From e679996e1a351e33d29c532e7871f47d59a3a0e3 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Sat, 10 May 2008 21:48:49 +0000 Subject: -use automoc4 from kdesupport if available, otherwise fallback to the one from kdelibs. In a few weeks automoc4 from kdesupport will be required. Alex CCMAIL: kretz@kde.org svn path=/trunk/KDE/kdelibs/; revision=806300 --- modules/FindAutomoc4.cmake | 52 ++++++++++++++ modules/FindKDE4Internal.cmake | 37 ++++++++-- modules/KDE4Macros.cmake | 150 ++++++++++++++++++++++------------------- 3 files changed, 165 insertions(+), 74 deletions(-) create mode 100644 modules/FindAutomoc4.cmake (limited to 'modules') diff --git a/modules/FindAutomoc4.cmake b/modules/FindAutomoc4.cmake new file mode 100644 index 00000000..03a90974 --- /dev/null +++ b/modules/FindAutomoc4.cmake @@ -0,0 +1,52 @@ +# - Try to find automoc4 +# Once done this will define +# +# AUTOMOC4_FOUND - automoc4 has been found +# AUTOMOC4_EXECUTABLE - the automoc4 tool +# +# It also adds the following macros +# AUTOMOC4( ) +# Use this to run automoc4 on all files contained in the list . +# +# AUTOMOC4_MOC_HEADERS( header1.h header2.h) +# Use this to add more header files to be processed with automoc4. + + +# Copyright (c) 2008, Alexander Neundorf, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +# check if we are inside KDESupport and automoc is enabled +if("${KDESupport_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") + # when building this project as part of kdesupport + set(AUTOMOC4_CONFIG_FILE "${KDESupport_SOURCE_DIR}/automoc/Automoc4Config.cmake") +else("${KDESupport_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") + # when building this project outside kdesupport + find_file(AUTOMOC4_CONFIG_FILE NAMES Automoc4Config.cmake + PATH_SUFFIXES automoc4 lib/automoc4 lib64/automoc4 + PATHS ${CMAKE_SYSTEM_PREFIX_PATH} ${CMAKE_SYSTEM_LIBRARY_PATH} ${CMAKE_INSTALL_PREFIX}/lib + NO_DEFAULT_PATH ) +endif("${KDESupport_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") + + +if(AUTOMOC4_CONFIG_FILE) + include(${AUTOMOC4_CONFIG_FILE}) + set(AUTOMOC4_FOUND TRUE) +else(AUTOMOC4_CONFIG_FILE) + set(AUTOMOC4_FOUND FALSE) +endif(AUTOMOC4_CONFIG_FILE) + +if (AUTOMOC4_FOUND) + if (NOT Automoc4_FIND_QUIETLY) + message(STATUS "Found Automoc4: ${AUTOMOC4_EXECUTABLE}") + endif (NOT Automoc4_FIND_QUIETLY) +else (AUTOMOC4_FOUND) + if (Automoc4_FIND_REQUIRED) + message(FATAL_ERROR "Did not find automoc4 (part of kdesupport).") + else (Automoc4_FIND_REQUIRED) + if (NOT Automoc4_FIND_QUIETLY) + message(STATUS "Did not find automoc4 (part of kdesupport).") + endif (NOT Automoc4_FIND_QUIETLY) + endif (Automoc4_FIND_REQUIRED) +endif (AUTOMOC4_FOUND) diff --git a/modules/FindKDE4Internal.cmake b/modules/FindKDE4Internal.cmake index 6e8bad88..cee539c3 100644 --- a/modules/FindKDE4Internal.cmake +++ b/modules/FindKDE4Internal.cmake @@ -228,6 +228,10 @@ set(QT_MIN_VERSION "4.4.0") #this line includes FindQt4.cmake, which searches the Qt library and headers find_package(Qt4 REQUIRED) +# automoc4 (from kdesupport) is not yet required, but will be in June +# until then still automoc from kdelibs is used as fallback, Alex +find_package(Automoc4) + # Perl is required for building KDE software, find_package(Perl REQUIRED) @@ -275,13 +279,27 @@ if (_kdeBootStrapping) set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH} ) # CMAKE_CFG_INTDIR is the output subdirectory created e.g. by XCode and MSVC set(KDE4_KCFGC_EXECUTABLE ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/kconfig_compiler ) - set(KDE4_AUTOMOC_EXECUTABLE ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/kde4automoc ) + + # use automoc4 from kdesupport if it has been found + if(AUTOMOC4_EXECUTABLE) + set(KDE4_AUTOMOC_EXECUTABLE "${AUTOMOC4_EXECUTABLE}" ) + else(AUTOMOC4_EXECUTABLE) + set(KDE4_AUTOMOC_EXECUTABLE ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/kde4automoc ) + endif(AUTOMOC4_EXECUTABLE) + set(KDE4_MEINPROC_EXECUTABLE ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/meinproc4 ) set(KDE4_MAKEKDEWIDGETS_EXECUTABLE ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/makekdewidgets ) else (WIN32) set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib ) set(KDE4_KCFGC_EXECUTABLE ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/kconfig_compiler.shell ) - set(KDE4_AUTOMOC_EXECUTABLE ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/kde4automoc.shell ) + + # use automoc4 from kdesupport if it has been found + if(AUTOMOC4_EXECUTABLE) + set(KDE4_AUTOMOC_EXECUTABLE "${AUTOMOC4_EXECUTABLE}" ) + else(AUTOMOC4_EXECUTABLE) + set(KDE4_AUTOMOC_EXECUTABLE ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/kde4automoc.shell ) + endif(AUTOMOC4_EXECUTABLE) + set(KDE4_MEINPROC_EXECUTABLE ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/meinproc4.shell ) set(KDE4_MAKEKDEWIDGETS_EXECUTABLE ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/makekdewidgets.shell ) endif (WIN32) @@ -290,10 +308,15 @@ if (_kdeBootStrapping) # when building kdelibs, make the kcfg rules depend on the binaries... set( _KDE4_KCONFIG_COMPILER_DEP kconfig_compiler) - set( _KDE4_AUTOMOC_EXECUTABLE_DEP kde4automoc) set( _KDE4_MAKEKDEWIDGETS_DEP makekdewidgets) set( _KDE4_MEINPROC_EXECUTABLE_DEP meinproc4) + if(AUTOMOC4_EXECUTABLE) + set( _KDE4_AUTOMOC_EXECUTABLE_DEP) + else(AUTOMOC4_EXECUTABLE) + set( _KDE4_AUTOMOC_EXECUTABLE_DEP kde4automoc) + endif(AUTOMOC4_EXECUTABLE) + set(KDE4_INSTALLED_VERSION_OK TRUE) else (_kdeBootStrapping) @@ -431,8 +454,12 @@ else (_kdeBootStrapping) find_program(KDE4_KCFGC_EXECUTABLE NAME kconfig_compiler PATHS ${KDE4_BIN_INSTALL_DIR} NO_DEFAULT_PATH ) find_program(KDE4_KCFGC_EXECUTABLE NAME kconfig_compiler ) - find_program(KDE4_AUTOMOC_EXECUTABLE NAME kde4automoc PATHS ${KDE4_BIN_INSTALL_DIR} NO_DEFAULT_PATH ) - find_program(KDE4_AUTOMOC_EXECUTABLE NAME kde4automoc ) + if (AUTOMOC4_EXECUTABLE) + set(KDE4_AUTOMOC_EXECUTABLE "${AUTOMOC4_EXECUTABLE}") + else (AUTOMOC4_EXECUTABLE) + find_program(KDE4_AUTOMOC_EXECUTABLE NAME kde4automoc PATHS ${KDE4_BIN_INSTALL_DIR} NO_DEFAULT_PATH ) + find_program(KDE4_AUTOMOC_EXECUTABLE NAME kde4automoc ) + endif (AUTOMOC4_EXECUTABLE) find_program(KDE4_MEINPROC_EXECUTABLE NAME meinproc4 PATHS ${KDE4_BIN_INSTALL_DIR} NO_DEFAULT_PATH ) find_program(KDE4_MEINPROC_EXECUTABLE NAME meinproc4 ) diff --git a/modules/KDE4Macros.cmake b/modules/KDE4Macros.cmake index f193010d..f5658620 100644 --- a/modules/KDE4Macros.cmake +++ b/modules/KDE4Macros.cmake @@ -161,78 +161,90 @@ endmacro (_KDE4_GET_CUSTOM_TARGET_PROPERTY) macro (KDE4_MOC_HEADERS _target_NAME) - set (_headers_to_moc) - foreach (_current_FILE ${ARGN}) - get_filename_component(_suffix "${_current_FILE}" EXT) - if (".h" STREQUAL "${_suffix}" OR ".hpp" STREQUAL "${_suffix}" OR ".hxx" STREQUAL "${_suffix}" OR ".H" STREQUAL "${_suffix}") - list(APPEND _headers_to_moc ${_current_FILE}) - else (".h" STREQUAL "${_suffix}" OR ".hpp" STREQUAL "${_suffix}" OR ".hxx" STREQUAL "${_suffix}" OR ".H" STREQUAL "${_suffix}") - message(STATUS "KDE4_MOC_HEADERS: ignoring non-header file ${_current_FILE}") - endif (".h" STREQUAL "${_suffix}" OR ".hpp" STREQUAL "${_suffix}" OR ".hxx" STREQUAL "${_suffix}" OR ".H" STREQUAL "${_suffix}") - endforeach (_current_FILE) - # need to create moc_.cpp file using kde4automoc.cmake - # and add it to the target - if(_headers_to_moc) - _kde4_set_custom_target_property(${_target_NAME} AUTOMOC_HEADERS "${_headers_to_moc}") - endif(_headers_to_moc) + # if automoc4 from kdesupport has been found, use the macro provided there, + # otherwise fall back to the kdelibs one + if (AUTOMOC4_EXECUTABLE) + AUTOMOC4_MOC_HEADERS(${_target_NAME} ${ARGN}) + else (AUTOMOC4_EXECUTABLE) + set (_headers_to_moc) + foreach (_current_FILE ${ARGN}) + get_filename_component(_suffix "${_current_FILE}" EXT) + if (".h" STREQUAL "${_suffix}" OR ".hpp" STREQUAL "${_suffix}" OR ".hxx" STREQUAL "${_suffix}" OR ".H" STREQUAL "${_suffix}") + list(APPEND _headers_to_moc ${_current_FILE}) + else (".h" STREQUAL "${_suffix}" OR ".hpp" STREQUAL "${_suffix}" OR ".hxx" STREQUAL "${_suffix}" OR ".H" STREQUAL "${_suffix}") + message(STATUS "KDE4_MOC_HEADERS: ignoring non-header file ${_current_FILE}") + endif (".h" STREQUAL "${_suffix}" OR ".hpp" STREQUAL "${_suffix}" OR ".hxx" STREQUAL "${_suffix}" OR ".H" STREQUAL "${_suffix}") + endforeach (_current_FILE) + # need to create moc_.cpp file using kde4automoc.cmake + # and add it to the target + if(_headers_to_moc) + _kde4_set_custom_target_property(${_target_NAME} AUTOMOC_HEADERS "${_headers_to_moc}") + endif(_headers_to_moc) + endif (AUTOMOC4_EXECUTABLE) endmacro (KDE4_MOC_HEADERS) macro(KDE4_HANDLE_AUTOMOC _target_NAME _SRCS) - set(_moc_files) - set(_moc_headers) - - # first list all explicitly set headers - _kde4_get_custom_target_property(_headers_to_moc ${_target_NAME} AUTOMOC_HEADERS) - if(NOT _headers_to_moc STREQUAL "NOTFOUND") - foreach(_header_to_moc ${_headers_to_moc}) - get_filename_component(_abs_header ${_header_to_moc} ABSOLUTE) - list(APPEND _moc_files ${_abs_header}) - list(APPEND _moc_headers ${_abs_header}) - endforeach(_header_to_moc) - endif(NOT _headers_to_moc STREQUAL "NOTFOUND") - - # now add all the sources for the automoc - foreach (_current_FILE ${${_SRCS}}) - get_filename_component(_abs_current_FILE "${_current_FILE}" ABSOLUTE) - get_source_file_property(_skip "${_abs_current_FILE}" SKIP_AUTOMOC) - get_source_file_property(_generated "${_abs_current_FILE}" GENERATED) - - if(NOT _generated AND NOT _skip) - get_filename_component(_suffix "${_current_FILE}" EXT) - # skip every source file that's not C++ - if(_suffix STREQUAL ".cpp" OR _suffix STREQUAL ".cc" OR _suffix STREQUAL ".cxx" OR _suffix STREQUAL ".C") - get_filename_component(_basename "${_current_FILE}" NAME_WE) - get_filename_component(_abs_path "${_abs_current_FILE}" PATH) - set(_header "${_abs_path}/${_basename}.h") - if(EXISTS "${_header}") - list(APPEND _moc_headers ${_header}) - endif(EXISTS "${_header}") - set(_pheader "${_abs_path}/${_basename}_p.h") - if(EXISTS "${_pheader}") - list(APPEND _moc_headers ${_pheader}) - endif(EXISTS "${_pheader}") - list(APPEND _moc_files ${_abs_current_FILE}) - endif(_suffix STREQUAL ".cpp" OR _suffix STREQUAL ".cc" OR _suffix STREQUAL ".cxx" OR _suffix STREQUAL ".C") - endif(NOT _generated AND NOT _skip) - endforeach (_current_FILE) - - if(_moc_files) - set(_automoc_source "${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_automoc.cpp") - get_directory_property(_moc_incs INCLUDE_DIRECTORIES) - configure_file(${KDE4_MODULE_DIR}/kde4automoc.files.in ${_automoc_source}.files) - add_custom_command(OUTPUT ${_automoc_source} - COMMAND ${KDE4_AUTOMOC_EXECUTABLE} - ${_automoc_source} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${QT_MOC_EXECUTABLE} - DEPENDS ${${_SRCS}} ${_moc_headers} ${_automoc_source}.files ${_KDE4_AUTOMOC_EXECUTABLE_DEP} - ) - # the OBJECT_DEPENDS is only necessary when a new moc file has to be generated that is included in a source file - # problem: the whole target is recompiled when the automoc.cpp file is touched - # set_source_files_properties(${${_SRCS}} PROPERTIES OBJECT_DEPENDS ${_automoc_source}) - set(${_SRCS} ${_automoc_source} ${${_SRCS}}) - endif(_moc_files) + # if automoc4 from kdesupport has been found, use the macro provided there, + # otherwise fall back to the kdelibs one + if (AUTOMOC4_EXECUTABLE) + AUTOMOC4(${_target_NAME} ${_SRCS}) + else (AUTOMOC4_EXECUTABLE) + set(_moc_files) + set(_moc_headers) + + # first list all explicitly set headers + _kde4_get_custom_target_property(_headers_to_moc ${_target_NAME} AUTOMOC_HEADERS) + if(NOT _headers_to_moc STREQUAL "NOTFOUND") + foreach(_header_to_moc ${_headers_to_moc}) + get_filename_component(_abs_header ${_header_to_moc} ABSOLUTE) + list(APPEND _moc_files ${_abs_header}) + list(APPEND _moc_headers ${_abs_header}) + endforeach(_header_to_moc) + endif(NOT _headers_to_moc STREQUAL "NOTFOUND") + + # now add all the sources for the automoc + foreach (_current_FILE ${${_SRCS}}) + get_filename_component(_abs_current_FILE "${_current_FILE}" ABSOLUTE) + get_source_file_property(_skip "${_abs_current_FILE}" SKIP_AUTOMOC) + get_source_file_property(_generated "${_abs_current_FILE}" GENERATED) + + if(NOT _generated AND NOT _skip) + get_filename_component(_suffix "${_current_FILE}" EXT) + # skip every source file that's not C++ + if(_suffix STREQUAL ".cpp" OR _suffix STREQUAL ".cc" OR _suffix STREQUAL ".cxx" OR _suffix STREQUAL ".C") + get_filename_component(_basename "${_current_FILE}" NAME_WE) + get_filename_component(_abs_path "${_abs_current_FILE}" PATH) + set(_header "${_abs_path}/${_basename}.h") + if(EXISTS "${_header}") + list(APPEND _moc_headers ${_header}) + endif(EXISTS "${_header}") + set(_pheader "${_abs_path}/${_basename}_p.h") + if(EXISTS "${_pheader}") + list(APPEND _moc_headers ${_pheader}) + endif(EXISTS "${_pheader}") + list(APPEND _moc_files ${_abs_current_FILE}) + endif(_suffix STREQUAL ".cpp" OR _suffix STREQUAL ".cc" OR _suffix STREQUAL ".cxx" OR _suffix STREQUAL ".C") + endif(NOT _generated AND NOT _skip) + endforeach (_current_FILE) + + if(_moc_files) + set(_automoc_source "${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_automoc.cpp") + get_directory_property(_moc_incs INCLUDE_DIRECTORIES) + configure_file(${KDE4_MODULE_DIR}/kde4automoc.files.in ${_automoc_source}.files) + add_custom_command(OUTPUT ${_automoc_source} + COMMAND ${KDE4_AUTOMOC_EXECUTABLE} + ${_automoc_source} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${QT_MOC_EXECUTABLE} + DEPENDS ${${_SRCS}} ${_moc_headers} ${_automoc_source}.files ${_KDE4_AUTOMOC_EXECUTABLE_DEP} + ) + # the OBJECT_DEPENDS is only necessary when a new moc file has to be generated that is included in a source file + # problem: the whole target is recompiled when the automoc.cpp file is touched + # set_source_files_properties(${${_SRCS}} PROPERTIES OBJECT_DEPENDS ${_automoc_source}) + set(${_SRCS} ${_automoc_source} ${${_SRCS}}) + endif(_moc_files) + endif (AUTOMOC4_EXECUTABLE) endmacro(KDE4_HANDLE_AUTOMOC) macro(KDE4_INSTALL_TS_FILES _lang _sdir) -- cgit v1.2.1