12

I'm currently trying to use CMake for cross-compiling. However, CMake seems to ignore the toolchain specified by

cmake -DCMAKE_TOOLCHAIN_FILE=my-toolchain.cmake . 

or

cmake . -DCMAKE_TOOLCHAIN_FILE=my-toolchain.cmake 

If I omit the CMAKE_TOOLCHAIN_FILE option, the exact same Makefile is generated. Furthermore, if I deliberately give a wrong filename or insert syntax and path errors in the toolchain file, CMake doesn't bother to complain either.

Is there a way to get more error/debug output during a CMake run? The only option I could find is "--debug-output", which isn't very helpful in my case.

0

1 Answer 1

20

My mistake. CMake always regenerated an existing build tree. By deleting CMakeCache.txt in the build directory, CMake is forced to generate a new build tree and does not ignore the CMAKE_TOOLCHAIN_FILE option anymore. See the CMake FAQ.

Sign up to request clarification or add additional context in comments.

4 Comments

If you make changes to the toolchain file, you should always start with an entirely empty build tree. Unless you know precisely what cache entries are affected by your toolchain file changes and they are "safe" for an incremental rebuild, you should assume the worst: everything should be rebuilt when you change your toolchain file...
Truly DIABOLICAL. I knew which variables I was 'fixing' but my fixes didn't work because it was coming from the cache. I grepped for the file that had the erroneous setting and deleted it specifically.
@ DLRdave does any change in my build cmakelists.txt also qualifies for this?
That's the answer what I really need.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.