diff options
author | Alexander Neundorf <neundorf@kde.org> | 2006-09-13 19:58:24 +0000 |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2006-09-13 19:58:24 +0000 |
commit | 1f010485d5e0ca81774c401c66af2612c47e6193 (patch) | |
tree | 0e3e95368d55fd82bf70c0bba8d437015c11e6e7 | |
parent | 732ad856ea72cc791fac712c06eaf0b659d5ea53 (diff) | |
download | extra-cmake-modules-1f010485d5e0ca81774c401c66af2612c47e6193.tar.gz extra-cmake-modules-1f010485d5e0ca81774c401c66af2612c47e6193.tar.bz2 |
-minor performance improvement: use LIST(APPEND list item1 item2... ) instead of SET(list ${list} item1 item2)
-add some documentation
-rename KDE4_HANDLE_RPATH() to KDE4_HANDLE_RPATH_FOR_EXECUTABLE() and add a new KDE4_HANDLE_RPATH_FOR_LIBRARY(), so that rpath handling is now very centralized
This shouldn't cause a recompile for anybody, at least it didn't for me. If it does nevertheless, let me know.
Alex
svn path=/trunk/KDE/kdelibs/; revision=583926
-rw-r--r-- | modules/FindKDE4Internal.cmake | 4 | ||||
-rw-r--r-- | modules/KDE4Macros.cmake | 104 |
2 files changed, 62 insertions, 46 deletions
diff --git a/modules/FindKDE4Internal.cmake b/modules/FindKDE4Internal.cmake index 6d57e6ac..82a7ae3f 100644 --- a/modules/FindKDE4Internal.cmake +++ b/modules/FindKDE4Internal.cmake @@ -506,7 +506,9 @@ if (UNIX) set( _KDE4_PLATFORM_INCLUDE_DIRS /usr/local/include ) # the rest is RPATH handling - + # here the defaults are set + # which are partly overwritten in kde4_handle_rpath_for_library() + # and kde4_handle_rpath_for_executable(), both located in KDE4Macros.cmake, Alex if (APPLE) set(CMAKE_INSTALL_NAME_DIR ${LIB_INSTALL_DIR}) else (APPLE) diff --git a/modules/KDE4Macros.cmake b/modules/KDE4Macros.cmake index 4bdc2b37..8e3eaa50 100644 --- a/modules/KDE4Macros.cmake +++ b/modules/KDE4Macros.cmake @@ -48,7 +48,7 @@ macro (KDE4_ADD_KCFG_FILES _sources ) macro_add_file_dependencies(${_src_FILE} ${_moc_FILE} ) endif(_kcfg_generatemoc) - set(${_sources} ${${_sources}} ${_src_FILE} ${_header_FILE}) + list(APPEND ${_sources} ${_src_FILE} ${_header_FILE}) endif(NOT ${_current_FILE} STREQUAL "GENERATE_MOC") endforeach (_current_FILE) @@ -79,7 +79,7 @@ macro (KDE4_ADD_UI_FILES _sources ) -P ${KDE4_MODULE_DIR}/kde4uic.cmake MAIN_DEPENDENCY ${_tmp_FILE} ) - set(${_sources} ${${_sources}} ${_header}) + list(APPEND ${_sources} ${_header}) endforeach (_current_FILE) endmacro (KDE4_ADD_UI_FILES) @@ -131,7 +131,7 @@ MACRO (KDE4_ADD_UI3_FILES _sources ) ARGS ${_moc_INCS} ${_header} -o ${_moc} MAIN_DEPENDENCY ${_header} ) - set(${_sources} ${${_sources}} ${_src} ${_moc} ) + list(APPEND ${_sources} ${_src} ${_moc} ) endforeach (_current_FILE) ENDMACRO (KDE4_ADD_UI3_FILES) @@ -340,23 +340,51 @@ MACRO (KDE4_INSTALL_LIBTOOL_FILE _subdir _target) ENDMACRO (KDE4_INSTALL_LIBTOOL_FILE) -MACRO (KDE4_CREATE_FINAL_FILES _filenameCPP _filenameC ) - FILE(WRITE ${_filenameCPP} "//autogenerated file\n") - FILE(WRITE ${_filenameC} "/*autogenerated file*/\n") +# For all C++ sources a big source file which includes all the files +# is created. +# This is not done for the C sources, they are just gathered in a separate list +# because they are usually not written by KDE and as such not intended to be +# compiled all-in-one. +macro (KDE4_CREATE_FINAL_FILES _filenameCPP _filesC ) + set(${_filesC}) + file(WRITE ${_filenameCPP} "//autogenerated file\n") foreach (_current_FILE ${ARGN}) - STRING(REGEX MATCH ".+\\.c$" _isCFile ${_current_FILE}) + string(REGEX MATCH ".+\\.c$" _isCFile ${_current_FILE}) if (_isCFile) - file(APPEND ${_filenameC} "#include \"${_current_FILE}\"\n") + list(APPEND ${_filesC} ${_current_FILE}) else (_isCFile) file(APPEND ${_filenameCPP} "#include \"${_current_FILE}\"\n") endif (_isCFile) endforeach (_current_FILE) -ENDMACRO (KDE4_CREATE_FINAL_FILES) +endmacro (KDE4_CREATE_FINAL_FILES) -# this macro sets the RPATH related options for executables -# and creates wrapper shell scripts for the executables -macro (KDE4_HANDLE_RPATH _target_NAME _type) +# This macro sets the RPATH related options for libraries, plugins and kdeinit executables. +# It overrides the defaults set in FindKDE4Internal.cmake. +# If RPATH is not explicitely disabled, libraries and plugins are built without RPATH, in +# the hope that the RPATH which is compiled into the executable is good enough. +macro (KDE4_HANDLE_RPATH_FOR_LIBRARY _target_NAME) + if (NOT CMAKE_SKIP_RPATH) + set_target_properties(${_target_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE BUILD_WITH_INSTALL_RPATH TRUE INSTALL_RPATH "") + endif (NOT CMAKE_SKIP_RPATH) +endmacro (KDE4_HANDLE_RPATH_FOR_LIBRARY) + +# This macro sets the RPATH related options for executables +# and creates wrapper shell scripts for the executables. +# It overrides the defaults set in FindKDE4Internal.cmake. +# For every executable a wrapper script is created, which sets the appropriate +# environment variable for the platform (LD_LIBRARY_PATH on most UNIX systems, +# DYLD_LIBRARY_PATH on OS X and PATH in Windows) so that it points to the built +# but not yet installed versions of the libraries. So if RPATH is disabled, the executables +# can be run via these scripts from the build tree and will find the correct libraries. +# If RPATH is not disabled, these scripts are also used but only for consistency, because +# they don't really influence anything then, because the compiled-in RPATH overrides +# the LD_LIBRARY_PATH env. variable. +# Executables with the RUN_UNINSTALLED option will be built with the RPATH pointing to the +# build dir, so that they can be run safely without being installed, e.g. as code generators +# for other stuff during the build. These executables will be relinked during "make install". +# All other executables are built with the RPATH with which they will be installed. +macro (KDE4_HANDLE_RPATH_FOR_EXECUTABLE _target_NAME _type) if (UNIX) # set the RPATH related properties @@ -414,9 +442,8 @@ macro (KDE4_HANDLE_RPATH _target_NAME _type) -P ${KDE4_MODULE_DIR}/kde4_exec_via_sh.cmake ) - endif (UNIX) -endmacro (KDE4_HANDLE_RPATH) +endmacro (KDE4_HANDLE_RPATH_FOR_EXECUTABLE) MACRO (KDE4_ADD_PLUGIN _target_NAME _with_PREFIX) @@ -428,31 +455,24 @@ MACRO (KDE4_ADD_PLUGIN _target_NAME _with_PREFIX) endif (${_with_PREFIX} STREQUAL "WITH_PREFIX") if (KDE4_ENABLE_FINAL) - KDE4_CREATE_FINAL_FILES(${_target_NAME}_final_cpp.cpp ${_target_NAME}_final_c.c ${_first_SRC} ${ARGN}) - ADD_LIBRARY(${_target_NAME} MODULE ${_target_NAME}_final_cpp.cpp ${_target_NAME}_final_c.c) + kde4_create_final_files(${_target_NAME}_final_cpp.cpp _c_files ${_first_SRC} ${ARGN}) + add_library(${_target_NAME} MODULE ${_target_NAME}_final_cpp.cpp ${_c_files}) else (KDE4_ENABLE_FINAL) - ADD_LIBRARY(${_target_NAME} MODULE ${_first_SRC} ${ARGN}) + add_library(${_target_NAME} MODULE ${_first_SRC} ${ARGN}) endif (KDE4_ENABLE_FINAL) if (_first_SRC) - SET_TARGET_PROPERTIES(${_target_NAME} PROPERTIES PREFIX "") + set_target_properties(${_target_NAME} PROPERTIES PREFIX "") endif (_first_SRC) - if (NOT CMAKE_SKIP_RPATH) - set_target_properties(${_target_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE BUILD_WITH_INSTALL_RPATH TRUE INSTALL_RPATH "") - endif (NOT CMAKE_SKIP_RPATH) + kde4_handle_rpath_for_library(${_target_NAME}) -# if (UNIX) -# I guess under windows the libtool file are not required -# KDE4_INSTALL_LIBTOOL_FILE(${_target_NAME}) -# endif (UNIX) - - IF (WIN32) + if (WIN32) # for shared libraries/plugins a -DMAKE_target_LIB is required string(TOUPPER ${_target_NAME} _symbol) set(_symbol "MAKE_${_symbol}_LIB") set_target_properties(${_target_NAME} PROPERTIES DEFINE_SYMBOL ${_symbol}) - ENDIF (WIN32) + endif (WIN32) ENDMACRO (KDE4_ADD_PLUGIN _target_NAME _with_PREFIX) @@ -521,17 +541,14 @@ macro (KDE4_ADD_KDEINIT_EXECUTABLE _target_NAME ) # else (WIN32) # under UNIX, create a shared library and a small executable, which links to this library if (KDE4_ENABLE_FINAL) - kde4_create_final_files(${_target_NAME}_final_cpp.cpp ${_target_NAME}_final_c.c ${_SRCS}) - add_library(kdeinit_${_target_NAME} SHARED ${_target_NAME}_final_cpp.cpp ${_target_NAME}_final_c.c) + kde4_create_final_files(${_target_NAME}_final_cpp.cpp _c_files ${_SRCS}) + add_library(kdeinit_${_target_NAME} SHARED ${_target_NAME}_final_cpp.cpp ${_c_files}) else (KDE4_ENABLE_FINAL) add_library(kdeinit_${_target_NAME} SHARED ${_SRCS} ) endif (KDE4_ENABLE_FINAL) - - if (NOT CMAKE_SKIP_RPATH) - set_target_properties(kdeinit_${_target_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE BUILD_WITH_INSTALL_RPATH TRUE INSTALL_RPATH "") - endif (NOT CMAKE_SKIP_RPATH) + kde4_handle_rpath_for_library(kdeinit_${_target_NAME}) kde4_add_executable(${_target_NAME} "${_nogui}" "${_uninst}" ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp) target_link_libraries(${_target_NAME} kdeinit_${_target_NAME}) @@ -565,13 +582,13 @@ macro (KDE4_ADD_EXECUTABLE _target_NAME) endif (_uninst) if (KDE4_ENABLE_FINAL) - kde4_create_final_files(${_target_NAME}_final_cpp.cpp ${_target_NAME}_final_c.c ${_SRCS}) - add_executable(${_target_NAME} ${_add_executable_param} ${_target_NAME}_final_cpp.cpp ${_target_NAME}_final_c.c) + kde4_create_final_files(${_target_NAME}_final_cpp.cpp ${_c_files} ${_SRCS}) + add_executable(${_target_NAME} ${_add_executable_param} ${_target_NAME}_final_cpp.cpp ${_c_files}) else (KDE4_ENABLE_FINAL) add_executable(${_target_NAME} ${_add_executable_param} ${_SRCS} ) endif (KDE4_ENABLE_FINAL) - kde4_handle_rpath(${_target_NAME} ${_type}) + kde4_handle_rpath_for_executable(${_target_NAME} ${_type}) endmacro (KDE4_ADD_EXECUTABLE) @@ -596,15 +613,13 @@ MACRO (KDE4_ADD_LIBRARY _target_NAME _lib_TYPE) endif (${_lib_TYPE} STREQUAL "MODULE") if (KDE4_ENABLE_FINAL) - KDE4_CREATE_FINAL_FILES(${_target_NAME}_final_cpp.cpp ${_target_NAME}_final_c.c ${_first_SRC} ${ARGN}) - ADD_LIBRARY(${_target_NAME} ${_add_lib_param} ${_target_NAME}_final_cpp.cpp ${_target_NAME}_final_c.c) + kde4_create_final_files(${_target_NAME}_final_cpp.cpp _c_files ${_first_SRC} ${ARGN}) + add_library(${_target_NAME} ${_add_lib_param} ${_target_NAME}_final_cpp.cpp ${_c_files}) else (KDE4_ENABLE_FINAL) - ADD_LIBRARY(${_target_NAME} ${_add_lib_param} ${_first_SRC} ${ARGN}) + add_library(${_target_NAME} ${_add_lib_param} ${_first_SRC} ${ARGN}) endif (KDE4_ENABLE_FINAL) - if (NOT CMAKE_SKIP_RPATH) - set_target_properties(${_target_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE BUILD_WITH_INSTALL_RPATH TRUE INSTALL_RPATH "") - endif (NOT CMAKE_SKIP_RPATH) + kde4_handle_rpath_for_library(${_target_NAME}) if (WIN32) # for shared libraries a -DMAKE_target_LIB is required @@ -634,7 +649,7 @@ MACRO (KDE4_ADD_WIDGET_FILES _sources) QT4_GENERATE_MOC(${_source} ${_moc} ) MACRO_ADD_FILE_DEPENDENCIES(${_source} ${_moc}) - SET(${_sources} ${${_sources}} ${_source}) + list(APPEND ${_sources} ${_source}) ENDFOREACH (_current_FILE) @@ -662,4 +677,3 @@ MACRO(KDE4_REMOVE_OBSOLETE_CMAKE_FILES) endforeach ( _current_FILE) ENDMACRO(KDE4_REMOVE_OBSOLETE_CMAKE_FILES) - |