[cmake-developers] Fwd: Question about CHECK_C_COMPILER_FLAG
Sergei Nikulov
sergey.nikulov at gmail.com
Mon Jun 20 07:23:41 EDT 2016
Hi All,
I have a question about CHECK_C_COMPILER_FLAG behaviour.
Documentation will tell that "the compiler does not give an error
message when it encounters the flag".
Unfortunately, it not only compiles but try to link executable.
If linker fails, due missed libraries it also does not produce
positive result even if compilation was successful.
Is it expected behaviour or issue?
My example environment
cmake v3.4.3/Linux/gcc v4.8.5
check_c_compiler_flag("-fsanitize=address" HAVE_C_FLAG_asan)
Log in CMakeError.log
...
erforming C SOURCE FILE Test HAVE_C_FLAG_asan failed with the following output:
Change Dir: /home/snikulov/work/github/curl/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/gmake" "cmTC_846be/fast"
/usr/bin/gmake -f CMakeFiles/cmTC_846be.dir/build.make
CMakeFiles/cmTC_846be.dir/build
gmake[1]: Entering directory
`/home/snikulov/work/github/curl/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_846be.dir/src.c.o
/usr/bin/cc -DHAVE_C_FLAG_asan -fsanitize=address -o
CMakeFiles/cmTC_846be.dir/src.c.o -c
/home/snikulov/work/github/curl/build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_846be
/usr/local/bin/cmake -E cmake_link_script
CMakeFiles/cmTC_846be.dir/link.txt --verbose=1
/usr/bin/cc -DHAVE_C_FLAG_asan CMakeFiles/cmTC_846be.dir/src.c.o
-o cmTC_846be -rdynamic /usr/lib64/libssl.so /usr/lib64/libcrypto.so
-lldap -llber
CMakeFiles/cmTC_846be.dir/src.c.o: In function `_GLOBAL__sub_I_00099_0_main':
src.c:(.text+0x10): undefined reference to `__asan_init_v1'
collect2: error: ld returned 1 exit status
gmake[1]: *** [cmTC_846be] Error 1
gmake[1]: Leaving directory
`/home/snikulov/work/github/curl/build/CMakeFiles/CMakeTmp'
gmake: *** [cmTC_846be/fast] Error 2
Source file was:
int main(void) { return 0; }
...
--
Best Regards,
Sergei Nikulov
More information about the cmake-developers
mailing list