[cmake-developers] [CMake 0015550]: check_cxx_source_compiles() does not honor CMAKE_CXX_STANDARD

Mantis Bug Tracker mantis at public.kitware.com
Fri May 1 13:26:08 EDT 2015


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=15550 
====================================================================== 
Reported By:                Daniel Schepler
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15550
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-05-01 10:26 PDT
Last Modified:              2015-05-01 10:26 PDT
====================================================================== 
Summary:                    check_cxx_source_compiles() does not honor
CMAKE_CXX_STANDARD
Description: 
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.

Steps to Reproduce: 
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)

Additional Information: 
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.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-05-01 10:26 Daniel ScheplerNew Issue                                    
======================================================================



More information about the cmake-developers mailing list