File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -166,11 +166,10 @@ set_target_properties(zen PROPERTIES
166166 VERSION ${ZenLib_VERSION}
167167 SOVERSION ${ZenLib_MAJOR_VERSION}
168168 PUBLIC_HEADER "${ZenLib_HDRS} "
169- CXX_STANDARD 20
170- CXX_EXTENSIONS NO
171- CXX_STANDARD_REQUIRED NO
172169 )
173- target_compile_features (zen PRIVATE cxx_std_11 )
170+
171+ include (EnableLatestCXX )
172+ enable_latest_cxx (zen )
174173
175174install (TARGETS zen EXPORT zen-export
176175 PUBLIC_HEADER DESTINATION ${INCLUDE_INSTALL_DIR} /ZenLib
Original file line number Diff line number Diff line change 1+ function (enable_latest_cxx target )
2+
3+ set_target_properties (${target} PROPERTIES
4+ CXX_STANDARD_REQUIRED ON
5+ CXX_EXTENSIONS OFF
6+ )
7+
8+ # User override
9+ if (DEFINED CMAKE_CXX_STANDARD )
10+ target_compile_features (${target} PRIVATE cxx_std_${CMAKE_CXX_STANDARD} )
11+ return ()
12+ endif ()
13+
14+ # Select highest available from list of supported
15+ set (_known_standards 26 23 20 17 14 11)
16+ foreach (std ${_known_standards} )
17+ if ("cxx_std_${std} " IN_LIST CMAKE_CXX_COMPILE_FEATURES)
18+ target_compile_features (${target} PRIVATE cxx_std_${std} )
19+ message (STATUS "'${target} ' is using latest available C++ standard: C++${std} " )
20+ return ()
21+ endif ()
22+ endforeach ()
23+
24+ # Unsupported C++ version
25+ message (FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} does not support C++11 or newer." )
26+ endfunction ()
You can’t perform that action at this time.
0 commit comments