[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    [CMake] C++ standard version fallbacks.
From:       Roger Leigh <rleigh () codelibre ! net>
Date:       2017-06-04 11:33:57
Message-ID: 8149b2f4-b4b6-4dd5-7b9f-11ad5cff92f6 () codelibre ! net
[Download RAW message or body]

Hi folks,

I'm currently using this logic to use C++14 with a fallback to C++11 
when C++14 is unavailable:

   if(NOT CMAKE_CXX_STANDARD)
     set(CMAKE_CXX_STANDARD 14)
   endif()
   if(NOT CMAKE_CXX_STANDARD_REQUIRED)
     set(CMAKE_CXX_STANDARD_REQUIRED 11)
   endif()

which seems to work OK.

However, for some new stuff, I'd like to use C++17 when available, but 
fall back to C++14, C++11 or C++98.  Is it possible to do this?

- I'd like it to work on older CMake versions where "17" isn't a valid 
version for the above; is there any way to introspect the supported 
standards?
- And I'd like it to fall back intelligently, i.e. if 17 isn't available 
I want it to select the newest standard possible, rather than falling 
back all the way to 98

Any suggestions?


Thanks,
Roger
-- 

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic