Roger Leigh wrote: > 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?
Probably set CMAKE_CXX_STANDARD without CMAKE_CXX_STANDARD_REQUIRED (That variable doesn't really make sense to me and I think it is overused when not needed). > - 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? Not currently. It could be added now (as a global property), but that won't help you for existing CMake versions. > - 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 I think it already does that. Thanks, Steve. -- 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