Create IMPORTED CMake targets for executables.
Although IMPORTED executables are not extra special, this is more future-proof in terms of both future CMake features and future our needs - it is possible that we would want to add a property to an executable at TARGET scope, which would not be possible if it is just a path. Change-Id: I649c601e004b21603c5fa97de0b7c397813ed68d Reviewed-by: Brad King <brad.king@kitware.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
parent
95191658d0
commit
189a5d8af1
@ -1,15 +1,47 @@
|
||||
|
||||
get_filename_component(_qt5_corelib_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
|
||||
|
||||
if (NOT TARGET Qt5::qmake)
|
||||
add_executable(Qt5::qmake IMPORTED)
|
||||
|
||||
set_target_properties(Qt5::qmake PROPERTIES
|
||||
!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
|
||||
set(QT_QMAKE_EXECUTABLE \"${_qt5_corelib_install_prefix}/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
|
||||
set(QT_MOC_EXECUTABLE \"${_qt5_corelib_install_prefix}/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
|
||||
set(QT_RCC_EXECUTABLE \"${_qt5_corelib_install_prefix}/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
|
||||
IMPORTED_LOCATION \"${_qt5_corelib_install_prefix}/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\"
|
||||
!!ELSE
|
||||
set(QT_QMAKE_EXECUTABLE \"$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
|
||||
set(QT_MOC_EXECUTABLE \"$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
|
||||
set(QT_RCC_EXECUTABLE \"$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
|
||||
IMPORTED_LOCATION \"$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\"
|
||||
!!ENDIF
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET Qt5::moc)
|
||||
add_executable(Qt5::moc IMPORTED)
|
||||
|
||||
set_target_properties(Qt5::moc PROPERTIES
|
||||
!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
|
||||
IMPORTED_LOCATION \"${_qt5_corelib_install_prefix}/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\"
|
||||
!!ELSE
|
||||
IMPORTED_LOCATION \"$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\"
|
||||
!!ENDIF
|
||||
)
|
||||
# For CMake automoc feature
|
||||
get_target_property(QT_MOC_EXECUTABLE Qt5::moc LOCATION)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET Qt5::rcc)
|
||||
add_executable(Qt5::rcc IMPORTED)
|
||||
|
||||
set_target_properties(Qt5::rcc PROPERTIES
|
||||
!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
|
||||
IMPORTED_LOCATION \"${_qt5_corelib_install_prefix}/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\"
|
||||
!!ELSE
|
||||
IMPORTED_LOCATION \"$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\"
|
||||
!!ENDIF
|
||||
)
|
||||
endif()
|
||||
|
||||
set(Qt5Core_QMAKE_EXECUTABLE Qt5::qmake)
|
||||
set(Qt5Core_MOC_EXECUTABLE Qt5::moc)
|
||||
set(Qt5Core_RCC_EXECUTABLE Qt5::rcc)
|
||||
|
||||
!!IF isEmpty(CMAKE_DATA_DIR_IS_ABSOLUTE)
|
||||
list(APPEND Qt5Core_INCLUDE_DIRS \"${_qt5_corelib_install_prefix}/mkspecs/default\")
|
||||
|
@ -108,13 +108,13 @@ macro(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options)
|
||||
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
|
||||
COMMAND ${Qt5Core_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters
|
||||
DEPENDS ${infile}
|
||||
${_moc_working_dir}
|
||||
VERBATIM)
|
||||
else()
|
||||
add_custom_command(OUTPUT ${outfile}
|
||||
COMMAND ${QT_MOC_EXECUTABLE}
|
||||
COMMAND ${Qt5Core_MOC_EXECUTABLE}
|
||||
ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile}
|
||||
DEPENDS ${infile} VERBATIM)
|
||||
endif()
|
||||
@ -202,7 +202,7 @@ function(QT5_ADD_RESOURCES outfiles )
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT ${outfile}
|
||||
COMMAND ${QT_RCC_EXECUTABLE}
|
||||
COMMAND ${Qt5Core_RCC_EXECUTABLE}
|
||||
ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
|
||||
MAIN_DEPENDENCY ${infile}
|
||||
DEPENDS ${_RC_DEPENDS} "${out_depends}" VERBATIM)
|
||||
|
@ -1,10 +1,29 @@
|
||||
|
||||
get_filename_component(_qt5_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
|
||||
get_filename_component(_qt5_dbus_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
|
||||
|
||||
if (NOT TARGET Qt5::qdbuscpp2xml)
|
||||
add_executable(Qt5::qdbuscpp2xml IMPORTED)
|
||||
|
||||
set_target_properties(Qt5::qdbuscpp2xml PROPERTIES
|
||||
!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
|
||||
set(QT_DBUSCPP2XML_EXECUTABLE \"${_qt5_install_prefix}/$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
|
||||
set(QT_DBUSXML2CPP_EXECUTABLE \"${_qt5_install_prefix}/$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
|
||||
IMPORTED_LOCATION \"${_qt5_dbus_install_prefix}/$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\"
|
||||
!!ELSE
|
||||
set(QT_DBUSCPP2XML_EXECUTABLE \"$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
|
||||
set(QT_DBUSXML2CPP_EXECUTABLE \"$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
|
||||
IMPORTED_LOCATION \"$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\"
|
||||
!!ENDIF
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET Qt5::qdbusxml2cpp)
|
||||
add_executable(Qt5::qdbusxml2cpp IMPORTED)
|
||||
|
||||
set_target_properties(Qt5::qdbusxml2cpp PROPERTIES
|
||||
!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
|
||||
IMPORTED_LOCATION \"${_qt5_dbus_install_prefix}/$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\"
|
||||
!!ELSE
|
||||
IMPORTED_LOCATION \"$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\"
|
||||
!!ENDIF
|
||||
)
|
||||
endif()
|
||||
|
||||
set(Qt5DBus_QDBUSCPP2XML_EXECUTABLE Qt5::qdbuscpp2xml)
|
||||
set(Qt5DBus_QDBUSXML2CPP_EXECUTABLE Qt5::qdbusxml2cpp)
|
||||
|
@ -57,7 +57,7 @@ function(QT5_ADD_DBUS_INTERFACE _sources _interface _basename)
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT "${_impl}" "${_header}"
|
||||
COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile}
|
||||
COMMAND ${Qt5DBus_QDBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile}
|
||||
DEPENDS ${_infile} VERBATIM)
|
||||
|
||||
set_source_files_properties("${_impl}" PROPERTIES SKIP_AUTOMOC TRUE)
|
||||
@ -111,7 +111,7 @@ function(QT5_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -optio
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT ${_target}
|
||||
COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} -o ${_target}
|
||||
COMMAND ${Qt5DBus_QDBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} -o ${_target}
|
||||
DEPENDS ${_in_file} VERBATIM
|
||||
)
|
||||
endfunction()
|
||||
@ -135,12 +135,12 @@ function(QT5_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optio
|
||||
|
||||
if(_optionalClassName)
|
||||
add_custom_command(OUTPUT "${_impl}" "${_header}"
|
||||
COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
|
||||
COMMAND ${Qt5DBus_QDBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
|
||||
DEPENDS ${_infile} VERBATIM
|
||||
)
|
||||
else()
|
||||
add_custom_command(OUTPUT "${_impl}" "${_header}"
|
||||
COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
|
||||
COMMAND ${Qt5DBus_QDBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
|
||||
DEPENDS ${_infile} VERBATIM
|
||||
)
|
||||
endif()
|
||||
|
@ -1,8 +1,16 @@
|
||||
|
||||
get_filename_component(_qt5_widgets_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
|
||||
|
||||
if (NOT TARGET Qt5::uic)
|
||||
add_executable(Qt5::uic IMPORTED)
|
||||
|
||||
set_target_properties(Qt5::uic PROPERTIES
|
||||
!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
|
||||
set(QT_UIC_EXECUTABLE \"${_qt5_widgets_install_prefix}/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
|
||||
IMPORTED_LOCATION \"${_qt5_widgets_install_prefix}/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\"
|
||||
!!ELSE
|
||||
set(QT_UIC_EXECUTABLE \"$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
|
||||
IMPORTED_LOCATION \"$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\"
|
||||
!!ENDIF
|
||||
)
|
||||
endif()
|
||||
|
||||
set(Qt5Widgets_UIC_EXECUTABLE Qt5::uic)
|
||||
|
@ -56,7 +56,7 @@ function(QT5_WRAP_UI outfiles )
|
||||
get_filename_component(infile ${it} ABSOLUTE)
|
||||
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
|
||||
add_custom_command(OUTPUT ${outfile}
|
||||
COMMAND ${QT_UIC_EXECUTABLE}
|
||||
COMMAND ${Qt5Widgets_UIC_EXECUTABLE}
|
||||
ARGS ${ui_options} -o ${outfile} ${infile}
|
||||
MAIN_DEPENDENCY ${infile} VERBATIM)
|
||||
list(APPEND ${outfiles} ${outfile})
|
||||
|
Loading…
Reference in New Issue
Block a user