On newer cmake versions which support it, use more portable way to set c++ standard version
This commit is contained in:
parent
61611d03b2
commit
c2c2a6f1dc
21
utils.cmake
21
utils.cmake
@ -6,20 +6,25 @@ include(CheckCXXCompilerFlag)
|
|||||||
# Uses: target_activate_cpp14(buildtarget)
|
# Uses: target_activate_cpp14(buildtarget)
|
||||||
###################################################
|
###################################################
|
||||||
function(target_activate_cpp14 TARGET)
|
function(target_activate_cpp14 TARGET)
|
||||||
|
if("${CMAKE_VERSION}" VERSION_GREATER "3.1")
|
||||||
|
set_property(TARGET ${TARGET} PROPERTY CXX_STANDARD 14)
|
||||||
|
set_property(TARGET ${TARGET} PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||||
|
else("${CMAKE_VERSION}" VERSION_GREATER "3.1")
|
||||||
check_cxx_compiler_flag("-std=c++14" COMPILER_HAS_CPP14_SUPPORT)
|
check_cxx_compiler_flag("-std=c++14" COMPILER_HAS_CPP14_SUPPORT)
|
||||||
IF (COMPILER_HAS_CPP14_SUPPORT)
|
if (COMPILER_HAS_CPP14_SUPPORT)
|
||||||
target_compile_options(${TARGET} PUBLIC -std=c++14)
|
target_compile_options(${TARGET} PUBLIC -std=c++14)
|
||||||
ELSE()
|
else(COMPILER_HAS_CPP14_SUPPORT)
|
||||||
check_cxx_compiler_flag("-std=c++1y" COMPILER_HAS_CPP14_PARTIAL_SUPPORT)
|
check_cxx_compiler_flag("-std=c++1y" COMPILER_HAS_CPP14_PARTIAL_SUPPORT)
|
||||||
IF (COMPILER_HAS_CPP14_PARTIAL_SUPPORT)
|
if (COMPILER_HAS_CPP14_PARTIAL_SUPPORT)
|
||||||
target_compile_options(${TARGET} PUBLIC -std=c++1y)
|
target_compile_options(${TARGET} PUBLIC -std=c++1y)
|
||||||
ELSE()
|
else()
|
||||||
message(FATAL_ERROR "Compiler doesn't support C++14")
|
message(FATAL_ERROR "Compiler doesn't support C++14")
|
||||||
ENDIF()
|
endif()
|
||||||
ENDIF()
|
endif(COMPILER_HAS_CPP14_SUPPORT)
|
||||||
IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
target_compile_options(${TARGET} PUBLIC -stdlib=libc++)
|
target_compile_options(${TARGET} PUBLIC -stdlib=libc++)
|
||||||
ENDIF()
|
endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
endif("${CMAKE_VERSION}" VERSION_GREATER "3.1")
|
||||||
endfunction(target_activate_cpp14)
|
endfunction(target_activate_cpp14)
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
|
Loading…
Reference in New Issue
Block a user