aboutsummaryrefslogtreecommitdiff
path: root/modules/KDE4Macros.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'modules/KDE4Macros.cmake')
-rw-r--r--modules/KDE4Macros.cmake98
1 files changed, 72 insertions, 26 deletions
diff --git a/modules/KDE4Macros.cmake b/modules/KDE4Macros.cmake
index 768a36e2..a17c1d4c 100644
--- a/modules/KDE4Macros.cmake
+++ b/modules/KDE4Macros.cmake
@@ -369,10 +369,12 @@ macro (KDE4_INSTALL_ICONS _defaultpath )
# first the png icons
file(GLOB _icons *.png)
foreach (_current_ICON ${_icons} )
- string(REGEX REPLACE "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\1" _type "${_current_ICON}")
- string(REGEX REPLACE "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\2" _size "${_current_ICON}")
- string(REGEX REPLACE "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\3" _group "${_current_ICON}")
- string(REGEX REPLACE "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\4" _name "${_current_ICON}")
+ # since CMake 2.6 regex matches are stored in special variables CMAKE_MATCH_x, if it didn't match, they are empty
+ string(REGEX MATCH "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" _dummy "${_current_ICON}")
+ set(_type "${CMAKE_MATCH_1}")
+ set(_size "${CMAKE_MATCH_2}")
+ set(_group "${CMAKE_MATCH_3}")
+ set(_name "${CMAKE_MATCH_4}")
set(_theme_GROUP ${_KDE4_ICON_THEME_${_type}})
if( _theme_GROUP)
@@ -385,10 +387,12 @@ macro (KDE4_INSTALL_ICONS _defaultpath )
# mng icons
file(GLOB _icons *.mng)
foreach (_current_ICON ${_icons} )
- string(REGEX REPLACE "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.mng)$" "\\1" _type "${_current_ICON}")
- string(REGEX REPLACE "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.mng)$" "\\2" _size "${_current_ICON}")
- string(REGEX REPLACE "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.mng)$" "\\3" _group "${_current_ICON}")
- string(REGEX REPLACE "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.mng)$" "\\4" _name "${_current_ICON}")
+ # since CMake 2.6 regex matches are stored in special variables CMAKE_MATCH_x, if it didn't match, they are empty
+ string(REGEX MATCH "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.mng)$" _dummy "${_current_ICON}")
+ set(_type "${CMAKE_MATCH_1}")
+ set(_size "${CMAKE_MATCH_2}")
+ set(_group "${CMAKE_MATCH_3}")
+ set(_name "${CMAKE_MATCH_4}")
set(_theme_GROUP ${_KDE4_ICON_THEME_${_type}})
if( _theme_GROUP)
@@ -401,9 +405,11 @@ macro (KDE4_INSTALL_ICONS _defaultpath )
# and now the svg icons
file(GLOB _icons *.svgz)
foreach (_current_ICON ${_icons} )
- string(REGEX REPLACE "^.*/([a-zA-Z]+)sc\\-([a-z]+)\\-(.+\\.svgz)$" "\\1" _type "${_current_ICON}")
- string(REGEX REPLACE "^.*/([a-zA-Z]+)sc\\-([a-z]+)\\-(.+\\.svgz)$" "\\2" _group "${_current_ICON}")
- string(REGEX REPLACE "^.*/([a-zA-Z]+)sc\\-([a-z]+)\\-(.+\\.svgz)$" "\\3" _name "${_current_ICON}")
+ # since CMake 2.6 regex matches are stored in special variables CMAKE_MATCH_x, if it didn't match, they are empty
+ string(REGEX MATCH "^.*/([a-zA-Z]+)sc\\-([a-z]+)\\-(.+\\.svgz)$" _dummy "${_current_ICON}")
+ set(_type "${CMAKE_MATCH_1}")
+ set(_group "${CMAKE_MATCH_2}")
+ set(_name "${CMAKE_MATCH_3}")
set(_theme_GROUP ${_KDE4_ICON_THEME_${_type}})
if( _theme_GROUP)
@@ -552,13 +558,20 @@ macro (KDE4_ADD_PLUGIN _target_NAME _with_PREFIX)
endif (${_with_PREFIX} STREQUAL "WITH_PREFIX")
set(_SRCS ${_first_SRC} ${ARGN})
- kde4_handle_automoc(${_target_NAME} _SRCS)
+ if(MSVC)
+ add_automoc4_target("${_target_NAME}_automoc" _SRCS)
+ else(MSVC)
+ automoc4(${_target_NAME} _SRCS)
+ endif(MSVC)
if (KDE4_ENABLE_FINAL)
kde4_create_final_files(${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_final_cpp.cpp _separate_files ${_SRCS})
add_library(${_target_NAME} MODULE ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_final_cpp.cpp ${_separate_files})
else (KDE4_ENABLE_FINAL)
add_library(${_target_NAME} MODULE ${_SRCS})
endif (KDE4_ENABLE_FINAL)
+ if(MSVC)
+ add_dependencies(${_target_NAME} "${_target_NAME}_automoc")
+ endif(MSVC)
if (_first_SRC)
set_target_properties(${_target_NAME} PROPERTIES PREFIX "")
@@ -802,13 +815,20 @@ macro (KDE4_ADD_EXECUTABLE _target_NAME)
set(_add_executable_param ${_add_executable_param} EXCLUDE_FROM_ALL)
endif (_test AND NOT KDE4_BUILD_TESTS)
- kde4_handle_automoc(${_target_NAME} _SRCS)
+ if(MSVC)
+ add_automoc4_target("${_target_NAME}_automoc" _SRCS)
+ else(MSVC)
+ automoc4(${_target_NAME} _SRCS)
+ endif(MSVC)
if (KDE4_ENABLE_FINAL)
kde4_create_final_files(${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_final_cpp.cpp _separate_files ${_SRCS})
add_executable(${_target_NAME} ${_add_executable_param} ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_final_cpp.cpp ${_separate_files})
else (KDE4_ENABLE_FINAL)
add_executable(${_target_NAME} ${_add_executable_param} ${_SRCS})
endif (KDE4_ENABLE_FINAL)
+ if(MSVC)
+ add_dependencies(${_target_NAME} "${_target_NAME}_automoc")
+ endif(MSVC)
if (_test)
set_target_properties(${_target_NAME} PROPERTIES COMPILE_FLAGS -DKDESRCDIR="\\"${CMAKE_CURRENT_SOURCE_DIR}\\"")
@@ -843,13 +863,20 @@ macro (KDE4_ADD_LIBRARY _target_NAME _lib_TYPE)
endif (${_lib_TYPE} STREQUAL "MODULE")
set(_SRCS ${_first_SRC} ${ARGN})
- kde4_handle_automoc(${_target_NAME} _SRCS)
+ if(MSVC)
+ add_automoc4_target("${_target_NAME}_automoc" _SRCS)
+ else(MSVC)
+ automoc4(${_target_NAME} _SRCS)
+ endif(MSVC)
if (KDE4_ENABLE_FINAL)
kde4_create_final_files(${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_final_cpp.cpp _separate_files ${_SRCS})
add_library(${_target_NAME} ${_add_lib_param} ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_final_cpp.cpp ${_separate_files})
else (KDE4_ENABLE_FINAL)
add_library(${_target_NAME} ${_add_lib_param} ${_SRCS})
endif (KDE4_ENABLE_FINAL)
+ if(MSVC)
+ add_dependencies(${_target_NAME} "${_target_NAME}_automoc")
+ endif(MSVC)
kde4_handle_rpath_for_library(${_target_NAME})
@@ -859,14 +886,14 @@ macro (KDE4_ADD_LIBRARY _target_NAME _lib_TYPE)
set(_symbol "MAKE_${_symbol}_LIB")
set_target_properties(${_target_NAME} PROPERTIES DEFINE_SYMBOL ${_symbol})
- # if that option is enabled, by default don't add any linked libraries to the "exported"
- # link interfaces, so that executables linking against this library won't get additional
- # indirect dependencies. This makes work easier for packagers and should make application
- # startup somewhat faster, if I understood Dirk correctly.
+ # by default don't add any linked libraries to the "exported"
+ # link interfaces, so that executables linking against this library
+ # will not automatically add implicit dependencies to their link list.
+ #
+ # This reduces inter-package dependencies and makes it easier to remove
+ # dependencies of shared libraries without breaking binary compatibility.
if(NOT "${_add_lib_param}" STREQUAL "STATIC")
- if(KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT AND UNIX )# AND NOT APPLE)
- set_target_properties(${_target_NAME} PROPERTIES LINK_INTERFACE_LIBRARIES "" )
- endif(KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT AND UNIX)# AND NOT APPLE)
+ set_target_properties(${_target_NAME} PROPERTIES ${KDE4_DISABLE_PROPERTY_}LINK_INTERFACE_LIBRARIES "" )
endif(NOT "${_add_lib_param}" STREQUAL "STATIC")
endmacro (KDE4_ADD_LIBRARY _target_NAME _lib_TYPE)
@@ -1086,7 +1113,7 @@ endmacro (KDE4_ADD_APP_ICON)
macro(_KDE4_EXPORT_LIBRARY_DEPENDENCIES _append_or_write _filename)
- if(KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT AND UNIX )# AND NOT APPLE)
+# if(KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT AND UNIX )# AND NOT APPLE)
# get all cmake variables which end in _LIB_DEPENDS
# then parse the target name out of them
@@ -1098,9 +1125,7 @@ macro(_KDE4_EXPORT_LIBRARY_DEPENDENCIES _append_or_write _filename)
# Alex
file(${_append_or_write} "${_filename}" "# The following variables have been created by kde4_export_library_dependencies()
-# The contents have been determined from the LINK_INTERFACE_LIBRARIES target property of the respective libraries.
-# The option KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT has been enabled to create the file this way.
-# You can modify KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT using \"make edit_cache\"\n\n")
+# The contents have been determined from the LINK_INTERFACE_LIBRARIES target property of the respective libraries.\n\n")
get_cmake_property(allVars VARIABLES)
set(allLibs "")
foreach(currentVar ${allVars})
@@ -1113,9 +1138,30 @@ macro(_KDE4_EXPORT_LIBRARY_DEPENDENCIES _append_or_write _filename)
endif(NOT "${target}" STREQUAL "${currentVar}")
endforeach(currentVar ${allVars})
- endif(KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT AND UNIX)# AND NOT APPLE)
+# endif(KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT AND UNIX)# AND NOT APPLE)
endmacro(_KDE4_EXPORT_LIBRARY_DEPENDENCIES)
+# In cmake 2.6.2 a new keyword "LINK_INTERFACE_LIBRARIES is added to TARGET_LINK_LIBRARIES().
+# We will use this to reduce the link interface of libraries. As opposed to setting the
+# respective target property, here the "debug" and "optimized" keywords are supported
+# (this is actually the reason why we will use this).
+# The problem is, once we add this call to our cmake files, cmake 2.6.0 and 2.6.1 would not
+# work anymore, since they would fail when trying to link against -lLINK_INTERFACE_LIBRARIES
+# That's for cmake 2.6.0 and 2.6.1 we redefine TARGET_LINK_LIBRARIES() here.
+# If the first argument after the target name if "LINK_INTERFACE_LIBRARIES", then
+# nothing is done, otherwise the original TARGET_LINK_LIBRARIES() is called.
+# This can be done by calling _target_link_libraries(), since if a command is
+# "overloaded" by a macro, the original command gets a "_" prepended, so it
+# is still available.
+if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" MATCHES "^2\\.6\\.[01]$")
+ macro(TARGET_LINK_LIBRARIES)
+ if(NOT "${ARGV1}" STREQUAL "LINK_INTERFACE_LIBRARIES")
+ _target_link_libraries(${ARGN})
+ endif()
+ endmacro(TARGET_LINK_LIBRARIES)
+endif("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" MATCHES "^2\\.6\\.[01]$")
+
+
macro (_KDE4_TARGET_LINK_INTERFACE_LIBRARIES _target _interface_libs)
message(FATAL_ERROR "_KDE4_TARGET_LINK_INTERFACE_LIBRARIES() doesn't exist anymore. Set the LINK_INTERFACE_LIBRARIES target property instead. See kdelibs/kdecore/CMakeLists.txt for an example.")
endmacro (_KDE4_TARGET_LINK_INTERFACE_LIBRARIES)