View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0015361 | CMake | CMake | public | 2015-01-19 18:28 | 2016-06-10 14:31 | ||||
Reporter | Laurent Demailly | ||||||||
Assigned To | Kitware Robot | ||||||||
Priority | normal | Severity | major | Reproducibility | always | ||||
Status | closed | Resolution | moved | ||||||
Platform | Linux | OS | Ubuntu | OS Version | 14.04.1 | ||||
Product Version | CMake 3.1 | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0015361: CHECK_CXX_SOURCE_COMPILES doesn't use c++11 flags specified | ||||||||
Description | I have set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED on) in my cmake file - yet later when I try: check_cxx_source_compiles( "extern \"C\" void cmkcheckweak() __attribute__((weak)); int main(int argc, char** argv) { return cmkcheckweak == nullptr; // works with (void*)0; }" HAVE_WEAK_SYMBOLS) it fails incorrectly because it invokes the compiler without the -std=gnu++11 it adds for regular files (the goal/point of CMAKE_CXX_STANDARD_REQUIRED is to use that compiler for everything and not me having to write code to guess the way to request c++11 compiler) this is related to http://public.kitware.com/Bug/view.php?id=15359 [^] but while here there is an easy work around (not use nullptr and use 0 instead) that won't work for other tests I'm trying to do with CHECK_CXX_SOURCE_COMPILES suggestions/workarounds on how to make CHECK_CXX_SOURCE_COMPILES use the same compiler invocation as my other targets would be most welcome in the meantime | ||||||||
Steps To Reproduce | see above and below | ||||||||
Additional Information | Performing C++ SOURCE FILE Test HAVE_WEAK_SYMBOLS failed with the following output: Change Dir: /home/ldemailly/mac/wdt_ubuntu_build/CMakeFiles/CMakeTmp Run Build Command:"/usr/bin/make" "cmTryCompileExec1489303762/fast" /usr/bin/make -f CMakeFiles/cmTryCompileExec1489303762.dir/build.make CMakeFiles/cmTryCompileExec1489303762.dir/build make[1]: Entering directory `/mnt/hgfs/ldemailly/wdt_ubuntu_build/CMakeFiles/CMakeTmp' /usr/local/bin/cmake -E cmake_progress_report /home/ldemailly/mac/wdt_ubuntu_build/CMakeFiles/CMakeTmp/CMakeFiles 1 Building CXX object CMakeFiles/cmTryCompileExec1489303762.dir/src.cxx.o /usr/bin/c++ -DHAVE_WEAK_SYMBOLS -o CMakeFiles/cmTryCompileExec1489303762.dir/src.cxx.o -c /home/ldemailly/mac/wdt_ubuntu_build/CMakeFiles/CMakeTmp/src.cxx /home/ldemailly/mac/wdt_ubuntu_build/CMakeFiles/CMakeTmp/src.cxx: In function ‘int main(int, char**)’: /home/ldemailly/mac/wdt_ubuntu_build/CMakeFiles/CMakeTmp/src.cxx:3:26: error: ‘nullptr’ was not declared in this scope return cmkcheckweak == nullptr; // (void*)0; works ^ make[1]: Leaving directory `/mnt/hgfs/ldemailly/wdt_ubuntu_build/CMakeFiles/CMakeTmp' make[1]: *** [CMakeFiles/cmTryCompileExec1489303762.dir/src.cxx.o] Error 1 make: *** [cmTryCompileExec1489303762/fast] Error 2 Source file was: extern "C" void cmkcheckweak() __attribute__((weak)); int main(int argc, char** argv) { return cmkcheckweak == nullptr; // (void*)0; works } | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | |||||||||
Relationships | |||||||||||
|
Relationships |
Notes | |
(0037755) Laurent Demailly (reporter) 2015-01-19 20:05 |
found a temporary workaround: set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_CXX11_STANDARD_COMPILE_OPTION}) before check_cxx_source_compiles(...) but what if there were other flags etc... |
(0037757) Laurent Demailly (reporter) 2015-01-20 14:05 |
I realized it seems internally check compiler flags calls CHECK_CXX_SOURCE_COMPILES but I think the "public" version (or a new function) should use all the flags that other CXX files would get I also have a related (faq?) issue about check_library_exists() using c and not c++ - any way to make it use c++ ? and (maybe I should ask in seperate issue or email) : why do I must list C CXX in my pure c++ project (if I remove C things fail - I would think cmake should switch to use c++ for everything when the project is CXX ? instead of having some macros that have _cxx and some that only exist with C) |
(0037760) Brad King (manager) 2015-01-21 08:29 |
Re 0015361:0037757: For basic projects enabling just CXX is enough for a pure C++ project. However, as you point out check macros like check_library_exists assume C is enabled, so C must be enabled to use them. Many such check macros were written before we had separate C and CXX language enabling capabilities. As this issue records the check macros need to be taught more about the CXX_STANDARD levels and other information about language variants and flags. The language standard levels and "Compile Features" interfaces are all brand new so not everything has been updated to support them. |
(0039119) Roman80 (reporter) 2015-07-10 01:12 |
I can reproduce the problem on Mac OS 10.10.x too. The current workaround "for me" is, to set the CMAKE_CXX_FLAGS manually before the check_cxx_source_compiles() calls like: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++") But then I must maintain two places, the CMAKE_CXX_FLAGS and: set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED on) |
(0039292) Laurent Demailly (reporter) 2015-08-17 20:02 |
ping ? my temp workaround makes basic thing like check_function_exists(open HAS_OPEN) fail any idea btw to get verbose / details on what cmake did / why it didn't find something ? |
(0039293) Laurent Demailly (reporter) 2015-08-17 20:24 |
found where to look for errors: CMakeFiles/CMakeError.log has error: invalid argument '-std=c++11' not allowed with 'C/ObjC' as a result for check_function_exists() |
(0042701) Kitware Robot (administrator) 2016-06-10 14:29 |
Resolving issue as `moved`. This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2015-01-19 18:28 | Laurent Demailly | New Issue | |
2015-01-19 20:05 | Laurent Demailly | Note Added: 0037755 | |
2015-01-20 08:31 | Brad King | Relationship added | related to 0015359 |
2015-01-20 14:05 | Laurent Demailly | Note Added: 0037757 | |
2015-01-21 08:29 | Brad King | Note Added: 0037760 | |
2015-05-01 13:29 | Brad King | Relationship added | has duplicate 0015550 |
2015-07-10 01:12 | Roman80 | Note Added: 0039119 | |
2015-08-17 20:02 | Laurent Demailly | Note Added: 0039292 | |
2015-08-17 20:24 | Laurent Demailly | Note Added: 0039293 | |
2016-06-10 14:29 | Kitware Robot | Note Added: 0042701 | |
2016-06-10 14:29 | Kitware Robot | Status | new => resolved |
2016-06-10 14:29 | Kitware Robot | Resolution | open => moved |
2016-06-10 14:29 | Kitware Robot | Assigned To | => Kitware Robot |
2016-06-10 14:31 | Kitware Robot | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |