2009-11-15 21:02:19 +03:00
|
|
|
# This file is included by FindQt4.cmake, don't include it directly.
|
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2005-2009 Kitware, Inc.
|
|
|
|
#
|
|
|
|
# Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
# see accompanying file Copyright.txt for details.
|
|
|
|
#
|
|
|
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the License for more information.
|
|
|
|
#=============================================================================
|
2010-08-07 04:48:47 +04:00
|
|
|
# (To distribute this file outside of CMake, substitute the full
|
2009-11-15 21:02:19 +03:00
|
|
|
# License text for the above reference.)
|
|
|
|
|
|
|
|
|
|
|
|
######################################
|
|
|
|
#
|
|
|
|
# Macros for building Qt files
|
|
|
|
#
|
|
|
|
######################################
|
|
|
|
|
|
|
|
|
2013-02-27 02:27:22 +04:00
|
|
|
macro (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options _qt4_target)
|
2012-08-13 21:47:32 +04:00
|
|
|
set(${_qt4_files})
|
|
|
|
set(${_qt4_options})
|
|
|
|
set(_QT4_DOING_OPTIONS FALSE)
|
2013-02-27 02:27:22 +04:00
|
|
|
set(_QT4_DOING_TARGET FALSE)
|
2012-08-13 21:47:32 +04:00
|
|
|
foreach(_currentArg ${ARGN})
|
2013-02-27 02:27:22 +04:00
|
|
|
if ("x${_currentArg}" STREQUAL "xOPTIONS")
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_QT4_DOING_OPTIONS TRUE)
|
2013-02-27 02:27:22 +04:00
|
|
|
elseif ("x${_currentArg}" STREQUAL "xTARGET")
|
|
|
|
set(_QT4_DOING_TARGET TRUE)
|
2012-08-13 21:50:14 +04:00
|
|
|
else ()
|
2013-02-27 02:27:22 +04:00
|
|
|
if(_QT4_DOING_TARGET)
|
|
|
|
set(${_qt4_target} "${_currentArg}")
|
|
|
|
elseif(_QT4_DOING_OPTIONS)
|
2012-08-13 21:47:32 +04:00
|
|
|
list(APPEND ${_qt4_options} "${_currentArg}")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
list(APPEND ${_qt4_files} "${_currentArg}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif ()
|
|
|
|
endforeach()
|
|
|
|
endmacro ()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
|
|
|
|
|
|
|
# macro used to create the names of output files preserving relative dirs
|
2012-08-13 21:47:32 +04:00
|
|
|
macro (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile )
|
|
|
|
string(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
|
|
|
|
string(LENGTH ${infile} _infileLength)
|
|
|
|
set(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
if(_infileLength GREATER _binlength)
|
|
|
|
string(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
|
|
|
|
if(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
|
|
|
|
file(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
if(WIN32 AND rel MATCHES "^[a-zA-Z]:") # absolute path
|
|
|
|
string(REGEX REPLACE "^([a-zA-Z]):(.*)$" "\\1_\\2" rel "${rel}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
|
|
|
|
string(REPLACE ".." "__" _outfile ${_outfile})
|
|
|
|
get_filename_component(outpath ${_outfile} PATH)
|
|
|
|
get_filename_component(_outfile ${_outfile} NAME_WE)
|
|
|
|
file(MAKE_DIRECTORY ${outpath})
|
|
|
|
set(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
|
2012-08-13 21:50:14 +04:00
|
|
|
endmacro ()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
|
|
|
|
macro (QT4_GET_MOC_FLAGS _moc_flags)
|
|
|
|
set(${_moc_flags})
|
|
|
|
get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES)
|
|
|
|
|
|
|
|
foreach(_current ${_inc_DIRS})
|
|
|
|
if("${_current}" MATCHES "\\.framework/?$")
|
|
|
|
string(REGEX REPLACE "/[^/]+\\.framework" "" framework_path "${_current}")
|
|
|
|
set(${_moc_flags} ${${_moc_flags}} "-F${framework_path}")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(${_moc_flags} ${${_moc_flags}} "-I${_current}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
get_directory_property(_defines COMPILE_DEFINITIONS)
|
|
|
|
foreach(_current ${_defines})
|
|
|
|
set(${_moc_flags} ${${_moc_flags}} "-D${_current}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if(Q_WS_WIN)
|
|
|
|
set(${_moc_flags} ${${_moc_flags}} -DWIN32)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
2012-08-13 21:50:14 +04:00
|
|
|
endmacro()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
|
|
|
|
|
|
|
# helper macro to set up a moc rule
|
2013-02-27 02:27:22 +04:00
|
|
|
macro (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target)
|
2009-11-15 21:02:19 +03:00
|
|
|
# For Windows, create a parameters file to work around command line length limit
|
2013-02-27 02:27:22 +04:00
|
|
|
# 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)
|
2013-07-26 11:35:57 +04:00
|
|
|
set(targetincludes "$<TARGET_PROPERTY:${moc_target},INCLUDE_DIRECTORIES>")
|
|
|
|
set(targetdefines "$<TARGET_PROPERTY:${moc_target},COMPILE_DEFINITIONS>")
|
2013-02-27 02:27:22 +04:00
|
|
|
|
|
|
|
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}
|
2013-07-26 11:34:05 +04:00
|
|
|
CONTENT "${targetdefines}${targetincludes}${_moc_parameters}\n"
|
2013-02-27 02:27:22 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
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)
|
2012-08-13 21:50:14 +04:00
|
|
|
endmacro ()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
macro (QT4_GENERATE_MOC infile outfile )
|
2009-11-15 21:02:19 +03:00
|
|
|
# get include dirs and flags
|
|
|
|
QT4_GET_MOC_FLAGS(moc_flags)
|
2012-08-13 21:47:32 +04:00
|
|
|
get_filename_component(abs_infile ${infile} ABSOLUTE)
|
|
|
|
set(_outfile "${outfile}")
|
|
|
|
if(NOT IS_ABSOLUTE "${outfile}")
|
|
|
|
set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2013-02-27 02:27:22 +04:00
|
|
|
|
|
|
|
if ("x${ARGV2}" STREQUAL "xTARGET")
|
|
|
|
set(moc_target ${ARGV3})
|
|
|
|
endif()
|
|
|
|
QT4_CREATE_MOC_COMMAND(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}")
|
2012-08-13 21:47:32 +04:00
|
|
|
set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file
|
2012-08-13 21:50:14 +04:00
|
|
|
endmacro ()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
|
|
|
|
|
|
|
# QT4_WRAP_CPP(outfiles inputfile ... )
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
macro (QT4_WRAP_CPP outfiles )
|
2009-11-15 21:02:19 +03:00
|
|
|
# get include dirs
|
|
|
|
QT4_GET_MOC_FLAGS(moc_flags)
|
2013-02-27 02:27:22 +04:00
|
|
|
QT4_EXTRACT_OPTIONS(moc_files moc_options moc_target ${ARGN})
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
foreach (it ${moc_files})
|
|
|
|
get_filename_component(it ${it} ABSOLUTE)
|
2009-11-15 21:02:19 +03:00
|
|
|
QT4_MAKE_OUTPUT_FILE(${it} moc_ cxx outfile)
|
2013-02-27 02:27:22 +04:00
|
|
|
QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}")
|
2012-08-13 21:47:32 +04:00
|
|
|
set(${outfiles} ${${outfiles}} ${outfile})
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:50:14 +04:00
|
|
|
endmacro ()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
|
|
|
|
|
|
|
# QT4_WRAP_UI(outfiles inputfile ... )
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
macro (QT4_WRAP_UI outfiles )
|
2013-02-27 02:27:22 +04:00
|
|
|
QT4_EXTRACT_OPTIONS(ui_files ui_options ui_target ${ARGN})
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
foreach (it ${ui_files})
|
|
|
|
get_filename_component(outfile ${it} NAME_WE)
|
|
|
|
get_filename_component(infile ${it} ABSOLUTE)
|
|
|
|
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
|
|
|
|
add_custom_command(OUTPUT ${outfile}
|
2009-11-15 21:02:19 +03:00
|
|
|
COMMAND ${QT_UIC_EXECUTABLE}
|
|
|
|
ARGS ${ui_options} -o ${outfile} ${infile}
|
2011-11-03 00:13:52 +04:00
|
|
|
MAIN_DEPENDENCY ${infile} VERBATIM)
|
2012-08-13 21:47:32 +04:00
|
|
|
set(${outfiles} ${${outfiles}} ${outfile})
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach ()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:50:14 +04:00
|
|
|
endmacro ()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
|
|
|
|
|
|
|
# QT4_ADD_RESOURCES(outfiles inputfile ... )
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
macro (QT4_ADD_RESOURCES outfiles )
|
2013-02-27 02:27:22 +04:00
|
|
|
QT4_EXTRACT_OPTIONS(rcc_files rcc_options rcc_target ${ARGN})
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
foreach (it ${rcc_files})
|
|
|
|
get_filename_component(outfilename ${it} NAME_WE)
|
|
|
|
get_filename_component(infile ${it} ABSOLUTE)
|
|
|
|
get_filename_component(rc_path ${infile} PATH)
|
|
|
|
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
|
2012-05-29 19:45:03 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_RC_DEPENDS)
|
|
|
|
if(EXISTS "${infile}")
|
2012-05-29 19:45:03 +04:00
|
|
|
# parse file for dependencies
|
|
|
|
# all files are absolute paths or relative to the location of the qrc file
|
2012-08-30 11:47:42 +04:00
|
|
|
file(READ "${infile}" _RC_FILE_CONTENTS)
|
2012-08-22 16:33:12 +04:00
|
|
|
string(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
|
|
|
|
foreach(_RC_FILE ${_RC_FILES})
|
|
|
|
string(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT IS_ABSOLUTE "${_RC_FILE}")
|
|
|
|
set(_RC_FILE "${rc_path}/${_RC_FILE}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
2012-08-19 15:54:56 +04:00
|
|
|
unset(_RC_FILES)
|
2012-08-22 16:33:12 +04:00
|
|
|
unset(_RC_FILE_CONTENTS)
|
2012-05-29 19:45:03 +04:00
|
|
|
# Since this cmake macro is doing the dependency scanning for these files,
|
|
|
|
# let's make a configured file and add it as a dependency so cmake is run
|
|
|
|
# again when dependencies need to be recomputed.
|
|
|
|
QT4_MAKE_OUTPUT_FILE("${infile}" "" "qrc.depends" out_depends)
|
2012-08-13 21:47:32 +04:00
|
|
|
configure_file("${infile}" "${out_depends}" COPY_ONLY)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-05-29 19:45:03 +04:00
|
|
|
# The .qrc file does not exist (yet). Let's add a dependency and hope
|
|
|
|
# that it will be generated later
|
2012-08-13 21:47:32 +04:00
|
|
|
set(out_depends)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-05-29 19:45:03 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(OUTPUT ${outfile}
|
2009-11-15 21:02:19 +03:00
|
|
|
COMMAND ${QT_RCC_EXECUTABLE}
|
|
|
|
ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
|
|
|
|
MAIN_DEPENDENCY ${infile}
|
2011-11-03 00:13:52 +04:00
|
|
|
DEPENDS ${_RC_DEPENDS} "${out_depends}" VERBATIM)
|
2012-08-13 21:47:32 +04:00
|
|
|
set(${outfiles} ${${outfiles}} ${outfile})
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach ()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:50:14 +04:00
|
|
|
endmacro ()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
macro(QT4_ADD_DBUS_INTERFACE _sources _interface _basename)
|
|
|
|
get_filename_component(_infile ${_interface} ABSOLUTE)
|
|
|
|
set(_header "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h")
|
|
|
|
set(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp")
|
|
|
|
set(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc")
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
get_source_file_property(_nonamespace ${_interface} NO_NAMESPACE)
|
|
|
|
if(_nonamespace)
|
|
|
|
set(_params -N -m)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_params -m)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2011-09-05 23:58:29 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
get_source_file_property(_classname ${_interface} CLASSNAME)
|
|
|
|
if(_classname)
|
|
|
|
set(_params ${_params} -c ${_classname})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2011-09-05 23:58:29 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
get_source_file_property(_include ${_interface} INCLUDE)
|
|
|
|
if(_include)
|
|
|
|
set(_params ${_params} -i ${_include})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(OUTPUT "${_impl}" "${_header}"
|
2009-11-15 21:02:19 +03:00
|
|
|
COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile}
|
2011-11-03 00:13:52 +04:00
|
|
|
DEPENDS ${_infile} VERBATIM)
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set_source_files_properties("${_impl}" PROPERTIES SKIP_AUTOMOC TRUE)
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-06-20 15:29:45 +04:00
|
|
|
QT4_GENERATE_MOC("${_header}" "${_moc}")
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
list(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}")
|
2012-06-20 15:29:45 +04:00
|
|
|
MACRO_ADD_FILE_DEPENDENCIES("${_impl}" "${_moc}")
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:50:14 +04:00
|
|
|
endmacro()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
macro(QT4_ADD_DBUS_INTERFACES _sources)
|
|
|
|
foreach (_current_FILE ${ARGN})
|
|
|
|
get_filename_component(_infile ${_current_FILE} ABSOLUTE)
|
|
|
|
get_filename_component(_basename ${_current_FILE} NAME)
|
2009-11-15 21:02:19 +03:00
|
|
|
# get the part before the ".xml" suffix
|
2012-08-13 21:47:32 +04:00
|
|
|
string(TOLOWER ${_basename} _basename)
|
|
|
|
string(REGEX REPLACE "(.*\\.)?([^\\.]+)\\.xml" "\\2" _basename ${_basename})
|
2009-11-15 21:02:19 +03:00
|
|
|
QT4_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface)
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach ()
|
|
|
|
endmacro()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
macro(QT4_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options )
|
2013-02-27 02:27:22 +04:00
|
|
|
QT4_EXTRACT_OPTIONS(_customName _qt4_dbus_options _qt4_dbus_target ${ARGN})
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
get_filename_component(_in_file ${_header} ABSOLUTE)
|
|
|
|
get_filename_component(_basename ${_header} NAME_WE)
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if (_customName)
|
2010-12-23 19:21:56 +03:00
|
|
|
if (IS_ABSOLUTE ${_customName})
|
|
|
|
get_filename_component(_containingDir ${_customName} PATH)
|
|
|
|
if (NOT EXISTS ${_containingDir})
|
|
|
|
file(MAKE_DIRECTORY "${_containingDir}")
|
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_target ${_customName})
|
2010-12-23 19:21:56 +03:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName})
|
2010-12-23 19:21:56 +03:00
|
|
|
endif()
|
2012-08-13 21:50:14 +04:00
|
|
|
else ()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(OUTPUT ${_target}
|
2009-11-15 21:02:19 +03:00
|
|
|
COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} -o ${_target}
|
2011-11-03 00:13:52 +04:00
|
|
|
DEPENDS ${_in_file} VERBATIM
|
2009-11-15 21:02:19 +03:00
|
|
|
)
|
2012-08-13 21:50:14 +04:00
|
|
|
endmacro()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
macro(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName)
|
|
|
|
get_filename_component(_infile ${_xml_file} ABSOLUTE)
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_optionalBasename "${ARGV4}")
|
|
|
|
if (_optionalBasename)
|
|
|
|
set(_basename ${_optionalBasename} )
|
2012-08-13 21:50:14 +04:00
|
|
|
else ()
|
2012-08-13 21:47:32 +04:00
|
|
|
string(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile})
|
|
|
|
string(TOLOWER ${_basename} _basename)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_optionalClassName "${ARGV5}")
|
|
|
|
set(_header "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h")
|
|
|
|
set(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp")
|
|
|
|
set(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc")
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(_optionalClassName)
|
|
|
|
add_custom_command(OUTPUT "${_impl}" "${_header}"
|
2009-11-15 21:02:19 +03:00
|
|
|
COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
|
2011-11-03 00:13:52 +04:00
|
|
|
DEPENDS ${_infile} VERBATIM
|
2009-11-15 21:02:19 +03:00
|
|
|
)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(OUTPUT "${_impl}" "${_header}"
|
2009-11-15 21:02:19 +03:00
|
|
|
COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
|
2011-11-03 00:13:52 +04:00
|
|
|
DEPENDS ${_infile} VERBATIM
|
2009-11-15 21:02:19 +03:00
|
|
|
)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-06-20 15:29:45 +04:00
|
|
|
QT4_GENERATE_MOC("${_header}" "${_moc}")
|
2012-08-13 21:47:32 +04:00
|
|
|
set_source_files_properties("${_impl}" PROPERTIES SKIP_AUTOMOC TRUE)
|
2012-06-20 15:29:45 +04:00
|
|
|
MACRO_ADD_FILE_DEPENDENCIES("${_impl}" "${_moc}")
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
list(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endmacro()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
macro(QT4_AUTOMOC)
|
2013-07-04 12:00:27 +04:00
|
|
|
if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.11)
|
2013-09-17 21:11:39 +04:00
|
|
|
message(DEPRECATION "The qt4_automoc macro is obsolete. Use the CMAKE_AUTOMOC feature instead.")
|
2013-07-04 12:00:27 +04:00
|
|
|
endif()
|
2009-11-15 21:02:19 +03:00
|
|
|
QT4_GET_MOC_FLAGS(_moc_INCS)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_matching_FILES )
|
|
|
|
foreach (_current_FILE ${ARGN})
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
|
2009-11-15 21:02:19 +03:00
|
|
|
# if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
|
|
|
|
# This is required to make uic work correctly:
|
|
|
|
# we need to add generated .cpp files to the sources (to compile them),
|
|
|
|
# but we cannot let automoc handle them, as the .cpp files don't exist yet when
|
|
|
|
# cmake is run for the very first time on them -> however the .cpp files might
|
|
|
|
# exist at a later run. at that time we need to skip them, so that we don't add two
|
|
|
|
# different rules for the same moc file
|
2012-08-13 21:47:32 +04:00
|
|
|
get_source_file_property(_skip ${_abs_FILE} SKIP_AUTOMOC)
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if ( NOT _skip AND EXISTS ${_abs_FILE} )
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
file(READ ${_abs_FILE} _contents)
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
get_filename_component(_abs_PATH ${_abs_FILE} PATH)
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
string(REGEX MATCHALL "# *include +[^ ]+\\.moc[\">]" _match "${_contents}")
|
|
|
|
if(_match)
|
|
|
|
foreach (_current_MOC_INC ${_match})
|
|
|
|
string(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
|
2009-11-15 21:02:19 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
get_filename_component(_basename ${_current_MOC} NAME_WE)
|
|
|
|
if(EXISTS ${_abs_PATH}/${_basename}.hpp)
|
|
|
|
set(_header ${_abs_PATH}/${_basename}.hpp)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_header ${_abs_PATH}/${_basename}.h)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
|
2013-02-27 02:27:22 +04:00
|
|
|
QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${_moc_INCS}" "" "")
|
2009-11-15 21:02:19 +03:00
|
|
|
MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach ()
|
|
|
|
endif()
|
|
|
|
endif ()
|
|
|
|
endforeach ()
|
|
|
|
endmacro()
|
2009-11-15 21:02:19 +03:00
|
|
|
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
macro(QT4_CREATE_TRANSLATION _qm_files)
|
2013-02-27 02:27:22 +04:00
|
|
|
QT4_EXTRACT_OPTIONS(_lupdate_files _lupdate_options _lupdate_target ${ARGN})
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_my_sources)
|
|
|
|
set(_my_dirs)
|
|
|
|
set(_my_tsfiles)
|
|
|
|
set(_ts_pro)
|
|
|
|
foreach (_file ${_lupdate_files})
|
|
|
|
get_filename_component(_ext ${_file} EXT)
|
|
|
|
get_filename_component(_abs_FILE ${_file} ABSOLUTE)
|
|
|
|
if(_ext MATCHES "ts")
|
|
|
|
list(APPEND _my_tsfiles ${_abs_FILE})
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT _ext)
|
|
|
|
list(APPEND _my_dirs ${_abs_FILE})
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
list(APPEND _my_sources ${_abs_FILE})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2012-08-13 21:47:32 +04:00
|
|
|
foreach(_ts_file ${_my_tsfiles})
|
|
|
|
if(_my_sources)
|
2009-11-15 21:02:19 +03:00
|
|
|
# make a .pro file to call lupdate on, so we don't make our commands too
|
|
|
|
# long for some systems
|
2012-08-13 21:47:32 +04:00
|
|
|
get_filename_component(_ts_name ${_ts_file} NAME_WE)
|
|
|
|
set(_ts_pro ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lupdate.pro)
|
|
|
|
set(_pro_srcs)
|
|
|
|
foreach(_pro_src ${_my_sources})
|
|
|
|
set(_pro_srcs "${_pro_srcs} \"${_pro_src}\"")
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_pro_includes)
|
|
|
|
get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES)
|
|
|
|
foreach(_pro_include ${_inc_DIRS})
|
|
|
|
get_filename_component(_abs_include "${_pro_include}" ABSOLUTE)
|
|
|
|
set(_pro_includes "${_pro_includes} \"${_abs_include}\"")
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
2012-08-13 21:47:32 +04:00
|
|
|
file(WRITE ${_ts_pro} "SOURCES = ${_pro_srcs}\nINCLUDEPATH = ${_pro_includes}\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(OUTPUT ${_ts_file}
|
2009-11-15 21:02:19 +03:00
|
|
|
COMMAND ${QT_LUPDATE_EXECUTABLE}
|
|
|
|
ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file}
|
2011-11-03 00:13:52 +04:00
|
|
|
DEPENDS ${_my_sources} ${_ts_pro} VERBATIM)
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
2009-11-15 21:02:19 +03:00
|
|
|
QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles})
|
2012-08-13 21:50:14 +04:00
|
|
|
endmacro()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
|
|
|
|
macro(QT4_ADD_TRANSLATION _qm_files)
|
|
|
|
foreach (_current_FILE ${ARGN})
|
|
|
|
get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
|
|
|
|
get_filename_component(qm ${_abs_FILE} NAME_WE)
|
|
|
|
get_source_file_property(output_location ${_abs_FILE} OUTPUT_LOCATION)
|
|
|
|
if(output_location)
|
|
|
|
file(MAKE_DIRECTORY "${output_location}")
|
|
|
|
set(qm "${output_location}/${qm}.qm")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
add_custom_command(OUTPUT ${qm}
|
2009-11-15 21:02:19 +03:00
|
|
|
COMMAND ${QT_LRELEASE_EXECUTABLE}
|
|
|
|
ARGS ${_abs_FILE} -qm ${qm}
|
2011-11-03 00:13:52 +04:00
|
|
|
DEPENDS ${_abs_FILE} VERBATIM
|
2009-11-15 21:02:19 +03:00
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
set(${_qm_files} ${${_qm_files}} ${qm})
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach ()
|
|
|
|
endmacro()
|
2012-08-09 01:31:52 +04:00
|
|
|
|
|
|
|
function(qt4_use_modules _target _link_type)
|
2013-07-04 12:00:27 +04:00
|
|
|
if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.11)
|
2013-09-17 21:11:39 +04:00
|
|
|
message(DEPRECATION "The qt4_use_modules function is obsolete. Use target_link_libraries with IMPORTED targets instead.")
|
2013-07-04 12:00:27 +04:00
|
|
|
endif()
|
2012-08-09 01:31:52 +04:00
|
|
|
if ("${_link_type}" STREQUAL "LINK_PUBLIC" OR "${_link_type}" STREQUAL "LINK_PRIVATE")
|
|
|
|
set(modules ${ARGN})
|
|
|
|
set(link_type ${_link_type})
|
|
|
|
else()
|
|
|
|
set(modules ${_link_type} ${ARGN})
|
|
|
|
endif()
|
|
|
|
foreach(_module ${modules})
|
|
|
|
string(TOUPPER ${_module} _ucmodule)
|
2013-05-23 18:51:11 +04:00
|
|
|
set(_targetPrefix QT_QT${_ucmodule})
|
|
|
|
if (_ucmodule STREQUAL QAXCONTAINER OR _ucmodule STREQUAL QAXSERVER)
|
|
|
|
if (NOT QT_Q${_ucmodule}_FOUND)
|
|
|
|
message(FATAL_ERROR "Can not use \"${_module}\" module which has not yet been found.")
|
|
|
|
endif()
|
|
|
|
set(_targetPrefix QT_Q${_ucmodule})
|
|
|
|
else()
|
|
|
|
if (NOT QT_QT${_ucmodule}_FOUND)
|
|
|
|
message(FATAL_ERROR "Can not use \"${_module}\" module which has not yet been found.")
|
|
|
|
endif()
|
|
|
|
if ("${_ucmodule}" STREQUAL "MAIN")
|
|
|
|
message(FATAL_ERROR "Can not use \"${_module}\" module with qt4_use_modules.")
|
|
|
|
endif()
|
2012-08-09 01:31:52 +04:00
|
|
|
endif()
|
2013-05-23 18:51:11 +04:00
|
|
|
target_link_libraries(${_target} ${link_type} ${${_targetPrefix}_LIBRARIES})
|
|
|
|
set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${${_targetPrefix}_INCLUDE_DIR} ${QT_HEADERS_DIR} ${QT_MKSPECS_DIR}/default)
|
|
|
|
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${${_targetPrefix}_COMPILE_DEFINITIONS})
|
2012-08-09 01:31:52 +04:00
|
|
|
endforeach()
|
|
|
|
endfunction()
|