[CMake] CHECK_CXX_SOURCE_COMPILES attempts linking

John Smith codeforgenator at gmail.com
Wed Sep 2 18:44:24 EDT 2009


It seems that CHECK_CXX_SOURCE_COMPILES attempts to link the object
files into an executable:

[...]
Performing C++ SOURCE FILE Test <sometest> failed with the following output:
Change Dir: /my-proj/builddir/CMakeFiles/CMakeTmp

Run Build Command:/usr/bin/gmake "cmTryCompileExec/fast"
[...]
gmake[1]: Entering directory `/my-proj/builddir/CMakeFiles/CMakeTmp'
[...]
Building CXX object CMakeFiles/cmTryCompileExec.dir/src.cxx.o
[...]
Linking CXX executable cmTryCompileExec
[...]
/usr/lib64/gcc/x86_64-slamd64-linux/4.1.2/../../../../lib/crt1.o: In
function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
[...]
Source file was:

#include <string.h>
bool ignore = &strerror_r != 0;

[...]

IMHO, the macro should only attempt to compile the source file. Is
this by design or by accident? If by design, what is the rationale
behind it?

Thanks.

-J


More information about the CMake mailing list