diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2021-12-29 01:08:39 +0100 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2021-12-29 09:59:44 +0100 |
commit | 24065538e3bde99e6a4ebcad8ccac230443a5168 (patch) | |
tree | 92ccd321a3f8e9ae2cdcb4090fc48b624357c65b /modules | |
parent | 939e5909366c457c17aeffd5eb91a8f2e39894f9 (diff) | |
download | tde-cmake-24065538e3bde99e6a4ebcad8ccac230443a5168.tar.gz tde-cmake-24065538e3bde99e6a4ebcad8ccac230443a5168.zip |
Add the ability to specify the necessary CXX features.
This increases the minimum necessary version of CMake to 3.1.
There are three levels:
1. TDE_CXX_FEATURES common for all TDE modules
2. PROJECT_CXX_FEATURES common at invidual module level
3. CXX_FEATURES and CXX_FEATURES_PRIVATE for individual libraries and binaries
Public CXX_FEATURES for libraries become part of the exported CMake target.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 2bcaeab34e1f7d3714416a6d5290701d2b02be1e)
Diffstat (limited to 'modules')
-rw-r--r-- | modules/TDEMacros.cmake | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake index 424b6c2..51be52a 100644 --- a/modules/TDEMacros.cmake +++ b/modules/TDEMacros.cmake @@ -23,6 +23,10 @@ include( CheckCXXCompilerFlag ) ##### initialization... if( NOT TDE_CMAKE_ROOT ) + if( "${CMAKE_VERSION}" VERSION_LESS "3.1" ) + message( FATAL_ERROR "CMake >= 3.1.0 required" ) + endif() + if( ${CMAKE_CURRENT_LIST_DIR} STREQUAL ${CMAKE_ROOT}/Modules ) # TDE CMake is installed in the system directory @@ -792,6 +796,8 @@ macro( tde_add_library _arg_target ) unset( _version ) unset( _release ) unset( _sources ) + unset( _cxx_features ) + unset( _cxx_features_private ) unset( _destination ) unset( _embed ) unset( _link ) @@ -878,6 +884,18 @@ macro( tde_add_library _arg_target ) set( _storage "_sources" ) endif( "+${_arg}" STREQUAL "+SOURCES" ) + # found directive "CXX_FEATURES" + if( "+${_arg}" STREQUAL "+CXX_FEATURES" ) + set( _skip_store 1 ) + set( _storage "_cxx_features" ) + endif( "+${_arg}" STREQUAL "+CXX_FEATURES" ) + + # found directive "CXX_FEATURES_PRIVATE" + if( "+${_arg}" STREQUAL "+CXX_FEATURES_PRIVATE" ) + set( _skip_store 1 ) + set( _storage "_cxx_features_private" ) + endif( "+${_arg}" STREQUAL "+CXX_FEATURES_PRIVATE" ) + # found directive "EMBED" if( "+${_arg}" STREQUAL "+EMBED" ) set( _skip_store 1 ) @@ -997,6 +1015,15 @@ macro( tde_add_library _arg_target ) # add target add_library( ${_target} ${_type} ${_exclude_from_all} ${_sources} ) + # set cxx features + if( _cxx_features ) + target_compile_features( ${_target} PUBLIC ${_cxx_features} ) + endif( ) + if( TDE_CXX_FEATURES OR PROJECT_CXX_FEATURES OR _cxx_features_private ) + target_compile_features( ${_target} PRIVATE + ${TDE_CXX_FEATURES} ${PROJECT_CXX_FEATURES} ${_cxx_features_private} ) + endif( ) + # we assume that modules have no prefix and no version # also, should not link if( ${_type} STREQUAL "MODULE" ) @@ -1235,6 +1262,7 @@ macro( tde_add_executable _arg_target ) unset( _meta_includes ) unset( _setuid ) unset( _sources ) + unset( _cxx_features ) unset( _destination ) unset( _link ) unset( _dependencies ) @@ -1289,6 +1317,12 @@ macro( tde_add_executable _arg_target ) set( _storage "_sources" ) endif( "+${_arg}" STREQUAL "+SOURCES" ) + # found directive "CXX_FEATURES" + if( "+${_arg}" STREQUAL "+CXX_FEATURES" ) + set( _skip_store 1 ) + set( _storage "_cxx_features" ) + endif( "+${_arg}" STREQUAL "+CXX_FEATURES" ) + # found directive "LINK" if( "+${_arg}" STREQUAL "+LINK" ) set( _skip_store 1 ) @@ -1372,6 +1406,12 @@ macro( tde_add_executable _arg_target ) # add target add_executable( ${_target} ${_sources} ) + # set cxx features + if( TDE_CXX_FEATURES OR PROJECT_CXX_FEATURES OR _cxx_features ) + target_compile_features( ${_target} PRIVATE + ${TDE_CXX_FEATURES} ${PROJECT_CXX_FEATURES} ${_cxx_features} ) + endif( ) + # set link libraries if( _link ) target_link_libraries( ${_target} ${_link} ) |