summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2020-05-10 12:43:42 +0200
committerSlávek Banko <slavek.banko@axis.cz>2020-05-11 00:53:39 +0200
commitd9fc349162c317df055cd4ba3b67f2c710a7b0c1 (patch)
tree04540f39407bd8880010d2b907c281da7d76e16a
parentdfbf5fa376358de2b91534115ff0ad548492e0f0 (diff)
downloadtde-cmake-d9fc349162c317df055cd4ba3b67f2c710a7b0c1.tar.gz
tde-cmake-d9fc349162c317df055cd4ba3b67f2c710a7b0c1.zip
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> (cherry picked from commit 778522d10450a8a45133c65ae0175224c6abc700)
-rw-r--r--modules/FindTDE.cmake6
-rw-r--r--modules/FindTQt.cmake123
-rw-r--r--modules/TDEMacros.cmake47
3 files changed, 96 insertions, 80 deletions
diff --git a/modules/FindTDE.cmake b/modules/FindTDE.cmake
index 4f48ab4..569e1ce 100644
--- a/modules/FindTDE.cmake
+++ b/modules/FindTDE.cmake
@@ -28,6 +28,8 @@ if( NOT TDE_FOUND )
if( NOT KDECONFIG_EXECUTABLE )
tde_message_fatal( "kde-config are NOT found." )
endif( NOT KDECONFIG_EXECUTABLE )
+ set( KDECONFIG_EXECUTABLE ${KDECONFIG_EXECUTABLE}
+ CACHE INTERNAL "kde-config executable" )
endif( NOT DEFINED KDECONFIG_EXECUTABLE )
set( ENV{LD_LIBRARY_PATH} "${TDE_LIBDIR}:$ENV{LD_LIBRARY_PATH}" )
@@ -40,8 +42,8 @@ if( NOT TDE_FOUND )
MESSAGE "Unable to run kde-config!\n KDELIBS are correctly installed?\n Path to kde-config are corect?" )
# parse kde-config output, to extract TDE version
- string( REGEX MATCH "KDE: ([0-9\\.]+)" __dummy "${_version}" )
- set( TDE_VERSION "${CMAKE_MATCH_1}" )
+ string( REGEX MATCH "KDE: ([0-9\\.]+).*" __dummy "${_version}" )
+ set( TDE_VERSION "${CMAKE_MATCH_1}" CACHE INTERNAL "" )
# ask kde-config for few paths
macro( __internal_get_path __type __var )
diff --git a/modules/FindTQt.cmake b/modules/FindTQt.cmake
index 6194bb2..9c36cb9 100644
--- a/modules/FindTQt.cmake
+++ b/modules/FindTQt.cmake
@@ -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" )
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake
index 060daed..432adc9 100644
--- a/modules/TDEMacros.cmake
+++ b/modules/TDEMacros.cmake
@@ -2154,19 +2154,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( )
@@ -2180,7 +2182,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 qt-mt HINTS "${TQT_LIBRARY_DIRS}" )
if( NOT "${TQT_LIBFILE}" STREQUAL "TQT_LIBFILE-NOTFOUND" )
message( STATUS "Performing Test HAVE_TQT_VISIBILITY" )
@@ -2193,11 +2195,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 qt 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}" )
@@ -2214,9 +2217,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( )
@@ -2363,7 +2366,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" )
@@ -2378,7 +2382,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" )
@@ -2392,6 +2397,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( )
@@ -2410,6 +2417,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( )