Reputation: 29096
I would like to investigate why I have this error:
$ cmake ..
-- The C compiler identification is unknown
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /cygdrive/c/Users/Ycr/Home/bin/arm-none-eabi-gcc
-- Check for working C compiler: /cygdrive/c/Users/Ycr/Home/bin/arm-none-eabi-gcc -- broken
CMake Error at /usr/share/cmake-3.6.2/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/cygdrive/c/Users/Ycr/Home/bin/arm-none-eabi-gcc" is not
able to compile a simple test program.
Unfortunately after the error:
CMakeFiles/cmTC_e4aa4.dir
was cleaned after the error, so I have no possibility to explore the issue myself.How should I investigate such an error?
I tried to use the --debug-trycompile
option. This time CMake creates a CMakeTmp
folder which makes perfectly without errors. However, I still have this CMakeFiles/cmTC_e4aa4.dir
that generates errors and even with the option CMake unlinks the folder.
Upvotes: 8
Views: 16584
Reputation: 719
For me, none of the log files in my output directory contained useful information from try_compile()
, even when using --debug-trycompile
.
I ended up using the OUTPUT_VARIABLE
option to capture and then print the output like this:
try_compile(<options> OUTPUT_VARIABLE TRY_COMPILE_OUTPUT)
message(WARNING ${TRY_COMPILE_OUTPUT})
Upvotes: 4
Reputation: 42852
The try_compile()
calls that CMake does in the beginning to test the compiler, gives a detailed error output on the console and writes it to
[your binary output directory]/CMakeFiles/CMakeError.log
I've checked the source code again and there is no CMake option that would give more a more detailed output for CMake's internal try_compile()
calls.
You could just force the output to standard output by adding some variable_watch()
calls to your main CMakeLists.txt
before your project()
call like:
variable_watch(__CMAKE_C_COMPILER_OUTPUT)
variable_watch(__CMAKE_CXX_COMPILER_OUTPUT)
To keep the temporary file of try_compile
, add --debug-trycompile
to the cmake
command line.
But be aware that the multiple compiler tests at the beginning overwrite the artifacts of previous ones:
It may however change the results of the try-compiles as old junk from a previous try-compile may cause a different test to either pass or fail incorrectly. This option is best used for one try-compile at a time, and only when debugging.
Upvotes: 6