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
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers