@ -15,7 +15,11 @@
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
include ( CheckCXXCompilerFlag )
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # #
# # # # # N e e d c m a k e m i n i m u m v e r s i o n
include ( TDEVersion )
@ -24,8 +28,8 @@ include( TDEVersion )
# # # # # i n i t i a l i z a t i o n . . .
if ( NOT TDE_CMAKE_ROOT )
if ( "${CMAKE_VERSION}" VERSION_LESS " 3.1 " )
message ( FATAL_ERROR "CMake >= 3.1.0 required" )
if ( "${CMAKE_VERSION}" VERSION_LESS " ${TDE_CMAKE_MINIMUM_VERSION} " )
message ( FATAL_ERROR "CMake >= ${TDE_CMAKE_MINIMUM_VERSION} required" )
endif ( )
if ( ${ CMAKE_CURRENT_LIST_DIR } STREQUAL ${ CMAKE_ROOT } /Modules )
@ -66,14 +70,63 @@ if( NOT TDE_CMAKE_ROOT )
endif ( )
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # #
# # # # # s e t n e c e s s a r y C M a k e p o l i c i e s
cmake_policy ( PUSH )
if ( POLICY CMP0057 )
# n e c e s s a r y f o r C h e c k L i n k e r F l a g
cmake_policy ( SET CMP0057 NEW )
endif ( )
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # #
# # # # # n e c e s s a r y i n c l u d e s
include ( CheckCXXCompilerFlag )
include ( CheckCXXSourceCompiles )
include ( CheckLinkerFlag OPTIONAL )
include ( CheckSymbolExists )
include ( CheckTypeSize )
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # #
# # # # # t d e _ c o n c a t _ m s g
macro ( tde_concat_msg _msg )
unset ( ${ _msg } )
foreach ( _arg ${ ARGN } )
string ( APPEND ${ _msg } " ${_arg}\n" )
endforeach ( )
endmacro ( tde_concat_msg )
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # #
# # # # # t d e _ m e s s a g e _ a u t h o r _ w a r n i n g
function ( tde_message_author_warning )
tde_concat_msg ( _msg ${ ARGV } )
message ( AUTHOR_WARNING
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ n "
" $ { _ m s g } "
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " )
endfunction ( tde_message_author_warning )
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # #
# # # # # t d e _ m e s s a g e _ f a t a l
macro ( tde_message_fatal )
tde_concat_msg ( _msg ${ ARGV } )
message ( FATAL_ERROR
" # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \ n "
" $ { A R G V } \ n "
" $ { _ m s g } "
" # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # " )
endmacro ( tde_message_fatal )
@ -193,9 +246,15 @@ macro( tde_read_src_metadata )
endmacro ( tde_read_src_metadata )
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # #
# # # # # f i n a l i z a t i o n a s a s l a v e p a r t
if ( DEFINED MASTER_SOURCE_DIR )
cmake_policy ( POP )
return ( )
endif ( )
# # # # # # # # # # # s l a v e p a r t e n d s h e r e # # # # # # # # # # # # # # #
@ -813,19 +872,29 @@ endfunction( )
macro ( tde_import _library )
message ( STATUS "checking for '${_library}'" )
string ( TOUPPER "BUILD_${_library}" _build )
if ( ${ _build } )
message ( STATUS " ok, activated for build" )
else ( )
if ( EXISTS "${TDE_CMAKE_DIR}/${_library}.cmake" )
include ( "${TDE_CMAKE_DIR}/${_library}.cmake" )
elseif ( EXISTS "${TQT_CMAKE_DIR}/${_library}.cmake" )
include ( "${TQT_CMAKE_DIR}/${_library}.cmake" )
if ( NOT DEFINED TDE_IMPORT_ ${ _library } )
message ( STATUS "Checking for '${_library}'" )
string ( TOUPPER "BUILD_${_library}" _build )
if ( ${ _build } )
message ( STATUS "Checking for '${_library}' - ok, activated for build" )
set ( TDE_IMPORT_ ${ _library } "build" CACHE INTERNAL "Library ${_library} activated for build" )
else ( )
tde_message_fatal ( "'${_library}' is required, but is not installed nor selected for build" )
if ( EXISTS "${TDE_CMAKE_DIR}/${_library}.cmake" )
set ( tde_import_include "${TDE_CMAKE_DIR}/${_library}.cmake" )
elseif ( EXISTS "${TQT_CMAKE_DIR}/${_library}.cmake" )
set ( tde_import_include "${TQT_CMAKE_DIR}/${_library}.cmake" )
else ( )
tde_message_fatal ( "'${_library}' is required, but is not installed nor selected for build" )
endif ( )
include ( "${tde_import_include}" )
message ( STATUS "Checking for '${_library}' - ok, found import file" )
set ( TDE_IMPORT_ ${ _library } "import:${tde_import_include}" CACHE INTERNAL "Library ${_library} imported" )
endif ( )
else ( )
if ( "${TDE_IMPORT_${_library}}" MATCHES "^import:" )
string ( REGEX REPLACE "^import:" "" tde_import_include "${TDE_IMPORT_${_library}}" )
include ( "${tde_import_include}" )
endif ( )
message ( STATUS " ok, found import file" )
endif ( )
endmacro ( )
@ -1093,11 +1162,7 @@ macro( tde_add_library _arg_target )
# s e t - f P I C f l a g f o r s t a t i c l i b r a r i e s
if ( _static_pic )
if ( "${CMAKE_VERSION}" VERSION_LESS "2.8.9" )
set_target_properties ( ${ _target } PROPERTIES COMPILE_FLAGS -fPIC )
else ( )
set_target_properties ( ${ _target } PROPERTIES POSITION_INDEPENDENT_CODE ON )
endif ( )
set_target_properties ( ${ _target } PROPERTIES POSITION_INDEPENDENT_CODE ON )
endif ( _static_pic )
# s e t v e r s i o n
@ -1138,23 +1203,16 @@ macro( tde_add_library _arg_target )
# s e t p r i v a t e l i n k e d l i b r a r i e s
if ( _link_private )
if ( NOT ${ CMAKE_VERSION } VERSION_LESS "2.8.12" )
if ( _link )
list ( INSERT _link 0 "PUBLIC" )
endif ( )
list ( INSERT _link_private 0 "PRIVATE" )
if ( _link )
list ( INSERT _link 0 "PUBLIC" )
endif ( )
list ( INSERT _link_private 0 "PRIVATE" )
list ( INSERT _link 0 ${ _link_private } )
endif ( _link_private )
# s e t l i n k l i b r a r i e s
if ( _link )
if ( _embed AND ${ CMAKE_VERSION } VERSION_EQUAL "2.8.12.0" )
# h a c k f o r b r o k e n C M a k e 2 . 8 . 1 2 . 0
set_target_properties ( ${ _target } PROPERTIES LINK_LIBRARIES "${_link}" )
else ( _embed AND ${ CMAKE_VERSION } VERSION_EQUAL "2.8.12.0" )
target_link_libraries ( ${ _target } ${ _link } )
endif ( _embed AND ${ CMAKE_VERSION } VERSION_EQUAL "2.8.12.0" )
target_link_libraries ( ${ _target } ${ _link } )
endif ( )
if ( _shared_libs )
string ( TOUPPER "${CMAKE_BUILD_TYPE}" _build_type )
@ -2831,7 +2889,29 @@ macro( tde_setup_architecture_flags )
check_cxx_compiler_flag ( -fPIE HAVE_PIE_SUPPORT )
if ( HAVE_PIE_SUPPORT )
set ( TDE_PIE_CFLAGS -fPIE )
set ( TDE_PIE_LDFLAGS -pie )
if ( ${ CMAKE_VERSION } VERSION_LESS "3.18" )
execute_process ( COMMAND "${CMAKE_LINKER}" --help
O U T P U T _ V A R I A B L E _ _ l i n k e r _ h e l p
E R R O R _ V A R I A B L E _ _ l i n k e r _ h e l p )
if ( "${__linker_help}" MATCHES "-pie" )
set ( LINKER_PIE_SUPPORT 1 )
elseif ( "${__linker_help}" MATCHES "type=type.*pie" )
set ( LINKER_ZTYPE_PIE_SUPPORT 1 )
endif ( )
unset ( __linker_help )
else ( )
check_linker_flag ( CXX -pie LINKER_PIE_SUPPORT )
if ( NOT LINKER_PIE_SUPPORT )
check_linker_flag ( CXX -ztype=pie LINKER_ZTYPE_PIE_SUPPORT )
endif ( )
endif ( )
if ( LINKER_PIE_SUPPORT )
set ( TDE_PIE_LDFLAGS -pie )
endif ( LINKER_PIE_SUPPORT )
if ( LINKER_ZTYPE_PIE_SUPPORT )
set ( TDE_PIE_LDFLAGS -ztype=pie )
endif ( LINKER_ZTYPE_PIE_SUPPORT )
endif ( HAVE_PIE_SUPPORT )
set ( _reproducible_cxxflags
@ -2858,7 +2938,7 @@ endmacro( )
# # # # # t d e _ s e t u p _ g c c _ v i s i b i l i t y
macro ( tde_setup_gcc_visibility )
if ( NOT DEFINED __ K DE_HAVE_GCC_VISIBILITY )
if ( NOT DEFINED __ T DE_HAVE_GCC_VISIBILITY )
if ( NOT UNIX )
tde_message_fatal ( "gcc visibility support was requested, but your system is not *NIX" )
endif ( NOT UNIX )
@ -2882,12 +2962,12 @@ macro( tde_setup_gcc_visibility )
endif ( TQT_FOUND AND NOT DEFINED HAVE_TQT_VISIBILITY )
if ( TDE_FOUND AND NOT DEFINED HAVE_TDE_VISIBILITY )
find_file ( TDEMACROS_H k demacros.h HINTS "${TDE_INCLUDE_DIR}" )
find_file ( TDEMACROS_H t demacros.h HINTS "${TDE_INCLUDE_DIR}" )
if ( NOT "${TDEMACROS_H}" STREQUAL "TDEMACROS_H-NOTFOUND" )
tde_save_and_set ( CMAKE_REQUIRED_INCLUDES "${TDE_INCLUDE_DIR}" )
check_cxx_source_compiles ( "
# i n c l u d e < $ { T D E M A C R O S _ H } >
# i f n d e f _ _ K D E _ H A V E _ G C C _ V I S I B I L I T Y
# i f n d e f _ _ T D E _ H A V E _ G C C _ V I S I B I L I T Y
# e r r o r g c c v i s i b i l i t y i s n o t e n a b l e d i n t d e l i b s
# e n d i f
i n t main ( ) { r e t u r n 0 ; } "
@ -2900,7 +2980,7 @@ macro( tde_setup_gcc_visibility )
endif ( )
endif ( TDE_FOUND AND NOT DEFINED HAVE_TDE_VISIBILITY )
set ( __ K DE_HAVE_GCC_VISIBILITY 1 CACHE INTERNAL "" )
set ( __ T DE_HAVE_GCC_VISIBILITY 1 CACHE INTERNAL "" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden" )
endif ( )
@ -3164,3 +3244,13 @@ macro( tde_setup_polkit )
endif ( )
endmacro ( )
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # #
# # # # # r e s t o r e C M a k e p o l i c i e s
cmake_policy ( POP )
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #