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>
pull/79/head
Slávek Banko 3 years ago
parent 6980b57268
commit 2bcaeab34e
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -23,6 +23,10 @@ include( CheckCXXCompilerFlag )
##### initialization... ##### initialization...
if( NOT TDE_CMAKE_ROOT ) 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 ) if( ${CMAKE_CURRENT_LIST_DIR} STREQUAL ${CMAKE_ROOT}/Modules )
# TDE CMake is installed in the system directory # TDE CMake is installed in the system directory
@ -792,6 +796,8 @@ macro( tde_add_library _arg_target )
unset( _version ) unset( _version )
unset( _release ) unset( _release )
unset( _sources ) unset( _sources )
unset( _cxx_features )
unset( _cxx_features_private )
unset( _destination ) unset( _destination )
unset( _embed ) unset( _embed )
unset( _link ) unset( _link )
@ -878,6 +884,18 @@ macro( tde_add_library _arg_target )
set( _storage "_sources" ) set( _storage "_sources" )
endif( "+${_arg}" STREQUAL "+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" # found directive "EMBED"
if( "+${_arg}" STREQUAL "+EMBED" ) if( "+${_arg}" STREQUAL "+EMBED" )
set( _skip_store 1 ) set( _skip_store 1 )
@ -997,6 +1015,15 @@ macro( tde_add_library _arg_target )
# add target # add target
add_library( ${_target} ${_type} ${_exclude_from_all} ${_sources} ) 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 # we assume that modules have no prefix and no version
# also, should not link # also, should not link
if( ${_type} STREQUAL "MODULE" ) if( ${_type} STREQUAL "MODULE" )
@ -1235,6 +1262,7 @@ macro( tde_add_executable _arg_target )
unset( _meta_includes ) unset( _meta_includes )
unset( _setuid ) unset( _setuid )
unset( _sources ) unset( _sources )
unset( _cxx_features )
unset( _destination ) unset( _destination )
unset( _link ) unset( _link )
unset( _dependencies ) unset( _dependencies )
@ -1289,6 +1317,12 @@ macro( tde_add_executable _arg_target )
set( _storage "_sources" ) set( _storage "_sources" )
endif( "+${_arg}" STREQUAL "+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" # found directive "LINK"
if( "+${_arg}" STREQUAL "+LINK" ) if( "+${_arg}" STREQUAL "+LINK" )
set( _skip_store 1 ) set( _skip_store 1 )
@ -1372,6 +1406,12 @@ macro( tde_add_executable _arg_target )
# add target # add target
add_executable( ${_target} ${_sources} ) 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 # set link libraries
if( _link ) if( _link )
target_link_libraries( ${_target} ${_link} ) target_link_libraries( ${_target} ${_link} )

@ -1,6 +1,7 @@
add_library( @_target@ @_type@ IMPORTED ) add_library( @_target@ @_type@ IMPORTED )
set_target_properties( @_target@ PROPERTIES set_target_properties( @_target@ PROPERTIES
INTERFACE_COMPILE_FEATURES "@_cxx_features@"
IMPORTED_LINK_INTERFACE_LIBRARIES "@_shared_libs@" IMPORTED_LINK_INTERFACE_LIBRARIES "@_shared_libs@"
IMPORTED_LOCATION "@_location@" IMPORTED_LOCATION "@_location@"
IMPORTED_SONAME "@_soname@" ) IMPORTED_SONAME "@_soname@" )

Loading…
Cancel
Save