port of cmake c++ standard detection from RC_1_1
This commit is contained in:
parent
8841c58435
commit
8258a114b9
|
@ -54,20 +54,35 @@ macro(find_public_dependency _name)
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
function(_cxx_standard_to_year _yearVar _std)
|
||||||
|
if (${_std} GREATER 97)
|
||||||
|
math(EXPR _year "1900 + ${_std}")
|
||||||
|
else()
|
||||||
|
math(EXPR _year "2000 + ${_std}")
|
||||||
|
endif()
|
||||||
|
set(${_yearVar} ${_year} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
function(select_cxx_standard _target _minimal_supported_version)
|
function(select_cxx_standard _target _minimal_supported_version)
|
||||||
message(STATUS "Compiler default is C++${CMAKE_CXX_STANDARD_DEFAULT}")
|
message(STATUS "Compiler default is C++${CMAKE_CXX_STANDARD_DEFAULT}")
|
||||||
# make the CXX_STANDARD property public to ensure it makes it into the pkg-config file
|
# make the CXX_STANDARD property public to ensure it makes it into the pkg-config file
|
||||||
get_target_property(_std ${_target} CXX_STANDARD)
|
get_target_property(_std ${_target} CXX_STANDARD)
|
||||||
|
# ${CMAKE_CXX_STANDARD_DEFAULT} could be 98, which is lower version than C++11. Thus we convert std
|
||||||
|
# version to year value and compare years
|
||||||
|
_cxx_standard_to_year(minimal_supported_version_year ${_minimal_supported_version})
|
||||||
# if it is unset, select the default if it is sufficient or the ${_minimal_supported_version}
|
# if it is unset, select the default if it is sufficient or the ${_minimal_supported_version}
|
||||||
if (NOT ${_std})
|
if (NOT ${_std})
|
||||||
if (${CMAKE_CXX_STANDARD_DEFAULT} GREATER_EQUAL ${_minimal_supported_version})
|
_cxx_standard_to_year(std_default_year ${CMAKE_CXX_STANDARD_DEFAULT})
|
||||||
|
if (${std_default_year} GREATER_EQUAL ${minimal_supported_version_year})
|
||||||
set(_std ${CMAKE_CXX_STANDARD_DEFAULT})
|
set(_std ${CMAKE_CXX_STANDARD_DEFAULT})
|
||||||
else()
|
else()
|
||||||
set(_std ${_minimal_supported_version})
|
set(_std ${_minimal_supported_version})
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
if (${_std} LESS ${_minimal_supported_version})
|
_cxx_standard_to_year(std_year ${_std})
|
||||||
message(FATAL_ERROR "Sorry, C++${_std} is not supported by libtorrent")
|
if (${std_year} LESS ${minimal_supported_version_year})
|
||||||
|
message(SEND_ERROR "Sorry, C++${_std} is not supported by libtorrent with the given Boost version")
|
||||||
|
message(FATAL_ERROR "The minimal supported C++ standard version is C++${_minimal_supported_version}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue