44cce1a2ea
QtBuild.cmake is huge. Split it. Move module, plugin, tools, executables and test related functions out of QtBuild.cmake into separate files. Do the same for many other things too. An additional requirement is that all the new Helpers files only define functions and macros. No global variable definitions are allowed, nor execution of commands with side effects. Some notes: qt_install_qml_files is removed because it's dead code. Some functions still need to be figured out, because they are interspersed and depend on various global state assignments. Task-number: QTBUG-86035 Change-Id: I21d79ff02eef923c202eb1000422888727cb0e2c Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
56 lines
2.3 KiB
CMake
56 lines
2.3 KiB
CMake
# helper to set up a qdbusxml2cpp rule
|
|
function(qt_create_qdbusxml2cpp_command target infile)
|
|
qt_parse_all_arguments(arg "qt_create_qdbusxml2cpp_command" "ADAPTOR;INTERFACE" "BASENAME" "FLAGS" ${ARGN})
|
|
if((arg_ADAPTOR AND arg_INTERFACE) OR (NOT arg_ADAPTOR AND NOT arg_INTERFACE))
|
|
message(FATAL_ERROR "qt_create_dbusxml2cpp_command needs either ADAPTOR or INTERFACE.")
|
|
endif()
|
|
|
|
set(option "-a")
|
|
set(type "adaptor")
|
|
if (arg_INTERFACE)
|
|
set(option "-p")
|
|
set(type "interface")
|
|
endif()
|
|
|
|
if ("${arg_BASENAME}" STREQUAL "")
|
|
get_filename_component(file_dir "${infile}" DIRECTORY)
|
|
get_filename_component(file_name "${infile}" NAME_WLE)
|
|
get_filename_component(file_ext "${infile}" LAST_EXT)
|
|
|
|
if("${file_ext}" STREQUAL ".xml")
|
|
else()
|
|
message(FATAL_ERROR "DBUS ${type} input file is not xml.")
|
|
endif()
|
|
|
|
# use last part of io.qt.something.xml!
|
|
get_filename_component(file_ext "${file_name}" LAST_EXT)
|
|
if("x${file_ext}" STREQUAL "x")
|
|
else()
|
|
string(SUBSTRING "${file_ext}" 1 -1 file_name) # cut of leading '.'
|
|
endif()
|
|
|
|
string(TOLOWER "${file_name}" file_name)
|
|
set(file_name "${file_name}_${type}")
|
|
else()
|
|
set(file_name ${arg_BASENAME})
|
|
endif()
|
|
|
|
# Use absolute file path for the source file and set the current working directory to the
|
|
# current binary directory, because setting an absolute path for the header:source combo option
|
|
# does not work. Splitting on ":" breaks inside the dbus tool when running on Windows
|
|
# due to ":" being contained in the drive path (e.g C:\foo.h:C:\foo.cpp).
|
|
get_filename_component(absolute_in_file_path "${infile}" ABSOLUTE)
|
|
|
|
set(header_file "${file_name}.h")
|
|
set(source_file "${file_name}.cpp")
|
|
|
|
add_custom_command(OUTPUT "${header_file}" "${source_file}"
|
|
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp ${arg_FLAGS} "${option}"
|
|
"${header_file}:${source_file}" "${absolute_in_file_path}"
|
|
DEPENDS "${absolute_in_file_path}" ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
|
VERBATIM)
|
|
|
|
target_sources("${target}" PRIVATE "${header_file}" "${source_file}")
|
|
endfunction()
|