Add caching of variables from checks results and add conditions

to avoid unnecessary repetition of checks.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/41/head
Slávek Banko 5 years ago
parent 4ced9fd928
commit 778522d104
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -28,6 +28,8 @@ if( NOT TDE_FOUND )
if( NOT KDECONFIG_EXECUTABLE )
tde_message_fatal( "tde-config are NOT found." )
endif( NOT KDECONFIG_EXECUTABLE )
set( KDECONFIG_EXECUTABLE ${KDECONFIG_EXECUTABLE}
CACHE INTERNAL "tde-config executable" )
endif( NOT DEFINED KDECONFIG_EXECUTABLE )
set( ENV{LD_LIBRARY_PATH} "${TDE_LIBDIR}:$ENV{LD_LIBRARY_PATH}" )
@ -41,7 +43,7 @@ if( NOT TDE_FOUND )
# parse tde-config output, to extract TDE version
string( REGEX MATCH "TDE: R([0-9\\.]+).*" __dummy "${_version}" )
set( TDE_VERSION "${CMAKE_MATCH_1}" )
set( TDE_VERSION "${CMAKE_MATCH_1}" CACHE INTERNAL "" )
# ask tde-config for few paths
macro( __internal_get_path __type __var )
@ -80,8 +82,12 @@ if( NOT TDE_FOUND )
__internal_find_program( tdeconfig_compiler KDE3_KCFGC_EXECUTABLE )
__internal_find_program( maketdewidgets KDE3_MAKETDEWIDGETS_EXECUTABLE )
# Don't use __internal_find_program due to it's not mandatory
find_program( TDELFEDITOR_EXECUTABLE NAMES tdelfeditor
HINTS "${TDE_PREFIX}/bin" ${BIN_INSTALL_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE )
if( NOT DEFINED TDELFEDITOR_EXECUTABLE )
find_program( TDELFEDITOR_EXECUTABLE NAMES tdelfeditor
HINTS "${TDE_PREFIX}/bin" ${BIN_INSTALL_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE )
set( TDELFEDITOR_EXECUTABLE ${TDELFEDITOR_EXECUTABLE}
CACHE INTERNAL "tdelfeditor executable" )
endif( )
# dcopidlng is a bash script which using tde-config;
# if PATH to tde-config is not set, dcopidlng will fail;

@ -13,94 +13,99 @@ macro( tqt_message )
message( STATUS "${ARGN}" )
endmacro( )
pkg_search_module( TQT tqt )
if( NOT TQT_FOUND )
tde_message_fatal( "Unable to find tqt!\n Try adding the directory in which the tqt.pc file is located\nto the PKG_CONFIG_PATH variable." )
endif( )
pkg_search_module( TQT tqt )
if( NOT TQT_FOUND )
tde_message_fatal( "Unable to find tqt!\n Try adding the directory in which the tqt.pc file is located\nto the PKG_CONFIG_PATH variable." )
endif( )
mark_as_advanced(
mark_as_advanced(
TMOC_EXECUTABLE
MOC_EXECUTABLE
UIC_EXECUTABLE
)
)
# tmoc_executable
tde_execute_process(
COMMAND pkg-config tqt --variable=tmoc_executable
OUTPUT_VARIABLE TMOC_EXECUTABLE
CACHE FILEPATH "TQt tmoc executable path"
OUTPUT_STRIP_TRAILING_WHITESPACE )
# tmoc_executable
tde_execute_process(
COMMAND pkg-config tqt --variable=tmoc_executable
OUTPUT_VARIABLE TMOC_EXECUTABLE
CACHE FILEPATH "TQt tmoc executable path"
OUTPUT_STRIP_TRAILING_WHITESPACE )
if( NOT EXISTS ${TMOC_EXECUTABLE} )
tde_message_fatal( "tmoc is not found!\n tqt is correctly installed?" )
endif( )
if( NOT EXISTS ${TMOC_EXECUTABLE} )
tde_message_fatal( "tmoc is not found!\n tqt is correctly installed?" )
endif( )
tqt_message( " tmoc path: ${TMOC_EXECUTABLE}" )
tqt_message( " tmoc path: ${TMOC_EXECUTABLE}" )
# moc_executable
tde_execute_process(
COMMAND pkg-config tqt --variable=moc_executable
OUTPUT_VARIABLE MOC_EXECUTABLE
CACHE FILEPATH "TQt moc executable path"
OUTPUT_STRIP_TRAILING_WHITESPACE )
# moc_executable
tde_execute_process(
COMMAND pkg-config tqt --variable=moc_executable
OUTPUT_VARIABLE MOC_EXECUTABLE
CACHE FILEPATH "TQt moc executable path"
OUTPUT_STRIP_TRAILING_WHITESPACE )
if( NOT EXISTS ${MOC_EXECUTABLE} )
tde_message_fatal( "Path to moc is not set.\n tqt is correctly installed?" )
endif( )
if( NOT EXISTS ${MOC_EXECUTABLE} )
tde_message_fatal( "Path to moc is not set.\n tqt is correctly installed?" )
endif( )
tqt_message( " moc path: ${MOC_EXECUTABLE}" )
tqt_message( " moc path: ${MOC_EXECUTABLE}" )
# uic_executable
tde_execute_process(
COMMAND pkg-config tqt --variable=uic_executable
OUTPUT_VARIABLE UIC_EXECUTABLE
CACHE FILEPATH "TQt uic executable path"
OUTPUT_STRIP_TRAILING_WHITESPACE )
# uic_executable
tde_execute_process(
COMMAND pkg-config tqt --variable=uic_executable
OUTPUT_VARIABLE UIC_EXECUTABLE
CACHE FILEPATH "TQt uic executable path"
OUTPUT_STRIP_TRAILING_WHITESPACE )
if( NOT EXISTS ${UIC_EXECUTABLE} )
tde_message_fatal( "uic not found!\n tqt is correctly installed?" )
endif( )
if( NOT EXISTS ${UIC_EXECUTABLE} )
tde_message_fatal( "uic not found!\n tqt is correctly installed?" )
endif( )
tqt_message( " uic path: ${UIC_EXECUTABLE}" )
tqt_message( " uic path: ${UIC_EXECUTABLE}" )
# tqt-replace script
set( TQT_REPLACE_SCRIPT "${TQT_PREFIX}/bin/tqt-replace" )
# tqt-replace script
set( TQT_REPLACE_SCRIPT "${TQT_PREFIX}/bin/tqt-replace"
CACHE FILEPATH "TQt replace script path" )
if( NOT EXISTS ${TQT_REPLACE_SCRIPT} )
tde_message_fatal( "tqt-replace not found!\n Check tqt installation." )
endif( )
if( NOT EXISTS ${TQT_REPLACE_SCRIPT} )
tde_message_fatal( "tqt-replace not found!\n Check tqt installation." )
endif( )
tqt_message( " tqt-replace path: ${TQT_REPLACE_SCRIPT}" )
tqt_message( " tqt-replace path: ${TQT_REPLACE_SCRIPT}" )
# check if tqt is usable
tde_save( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
set( CMAKE_REQUIRED_INCLUDES ${TQT_INCLUDE_DIRS} )
foreach( _dirs ${TQT_LIBRARY_DIRS} )
list( APPEND CMAKE_REQUIRED_LIBRARIES "-L${_dirs}" )
endforeach()
list( APPEND CMAKE_REQUIRED_LIBRARIES ${TQT_LIBRARIES} )
# check if tqt is usable
tde_save( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
set( CMAKE_REQUIRED_INCLUDES ${TQT_INCLUDE_DIRS} )
foreach( _dirs ${TQT_LIBRARY_DIRS} )
list( APPEND CMAKE_REQUIRED_LIBRARIES "-L${_dirs}" )
endforeach()
list( APPEND CMAKE_REQUIRED_LIBRARIES ${TQT_LIBRARIES} )
check_cxx_source_compiles("
check_cxx_source_compiles("
#include <tqapplication.h>
int main(int argc, char **argv) { TQApplication app(argc, argv); return 0; } "
HAVE_USABLE_TQT )
HAVE_USABLE_TQT )
if( NOT HAVE_USABLE_TQT )
tde_message_fatal( "Unable to build a simple tqt test." )
endif( )
if( NOT HAVE_USABLE_TQT )
tde_message_fatal( "Unable to build a simple tqt test." )
endif( )
tde_restore( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
tde_restore( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
# TQT_CXX_FLAGS
foreach( _flag ${TQT_CFLAGS} ${TQT_CFLAGS_OTHER} )
set( TQT_CXX_FLAGS "${TQT_CXX_FLAGS} ${_flag}" )
endforeach()
set( TQT_CXX_FLAGS "${TQT_CXX_FLAGS}" CACHE INTERNAL "" )
# TQT_CXX_FLAGS
foreach( _flag ${TQT_CFLAGS} ${TQT_CFLAGS_OTHER} )
set( TQT_CXX_FLAGS "${TQT_CXX_FLAGS} ${_flag}" )
endforeach()
endif( NOT TQT_FOUND )
# Set compiler flags according to build type
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-DNDEBUG" )

@ -2311,19 +2311,21 @@ endif( )
##### tde_setup_architecture_flags
macro( tde_setup_architecture_flags )
message( STATUS "Detected ${CMAKE_SYSTEM_PROCESSOR} CPU architecture" )
## Immediate symbol binding is available only for gcc but not on ARM architectures
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" AND NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES arm* AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" )
set( LINKER_IMMEDIATE_BINDING_FLAGS "-z\ now" CACHE INTERNAL "" FORCE )
else( )
set( LINKER_IMMEDIATE_BINDING_FLAGS "" CACHE INTERNAL "" FORCE )
endif( )
if( NOT DEFINED LINKER_IMMEDIATE_BINDING_FLAGS )
message( STATUS "Detected ${CMAKE_SYSTEM_PROCESSOR} CPU architecture" )
## Immediate symbol binding is available only for gcc but not on ARM architectures
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" AND NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES arm* AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" )
set( LINKER_IMMEDIATE_BINDING_FLAGS "-z\ now" CACHE INTERNAL "" FORCE )
else( )
set( LINKER_IMMEDIATE_BINDING_FLAGS "" CACHE INTERNAL "" FORCE )
endif( )
check_cxx_compiler_flag( -fPIE HAVE_PIE_SUPPORT )
if( HAVE_PIE_SUPPORT )
set( TDE_PIE_CFLAGS -fPIE )
set( TDE_PIE_LDFLAGS -pie )
endif( HAVE_PIE_SUPPORT )
check_cxx_compiler_flag( -fPIE HAVE_PIE_SUPPORT )
if( HAVE_PIE_SUPPORT )
set( TDE_PIE_CFLAGS -fPIE )
set( TDE_PIE_LDFLAGS -pie )
endif( HAVE_PIE_SUPPORT )
endif( )
endmacro( )
@ -2337,7 +2339,7 @@ macro( tde_setup_gcc_visibility )
tde_message_fatal( "gcc visibility support was requested, but your system is not *NIX" )
endif( NOT UNIX )
if( TQT_FOUND )
if( TQT_FOUND AND NOT DEFINED HAVE_TQT_VISIBILITY )
find_library( TQT_LIBFILE tqt-mt HINTS "${TQT_LIBRARY_DIRS}" )
if( NOT "${TQT_LIBFILE}" STREQUAL "TQT_LIBFILE-NOTFOUND" )
message( STATUS "Performing Test HAVE_TQT_VISIBILITY" )
@ -2350,11 +2352,12 @@ macro( tde_setup_gcc_visibility )
message( STATUS "Performing Test HAVE_TQT_VISIBILITY - Failed" )
tde_message_fatal( "gcc visibility support was requested, but not supported in tqt library" )
endif( )
set( HAVE_TQT_VISIBILITY 1 CACHE INTERNAL "" )
message( STATUS "Performing Test HAVE_TQT_VISIBILITY - Success" )
endif( )
endif( TQT_FOUND )
endif( TQT_FOUND AND NOT DEFINED HAVE_TQT_VISIBILITY )
if( TDE_FOUND )
if( TDE_FOUND AND NOT DEFINED HAVE_TDE_VISIBILITY )
find_file( TDEMACROS_H kdemacros.h HINTS "${TDE_INCLUDE_DIR}" )
if( NOT "${TDEMACROS_H}" STREQUAL "TDEMACROS_H-NOTFOUND" )
tde_save_and_set( CMAKE_REQUIRED_INCLUDES "${TDE_INCLUDE_DIR}" )
@ -2371,9 +2374,9 @@ macro( tde_setup_gcc_visibility )
tde_message_fatal( "gcc visibility support was requested, but not supported in tdelibs" )
endif( NOT HAVE_TDE_VISIBILITY )
endif( )
endif( TDE_FOUND )
endif( TDE_FOUND AND NOT DEFINED HAVE_TDE_VISIBILITY )
set( __KDE_HAVE_GCC_VISIBILITY 1 )
set( __KDE_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( )
@ -2520,7 +2523,8 @@ macro( tde_setup_dbus )
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if( DBUS_SYSTEM_CONF_BASE )
set( DBUS_SYSTEM_CONF_DIRECTORY "${DBUS_SYSTEM_CONF_BASE}/dbus-1/system.d" )
set( DBUS_SYSTEM_CONF_DIRECTORY "${DBUS_SYSTEM_CONF_BASE}/dbus-1/system.d"
CACHE PATH "Path for DBUS system configuration files" )
message( STATUS "Using " ${DBUS_SYSTEM_CONF_DIRECTORY} " for DBUS system configuration files" )
else( )
tde_message_fatal( "Can not find the base directory for the dbus-1 configuration" )
@ -2535,7 +2539,8 @@ macro( tde_setup_dbus )
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if( DBUS_SYSTEM_CONF_BASE )
set( DBUS_SESSION_CONF_DIRECTORY "${DBUS_SYSTEM_CONF_BASE}/dbus-1/session.d" )
set( DBUS_SESSION_CONF_DIRECTORY "${DBUS_SYSTEM_CONF_BASE}/dbus-1/session.d"
CACHE PATH "Path for DBUS session configuration files" )
message( STATUS "Using " ${DBUS_SESSION_CONF_DIRECTORY} " for DBUS session configuration files" )
else( )
tde_message_fatal( "Can not find the base directory for the dbus-1 configuration" )
@ -2549,6 +2554,8 @@ macro( tde_setup_dbus )
OUTPUT_VARIABLE DBUS_SESSION_DIRECTORY
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set( DBUS_SESSION_DIRECTORY "${DBUS_SESSION_DIRECTORY}"
CACHE PATH "Path for DBUS session service files" )
message( STATUS "Using " ${DBUS_SESSION_DIRECTORY} " for DBUS session service files" )
endif( )
@ -2567,6 +2574,8 @@ macro( tde_setup_dbus )
tde_message_fatal( "Directory for DBUS system service files can not be determined." )
endif( )
endif( )
set( DBUS_SERVICE_DIRECTORY "${DBUS_SERVICE_DIRECTORY}"
CACHE PATH "Path for DBUS system service files" )
message( STATUS "Using " ${DBUS_SERVICE_DIRECTORY} " for DBUS system service files" )
endif( )
@ -2625,6 +2634,8 @@ macro( tde_setup_polkit )
OUTPUT_VARIABLE POLKIT_ACTIONS_DIRECTORY
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set( POLKIT_ACTIONS_DIRECTORY "${POLKIT_ACTIONS_DIRECTORY}"
CACHE PATH "Path for PolicyKit action files" )
message( STATUS "Using " ${POLKIT_ACTIONS_DIRECTORY} " for PolicyKit action files" )
endif( )

Loading…
Cancel
Save