diff --git a/CMakeLists.txt b/CMakeLists.txt index 28f0843..e82cf99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,12 +25,19 @@ set_target_properties(platform_folders PROPERTIES PUBLIC_HEADER "sago/platform_folders.h" ) -# Require (minimum) C++11 when using header -# PRIVATE means only at compile time -target_compile_features(platform_folders - PUBLIC cxx_std_11 - PRIVATE cxx_nullptr -) +# cxx_std_11 requires v3.8 +if(CMAKE_VERSION VERSION_LESS "3.8.0") + # Use old method of forcing C++11 + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED true) +else() + # Require (minimum) C++11 when using header + # PRIVATE means only at compile time + target_compile_features(platform_folders PUBLIC cxx_std_11) +endif() + +# cxx_nullptr exists in v3.1 +target_compile_features(platform_folders PRIVATE cxx_nullptr) # Apple requires linking to CoreServices # Check sys name instead of "APPLE" for cross-compilation diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ec0083a..8b11d44 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,13 +3,26 @@ add_library(platformfolders_internal_tester "tester.cpp" ) +# cxx_std_11 requires v3.8 +if(CMAKE_VERSION VERSION_LESS "3.8.0") + # Use old method of forcing C++11 + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED true) +else() + # Require (minimum) C++11 when using header + # PRIVATE means only at compile time + target_compile_features(platformfolders_internal_tester + PUBLIC cxx_std_11 + ) +endif() + +# cxx_range_for exists in v3.1 target_compile_features(platformfolders_internal_tester - PUBLIC cxx_std_11 PRIVATE cxx_range_for ) -target_include_directories(platformfolders_internal_tester PUBLIC - $ +target_include_directories(platformfolders_internal_tester + PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" ) # Easily define a new test to run @@ -19,9 +32,6 @@ macro(_def_test _name) platform_folders platformfolders_internal_tester ) - target_compile_features(${_name} PRIVATE - cxx_std_11 - ) add_test(NAME "${_name}" COMMAND "${_name}") endmacro()