MantisBT - CMake
View Issue Details
0015550CMakeCMakepublic2015-05-01 13:262015-11-02 09:15
Daniel Schepler 
 
normalminoralways
closedduplicate 
DebianLinuxstretch
CMake 3.2.2 
 
0015550: check_cxx_source_compiles() does not honor CMAKE_CXX_STANDARD
In a project I recently converted to use set(CMAKE_CXX_STANDARD 11) instead of the previous hard coding of -std=* compile flags in cxx_flag_overrides.cmake, I just noticed that our test for std::unordered_map<> broke.
set(CMAKE_CXX_STANDARD 11)
check_cxx_source_compiles(
"#include <unordered_map>

int main() {
    std::unordered_map<int, int> m;
    return m.size();
}"
    HAVE_STD_UNORDERED_MAP)
I can work around that with set(CMAKE_REQUIRED_FLAGS ${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}) . That seems a bit ugly, though.

I'm not sure what a proper "fix" to this would be. My ideas would be adding *_STANDARD arguments to try_compile() which might not quite be scalable; or maybe having check_cxx_source_compiles add -DCMAKE_CXX_STANDARD=... to the CMAKE_FLAGS it passes to try_compile(), based on CMAKE_CXX_STANDARD which could be overridden by setting CMAKE_REQUIRED_CXX_STANDARD which also seems like it might not be the best possible solution.
No tags attached.
duplicate of 0015361closed Kitware Robot CHECK_CXX_SOURCE_COMPILES doesn't use c++11 flags specified 
Issue History
2015-05-01 13:26Daniel ScheplerNew Issue
2015-05-01 13:29Brad KingRelationship addedduplicate of 0015361
2015-05-01 13:30Brad KingNote Added: 0038675
2015-05-01 13:30Brad KingStatusnew => resolved
2015-05-01 13:30Brad KingResolutionopen => duplicate
2015-11-02 09:15Robert MaynardNote Added: 0039799
2015-11-02 09:15Robert MaynardStatusresolved => closed

Notes
(0038675)
Brad King   
2015-05-01 13:30   
See 0015361:0037760.
(0039799)
Robert Maynard   
2015-11-02 09:15   
Closing resolved issues that have not been updated in more than 4 months.