Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Project/CMake/Modules/EnableLatestCXX.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ if(NOT "${CMAKE_VERSION}" VERSION_LESS "3.8")
# Select highest available from list of supported
set(_known_standards 26 23 20 17 14 11)
foreach(std ${_known_standards})
if("cxx_std_${std}" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
list(FIND CMAKE_CXX_COMPILE_FEATURES "cxx_std_${std}" _index)
if(NOT _index EQUAL -1)
target_compile_features(${target} PRIVATE cxx_std_${std})
message(STATUS "'${target}' is using latest available C++ standard: C++${std}")
return()
Expand All @@ -24,6 +25,13 @@ if(NOT "${CMAKE_VERSION}" VERSION_LESS "3.8")

# Unsupported C++ version
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} does not support C++11 or newer.")
else()
set_target_properties(${target} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
message(STATUS "${target}: Use CMake > 3.8 to automatically use the latest available C++ standard.")
endif()

endfunction()
Loading