summaryrefslogtreecommitdiff
path: root/Modules/Qt4Macros.cmake
diff options
context:
space:
mode:
authorKévin THIERRY <kevin.thierry@open.eurogiciel.org>2014-12-23 09:30:24 +0100
committerKévin THIERRY <kevin.thierry@open.eurogiciel.org>2014-12-23 09:30:24 +0100
commit317dbdb79761ef65e45c7358cfc7571c6afa54ad (patch)
treed6e8d59029aea04ca4a0579fb1c19c3e493af78f /Modules/Qt4Macros.cmake
parent297c63fa65327491a2b50e521b661c5835a19fe4 (diff)
downloadcmake-317dbdb79761ef65e45c7358cfc7571c6afa54ad.tar.gz
cmake-317dbdb79761ef65e45c7358cfc7571c6afa54ad.tar.bz2
cmake-317dbdb79761ef65e45c7358cfc7571c6afa54ad.zip
Imported Upstream version 2.8.12.2upstream/2.8.12.2sandbox/kevinthierry/upstream
Diffstat (limited to 'Modules/Qt4Macros.cmake')
-rw-r--r--Modules/Qt4Macros.cmake119
1 files changed, 81 insertions, 38 deletions
diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake
index f6c8476a5..f1aedd743 100644
--- a/Modules/Qt4Macros.cmake
+++ b/Modules/Qt4Macros.cmake
@@ -21,15 +21,20 @@
######################################
-macro (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
+macro (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options _qt4_target)
set(${_qt4_files})
set(${_qt4_options})
set(_QT4_DOING_OPTIONS FALSE)
+ set(_QT4_DOING_TARGET FALSE)
foreach(_currentArg ${ARGN})
- if ("${_currentArg}" STREQUAL "OPTIONS")
+ if ("x${_currentArg}" STREQUAL "xOPTIONS")
set(_QT4_DOING_OPTIONS TRUE)
+ elseif ("x${_currentArg}" STREQUAL "xTARGET")
+ set(_QT4_DOING_TARGET TRUE)
else ()
- if(_QT4_DOING_OPTIONS)
+ if(_QT4_DOING_TARGET)
+ set(${_qt4_target} "${_currentArg}")
+ elseif(_QT4_DOING_OPTIONS)
list(APPEND ${_qt4_options} "${_currentArg}")
else()
list(APPEND ${_qt4_files} "${_currentArg}")
@@ -92,34 +97,46 @@ endmacro()
# helper macro to set up a moc rule
-macro (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options)
+macro (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target)
# For Windows, create a parameters file to work around command line length limit
- if (WIN32)
- # Pass the parameters in a file. Set the working directory to
- # be that containing the parameters file and reference it by
- # just the file name. This is necessary because the moc tool on
- # MinGW builds does not seem to handle spaces in the path to the
- # file given with the @ syntax.
- get_filename_component(_moc_outfile_name "${outfile}" NAME)
- get_filename_component(_moc_outfile_dir "${outfile}" PATH)
- if(_moc_outfile_dir)
- set(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
- endif()
- set (_moc_parameters_file ${outfile}_parameters)
- set (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}")
- string (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}")
- file (WRITE ${_moc_parameters_file} "${_moc_parameters}")
- add_custom_command(OUTPUT ${outfile}
- COMMAND ${QT_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters
- DEPENDS ${infile}
- ${_moc_working_dir}
- VERBATIM)
- else ()
- add_custom_command(OUTPUT ${outfile}
- COMMAND ${QT_MOC_EXECUTABLE}
- ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile}
- DEPENDS ${infile} VERBATIM)
- endif ()
+ # Pass the parameters in a file. Set the working directory to
+ # be that containing the parameters file and reference it by
+ # just the file name. This is necessary because the moc tool on
+ # MinGW builds does not seem to handle spaces in the path to the
+ # file given with the @ syntax.
+ get_filename_component(_moc_outfile_name "${outfile}" NAME)
+ get_filename_component(_moc_outfile_dir "${outfile}" PATH)
+ if(_moc_outfile_dir)
+ set(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
+ endif()
+ set (_moc_parameters_file ${outfile}_parameters)
+ set (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}")
+ string (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}")
+
+ if(moc_target)
+ set(targetincludes "$<TARGET_PROPERTY:${moc_target},INCLUDE_DIRECTORIES>")
+ set(targetdefines "$<TARGET_PROPERTY:${moc_target},COMPILE_DEFINITIONS>")
+
+ set(targetincludes "$<$<BOOL:${targetincludes}>:-I$<JOIN:${targetincludes},\n-I>\n>")
+ set(targetdefines "$<$<BOOL:${targetdefines}>:-D$<JOIN:${targetdefines},\n-D>\n>")
+
+ file (GENERATE
+ OUTPUT ${_moc_parameters_file}
+ CONTENT "${targetdefines}${targetincludes}${_moc_parameters}\n"
+ )
+
+ set(targetincludes)
+ set(targetdefines)
+ else()
+ file(WRITE ${_moc_parameters_file} "${_moc_parameters}\n")
+ endif()
+
+ set(_moc_extra_parameters_file @${_moc_parameters_file})
+ add_custom_command(OUTPUT ${outfile}
+ COMMAND ${QT_MOC_EXECUTABLE} ${_moc_extra_parameters_file}
+ DEPENDS ${infile}
+ ${_moc_working_dir}
+ VERBATIM)
endmacro ()
@@ -131,7 +148,11 @@ macro (QT4_GENERATE_MOC infile outfile )
if(NOT IS_ABSOLUTE "${outfile}")
set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
endif()
- QT4_CREATE_MOC_COMMAND(${abs_infile} ${_outfile} "${moc_flags}" "")
+
+ if ("x${ARGV2}" STREQUAL "xTARGET")
+ set(moc_target ${ARGV3})
+ endif()
+ QT4_CREATE_MOC_COMMAND(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}")
set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file
endmacro ()
@@ -141,12 +162,12 @@ endmacro ()
macro (QT4_WRAP_CPP outfiles )
# get include dirs
QT4_GET_MOC_FLAGS(moc_flags)
- QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
+ QT4_EXTRACT_OPTIONS(moc_files moc_options moc_target ${ARGN})
foreach (it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
QT4_MAKE_OUTPUT_FILE(${it} moc_ cxx outfile)
- QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_flags}" "${moc_options}")
+ QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}")
set(${outfiles} ${${outfiles}} ${outfile})
endforeach()
@@ -156,7 +177,7 @@ endmacro ()
# QT4_WRAP_UI(outfiles inputfile ... )
macro (QT4_WRAP_UI outfiles )
- QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
+ QT4_EXTRACT_OPTIONS(ui_files ui_options ui_target ${ARGN})
foreach (it ${ui_files})
get_filename_component(outfile ${it} NAME_WE)
@@ -175,7 +196,7 @@ endmacro ()
# QT4_ADD_RESOURCES(outfiles inputfile ... )
macro (QT4_ADD_RESOURCES outfiles )
- QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN})
+ QT4_EXTRACT_OPTIONS(rcc_files rcc_options rcc_target ${ARGN})
foreach (it ${rcc_files})
get_filename_component(outfilename ${it} NAME_WE)
@@ -270,7 +291,7 @@ endmacro()
macro(QT4_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options )
- QT4_EXTRACT_OPTIONS(_customName _qt4_dbus_options ${ARGN})
+ QT4_EXTRACT_OPTIONS(_customName _qt4_dbus_options _qt4_dbus_target ${ARGN})
get_filename_component(_in_file ${_header} ABSOLUTE)
get_filename_component(_basename ${_header} NAME_WE)
@@ -333,6 +354,17 @@ endmacro()
macro(QT4_AUTOMOC)
+ if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.11)
+ if(CMAKE_WARN_DEPRECATED)
+ set(messageType WARNING)
+ endif()
+ if(CMAKE_ERROR_DEPRECATED)
+ set(messageType FATAL_ERROR)
+ endif()
+ if(messageType)
+ message(${messageType} "The qt4_automoc macro is obsolete. Use the CMAKE_AUTOMOC feature instead.")
+ endif()
+ endif()
QT4_GET_MOC_FLAGS(_moc_INCS)
set(_matching_FILES )
@@ -366,7 +398,7 @@ macro(QT4_AUTOMOC)
set(_header ${_abs_PATH}/${_basename}.h)
endif()
set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
- QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${_moc_INCS}" "")
+ QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${_moc_INCS}" "" "")
MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
endforeach ()
endif()
@@ -376,7 +408,7 @@ endmacro()
macro(QT4_CREATE_TRANSLATION _qm_files)
- QT4_EXTRACT_OPTIONS(_lupdate_files _lupdate_options ${ARGN})
+ QT4_EXTRACT_OPTIONS(_lupdate_files _lupdate_options _lupdate_target ${ARGN})
set(_my_sources)
set(_my_dirs)
set(_my_tsfiles)
@@ -443,6 +475,17 @@ macro(QT4_ADD_TRANSLATION _qm_files)
endmacro()
function(qt4_use_modules _target _link_type)
+ if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.11)
+ if(CMAKE_WARN_DEPRECATED)
+ set(messageType WARNING)
+ endif()
+ if(CMAKE_ERROR_DEPRECATED)
+ set(messageType FATAL_ERROR)
+ endif()
+ if(messageType)
+ message(${messageType} "The qt4_use_modules function is obsolete. Use target_link_libraries with IMPORTED targets instead.")
+ endif()
+ endif()
if ("${_link_type}" STREQUAL "LINK_PUBLIC" OR "${_link_type}" STREQUAL "LINK_PRIVATE")
set(modules ${ARGN})
set(link_type ${_link_type})