summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-10-14 16:39:51 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-10-28 11:24:08 +0000
commit9166d8bbbb82b07882d8757b655270bcd5dd0013 (patch)
tree65b0c86cdf30cd28554ac65bc21333c62a1c61fc
parent26b55f78c9252a05defefdef3016754774ef2df0 (diff)
CMake: Fix idc in-tree example build when using CMake 3.24
When using CMake 3.24 to build qtactiveqt with in-tree examples, the build would fail with 'C:/Users/qt/work/qt/qtactiveqt_build/bin/Debug/idc.exe' is not recognized as an internal or external command, This seems to happen due to a combination of things: - using CMake 3.22+ - Windows -debug-and-release (Ninja Multi-Config) - excluding the idc tool debug variant from being built with EXCLUDE_FROM_ALL as part of a regular qt_internal_add_tool call - using add_custom_command(POST_BUILD) instead of (OUTPUT) - using $<TARGET_FILE> generator expression in the command instead of just the target name (due to having to prepend an environment setting shell script) Fix this by wrapping the relevant $<TARGET_FILE> arguments in a $<COMMAND_CONFIG> generator expression, similar how it was done in 97b1062674283afb0131e73d8319c95aa7087a8b for qtdeclarative. Note that in one case, we split the $<IF> expression into sub-expressions, and wrap $<TARGET_FILE> in $<COMMAND_CONFIG> only for the tool path, because $<COMMAND_CONFIG> can only wrap the outer-most generator expression in an argument, according to the docs, and we don't want to apply it to the target and output tlb file. Task-number: QTQAINFRA-5044 Change-Id: Ib5daa3b7c7d40761a42e5772add69c700752a6e6 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit fe41d5656f9c9494499061ccc0eb8d076de0e1f2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/activeqt/control/Qt6AxServerMacros.cmake35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/activeqt/control/Qt6AxServerMacros.cmake b/src/activeqt/control/Qt6AxServerMacros.cmake
index 7e67eda..df7a643 100644
--- a/src/activeqt/control/Qt6AxServerMacros.cmake
+++ b/src/activeqt/control/Qt6AxServerMacros.cmake
@@ -55,10 +55,25 @@ function(qt6_target_idl target)
_qt_internal_get_tool_wrapper_script_path(tool_wrapper)
set(tlb_command_list "")
+ # Wrap tool paths in $<COMMAND_CONFIG> to ensure we use the release tool when building debug
+ # targets in a multi-config build, because the debug tool is usually not built by default.
+ if(CMAKE_GENERATOR STREQUAL "Ninja Multi-Config" AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.20")
+ set(cmb "$<COMMAND_CONFIG:")
+ set(cme ">")
+ else()
+ set(cmb "")
+ set(cme "")
+ endif()
+
+ set(idc_target "${QT_CMAKE_EXPORT_NAMESPACE}::idc")
+ set(idc_target_file "$<TARGET_FILE:${idc_target}>")
+ set(idc_target_file_command_config_wrapped "${cmb}${idc_target_file}${cme}")
+
list(APPEND tlb_command_list
COMMAND
"${tool_wrapper}"
- "$<TARGET_FILE:${QT_CMAKE_EXPORT_NAMESPACE}::idc>" "$<TARGET_FILE:${target}>"
+ "${idc_target_file_command_config_wrapped}"
+ "$<TARGET_FILE:${target}>"
/idl "${output_idl}" -version 1.0
)
@@ -69,27 +84,35 @@ function(qt6_target_idl target)
set(rc_files "$<FILTER:$<TARGET_PROPERTY:${target},SOURCES>,INCLUDE,\\.rc$>")
set(have_rc_files "$<NOT:$<BOOL:$<STREQUAL:${rc_files},>>>")
- set(rc_cmd "$<TARGET_FILE:${QT_CMAKE_EXPORT_NAMESPACE}::idc>$<SEMICOLON>\
-$<TARGET_FILE:${target}>$<SEMICOLON>/tlb$<SEMICOLON>${output_tlb}")
+
set(no_rc_cmd "echo \"No rc-file linked into project. The type library of the ${target} \
target will be a separate file.\"")
+
+ set(idc_args
+ "$<SEMICOLON>$<TARGET_FILE:${target}>$<SEMICOLON>/tlb$<SEMICOLON>${output_tlb}")
+
+ # Split command into two parts, so that COMMAND_CONFIG can be applied only to the idc tool path,
+ # but not the target and tlb files.
+ set(cmd_part1 "${cmb}$<IF:${have_rc_files},${idc_target_file},${no_rc_cmd}>${cme}")
+ set(cmd_part2 "$<${have_rc_files}:${idc_args}>")
+
list(APPEND tlb_command_list
COMMAND
- "${tool_wrapper}" "$<IF:${have_rc_files},${rc_cmd},${no_rc_cmd}>"
+ "${tool_wrapper}" "${cmd_part1}" "${cmd_part2}"
)
if(NOT arg_NO_AX_SERVER_REGISTRATION AND NOT QT_NO_AX_SERVER_REGISTRATION)
list(APPEND tlb_command_list
COMMAND
"${tool_wrapper}"
- "$<TARGET_FILE:${QT_CMAKE_EXPORT_NAMESPACE}::idc>"
+ "${idc_target_file_command_config_wrapped}"
"$<TARGET_FILE:${target}>" /regserver
)
endif()
add_custom_command(TARGET ${target} POST_BUILD
${tlb_command_list}
DEPENDS
- ${QT_CMAKE_EXPORT_NAMESPACE}::idc
+ "${idc_target}"
VERBATIM
COMMAND_EXPAND_LISTS
)