Warning, /frameworks/kdelibs4support/cmake/modules/ECMQt4To5Porting.cmake is written in an unsupported language. File is not indexed.
0001 #============================================================================= 0002 # Copyright 2005-2011 Kitware, Inc. 0003 # All rights reserved. 0004 # 0005 # Redistribution and use in source and binary forms, with or without 0006 # modification, are permitted provided that the following conditions 0007 # are met: 0008 # 0009 # * Redistributions of source code must retain the above copyright 0010 # notice, this list of conditions and the following disclaimer. 0011 # 0012 # * Redistributions in binary form must reproduce the above copyright 0013 # notice, this list of conditions and the following disclaimer in the 0014 # documentation and/or other materials provided with the distribution. 0015 # 0016 # * Neither the name of Kitware, Inc. nor the names of its 0017 # contributors may be used to endorse or promote products derived 0018 # from this software without specific prior written permission. 0019 # 0020 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0021 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0022 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0023 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0024 # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0025 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0026 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0027 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0028 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0029 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0030 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0031 #============================================================================= 0032 0033 # The automoc_qt4 macro is superceded by CMAKE_AUTOMOC from CMake 2.8.6 0034 # A Qt 5 version is not provided by CMake or Qt. 0035 0036 include(MacroAddFileDependencies) 0037 0038 MACRO (QT4_GET_MOC_FLAGS _moc_flags) 0039 SET(${_moc_flags}) 0040 GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES) 0041 0042 FOREACH(_current ${_inc_DIRS}) 0043 IF("${_current}" MATCHES "\\.framework/?$") 0044 STRING(REGEX REPLACE "/[^/]+\\.framework" "" framework_path "${_current}") 0045 SET(${_moc_flags} ${${_moc_flags}} "-F${framework_path}") 0046 ELSE("${_current}" MATCHES "\\.framework/?$") 0047 SET(${_moc_flags} ${${_moc_flags}} "-I${_current}") 0048 ENDIF("${_current}" MATCHES "\\.framework/?$") 0049 ENDFOREACH(_current ${_inc_DIRS}) 0050 0051 GET_DIRECTORY_PROPERTY(_defines COMPILE_DEFINITIONS) 0052 FOREACH(_current ${_defines}) 0053 SET(${_moc_flags} ${${_moc_flags}} "-D${_current}") 0054 ENDFOREACH(_current ${_defines}) 0055 0056 IF(Q_WS_WIN) 0057 SET(${_moc_flags} ${${_moc_flags}} -DWIN32) 0058 ENDIF(Q_WS_WIN) 0059 0060 ENDMACRO(QT4_GET_MOC_FLAGS) 0061 0062 # helper macro to set up a moc rule 0063 MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options) 0064 # For Windows, create a parameters file to work around command line length limit 0065 IF (WIN32) 0066 # Pass the parameters in a file. Set the working directory to 0067 # be that containing the parameters file and reference it by 0068 # just the file name. This is necessary because the moc tool on 0069 # MinGW builds does not seem to handle spaces in the path to the 0070 # file given with the @ syntax. 0071 GET_FILENAME_COMPONENT(_moc_outfile_name "${outfile}" NAME) 0072 GET_FILENAME_COMPONENT(_moc_outfile_dir "${outfile}" PATH) 0073 IF(_moc_outfile_dir) 0074 SET(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir}) 0075 ENDIF(_moc_outfile_dir) 0076 SET (_moc_parameters_file ${outfile}_parameters) 0077 SET (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}") 0078 STRING (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}") 0079 FILE (WRITE ${_moc_parameters_file} "${_moc_parameters}") 0080 ADD_CUSTOM_COMMAND(OUTPUT ${outfile} 0081 COMMAND ${QT_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters 0082 DEPENDS ${infile} 0083 ${_moc_working_dir} 0084 VERBATIM) 0085 ELSE (WIN32) 0086 ADD_CUSTOM_COMMAND(OUTPUT ${outfile} 0087 COMMAND ${QT_MOC_EXECUTABLE} 0088 ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile} 0089 DEPENDS ${infile} VERBATIM) 0090 ENDIF (WIN32) 0091 ENDMACRO (QT4_CREATE_MOC_COMMAND) 0092 0093 0094 MACRO(QT4_AUTOMOC) 0095 QT4_GET_MOC_FLAGS(_moc_INCS) 0096 0097 SET(_matching_FILES ) 0098 FOREACH (_current_FILE ${ARGN}) 0099 0100 GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE) 0101 # if "SKIP_AUTOMOC" is set to true, we will not handle this file here. 0102 # This is required to make uic work correctly: 0103 # we need to add generated .cpp files to the sources (to compile them), 0104 # but we cannot let automoc handle them, as the .cpp files don't exist yet when 0105 # cmake is run for the very first time on them -> however the .cpp files might 0106 # exist at a later run. at that time we need to skip them, so that we don't add two 0107 # different rules for the same moc file 0108 GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC) 0109 0110 IF ( NOT _skip AND EXISTS ${_abs_FILE} ) 0111 0112 FILE(READ ${_abs_FILE} _contents) 0113 0114 GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH) 0115 0116 STRING(REGEX MATCHALL "# *include +[^ ]+\\.moc[\">]" _match "${_contents}") 0117 IF(_match) 0118 FOREACH (_current_MOC_INC ${_match}) 0119 STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}") 0120 0121 GET_FILENAME_COMPONENT(_basename ${_current_MOC} NAME_WE) 0122 IF(EXISTS ${_abs_PATH}/${_basename}.hpp) 0123 SET(_header ${_abs_PATH}/${_basename}.hpp) 0124 ELSE(EXISTS ${_abs_PATH}/${_basename}.hpp) 0125 SET(_header ${_abs_PATH}/${_basename}.h) 0126 ENDIF(EXISTS ${_abs_PATH}/${_basename}.hpp) 0127 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC}) 0128 QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${_moc_INCS}" "") 0129 MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc}) 0130 ENDFOREACH (_current_MOC_INC) 0131 ENDIF(_match) 0132 ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} ) 0133 ENDFOREACH (_current_FILE) 0134 ENDMACRO(QT4_AUTOMOC) 0135 0136 0137 # Portability helpers. 0138 0139 set(QT_QTGUI_LIBRARIES 0140 ${Qt5Gui_LIBRARIES} 0141 ${Qt5Widgets_LIBRARIES} 0142 ${Qt5PrintSupport_LIBRARIES} 0143 ${Qt5Svg_LIBRARIES} 0144 ) 0145 0146 set(QT_INCLUDES 0147 ${Qt5Gui_INCLUDE_DIRS} 0148 ${Qt5Widgets_INCLUDE_DIRS} 0149 ${Qt5PrintSupport_INCLUDE_DIRS} 0150 ${Qt5Svg_INCLUDE_DIRS} 0151 ) 0152 set(QT_QTGUI_LIBRARY ${QT_QTGUI_LIBRARIES}) 0153 0154 set(_qt_modules 0155 Core 0156 Declarative 0157 Widgets 0158 Script 0159 ScriptTools 0160 DBus 0161 Network 0162 Test 0163 Designer 0164 Concurrent 0165 Xml 0166 UiTools 0167 Qml 0168 Quick 0169 WebKit 0170 WebKitWidgets 0171 Sql 0172 OpenGL 0173 ) 0174 0175 foreach(_module ${_qt_modules}) 0176 string(TOUPPER ${_module} _module_upper) 0177 set(QT_QT${_module_upper}_LIBRARIES ${Qt5${_module}_LIBRARIES}) 0178 set(QT_QT${_module_upper}_LIBRARY ${QT_QT${_module_upper}_LIBRARIES}) 0179 list(APPEND QT_INCLUDES ${Qt5${_module}_INCLUDE_DIRS}) 0180 set(QT_QT${_module_upper}_FOUND ${Qt5${_module}_FOUND}) 0181 endforeach() 0182 0183 list(APPEND QT_QTCORE_LIBRARIES ${Qt5Concurrent_LIBRARIES}) 0184 list(APPEND QT_QTCORE_LIBRARY ${Qt5Concurrent_LIBRARIES}) 0185 0186 list(APPEND QT_QTWEBKIT_LIBRARIES ${Qt5WebKitWidgets_LIBRARIES}) 0187 list(APPEND QT_QTWEBKIT_LIBRARY ${Qt5WebKitWidgets_LIBRARIES}) 0188 0189 get_target_property(QT_QMAKE_EXECUTABLE Qt5::qmake LOCATION) 0190 get_target_property(QT_RCC_EXECUTABLE Qt5::rcc LOCATION) 0191 if (TARGET Qt5::uic) 0192 get_target_property(QT_UIC_EXECUTABLE Qt5::uic LOCATION) 0193 endif() 0194 0195 if (TARGET Qt5::qdbuscpp2xml) 0196 get_target_property(QT_QDBUSCPP2XML_EXECUTABLE Qt5::qdbuscpp2xml LOCATION) 0197 endif() 0198 0199 if (TARGET Qt5::qdbusxml2cpp) 0200 get_target_property(QT_QDBUSXML2CPP_EXECUTABLE Qt5::qdbusxml2cpp LOCATION) 0201 endif() 0202 0203 add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0) 0204 0205 macro(qt4_wrap_ui) 0206 qt5_wrap_ui(${ARGN}) 0207 endmacro() 0208 0209 macro(qt4_wrap_cpp) 0210 qt5_wrap_cpp(${ARGN}) 0211 endmacro() 0212 0213 macro(qt4_generate_moc) 0214 qt5_generate_moc(${ARGN}) 0215 endmacro() 0216 0217 macro(qt4_add_dbus_adaptor) 0218 qt5_add_dbus_adaptor(${ARGN}) 0219 endmacro() 0220 0221 macro(qt4_add_dbus_interfaces) 0222 qt5_add_dbus_interfaces(${ARGN}) 0223 endmacro() 0224 0225 macro(qt4_add_dbus_interface) 0226 qt5_add_dbus_interface(${ARGN}) 0227 endmacro() 0228 0229 macro(qt4_generate_dbus_interface) 0230 qt5_generate_dbus_interface(${ARGN}) 0231 endmacro() 0232 0233 macro(qt4_add_resources) 0234 qt5_add_resources(${ARGN}) 0235 endmacro()