summaryrefslogtreecommitdiffstats
path: root/src/corelib/Qt6CoreMacros.cmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2020-05-04 21:55:40 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2020-05-07 21:30:33 +0200
commit657fa0462d552110e2ba14bcac46275e6066993f (patch)
tree334a0210e71f1f3f9db5e4deff89b9469fcc4048 /src/corelib/Qt6CoreMacros.cmake
parentc5b8b662105cc5ced968da9f567fe1134c52d6b5 (diff)
CMake: Fix Windows RC file generation for multi-config builds
For Ninja Multi-Config we now generate RC files in a path matching the current config name. We have to work around https://gitlab.kitware.com/cmake/cmake/-/issues/20682 to add the generated config-dependent RC files to the target. But due to https://gitlab.kitware.com/cmake/cmake/-/issues/20683 the OriginalFilename entry in the generated resource will be wrong for all configurations but the main one. Cross fingers that this will be fixed upstream. In the meantime: ignore the issue. Drive-by changes: - Fix the function comment. - Surround the RC file name by double quotes in case there are spaces in the path. Fixes: QTBUG-83986 Change-Id: If2fec41fa8050b3feb92c3ce051fde1a5bad0239 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/corelib/Qt6CoreMacros.cmake')
-rw-r--r--src/corelib/Qt6CoreMacros.cmake52
1 files changed, 38 insertions, 14 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index 739f89cc3f..9dade2edbd 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -805,7 +805,7 @@ if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
endif()
# Generate Win32 RC files for a target. All entries in the RC file are generated
-# from target prorties:
+# from target properties:
#
# QT_TARGET_COMPANY_NAME: RC Company name
# QT_TARGET_DESCRIPTION: RC File Description
@@ -814,10 +814,9 @@ endif()
# QT_TARGET_PRODUCT_NAME: RC ProductName
# QT_TARGET_RC_ICONS: List of paths to icon files
#
-# If you don not wish to auto-generate rc files, it's possible to provide your
+# If you do not wish to auto-generate rc files, it's possible to provide your
# own RC file by setting the property QT_TARGET_WINDOWS_RC_FILE with a path to
# an existing rc file.
-#
function(qt6_generate_win32_rc_file target)
set(prohibited_target_types INTERFACE_LIBRARY STATIC_LIBRARY OBJECT_LIBRARY)
get_target_property(target_type ${target} TYPE)
@@ -834,9 +833,16 @@ function(qt6_generate_win32_rc_file target)
return()
endif()
- if (NOT target_rc_file)
+ if (target_rc_file)
+ # Use the provided RC file
+ target_sources(${target} PRIVATE "${target_rc_file}")
+ else()
# Generate RC File
- set(rc_file_output "${target_binary_dir}/${target}_resource.rc")
+ set(rc_file_output "${target_binary_dir}/")
+ if(QT_GENERATOR_IS_MULTI_CONFIG)
+ string(APPEND rc_file_output "$<CONFIG>/")
+ endif()
+ string(APPEND rc_file_output "${target}_resource.rc")
set(target_rc_file "${rc_file_output}")
set(company_name "")
@@ -940,16 +946,34 @@ END
CONTENT "${contents}"
)
- add_custom_command(OUTPUT "${target_rc_file}"
- DEPENDS "${rc_file_output}.tmp"
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- "${target_rc_file}.tmp"
- "${target_rc_file}"
- )
- endif()
-
- target_sources(${target} PRIVATE ${target_rc_file})
+ if(QT_GENERATOR_IS_MULTI_CONFIG)
+ set(cfgs ${CMAKE_CONFIGURATION_TYPES})
+ set(outputs "")
+ foreach(cfg ${cfgs})
+ string(REPLACE "$<CONFIG>" "${cfg}" expanded_rc_file_output "${rc_file_output}")
+ list(APPEND outputs "${expanded_rc_file_output}")
+ endforeach()
+ else()
+ set(cfgs "${CMAKE_BUILD_TYPE}")
+ set(outputs "${rc_file_output}")
+ endif()
+ while(outputs)
+ list(POP_FRONT cfgs cfg)
+ list(POP_FRONT outputs output)
+ set(input "${output}.tmp")
+ add_custom_command(OUTPUT "${output}"
+ DEPENDS "${input}"
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different "${input}" "${output}"
+ )
+ # We would like to do the following:
+ # target_sources(${target} PRIVATE "$<$<CONFIG:${cfg}>:${output}>")
+ # However, https://gitlab.kitware.com/cmake/cmake/-/issues/20682 doesn't let us.
+ add_library(${target}_${cfg}_rc INTERFACE)
+ target_sources(${target}_${cfg}_rc INTERFACE "${output}")
+ target_link_libraries(${target} PRIVATE "$<$<CONFIG:${cfg}>:${target}_${cfg}_rc>")
+ endwhile()
+ endif()
endfunction()
function(__qt_get_relative_resource_path_for_file output_alias file)