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

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

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

Loading…
Cancel
Save