summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2022-05-18 18:14:12 +0200
committerAlexey Edelev <alexey.edelev@qt.io>2022-05-19 15:34:26 +0200
commit38bb294fb786a9a6ee8386bde85ab0ad067ecd7a (patch)
treeb19852c164f5520ec455853793f23b2219c16de2
parent04a60bb033f57099b048b0d6f99f68a08dcd1483 (diff)
Avoid using add_custom_command with PRE_LINK for version script
add_custom_command with PRE_LINK doesn't work correctly with Multi-Config builds. The better solution is to introduce a custom target that generates the final version script and link the target to the library target as the dependency. Change-Id: Ib7420af752a6a46f29f411f9f0dc8557410b4f22 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--cmake/QtFlagHandlingHelpers.cmake25
1 files changed, 19 insertions, 6 deletions
diff --git a/cmake/QtFlagHandlingHelpers.cmake b/cmake/QtFlagHandlingHelpers.cmake
index f8bca02910..c01b596b80 100644
--- a/cmake/QtFlagHandlingHelpers.cmake
+++ b/cmake/QtFlagHandlingHelpers.cmake
@@ -32,13 +32,26 @@ function(qt_internal_add_linker_version_script target)
qt_ensure_perl()
- add_custom_command(TARGET "${target}" PRE_LINK
- COMMAND "${HOST_PERL}" "${QT_MKSPECS_DIR}/features/data/unix/findclasslist.pl" < "${infile}" > "${outfile}"
- BYPRODUCTS "${outfile}" DEPENDS "${infile}"
+ set(generator_command "${HOST_PERL}"
+ "${QT_MKSPECS_DIR}/features/data/unix/findclasslist.pl"
+ "<" "${infile}" ">" "${outfile}"
+ )
+ set(generator_dependencies
+ "${infile}"
+ "${QT_MKSPECS_DIR}/features/data/unix/findclasslist.pl"
+ )
+
+ add_custom_command(
+ OUTPUT "${outfile}"
+ COMMAND ${generator_command}
+ DEPENDS ${generator_dependencies}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- COMMENT "Generating version linker script"
- VERBATIM)
- target_link_options("${target}" PRIVATE "-Wl,--version-script,${outfile}")
+ COMMENT "Generating version linker script for target ${target}"
+ VERBATIM
+ )
+ add_custom_target(${target}_version_script DEPENDS ${outfile})
+ add_dependencies(${target} ${target}_version_script)
+ target_link_options(${target} PRIVATE "-Wl,--version-script,${outfile}")
endif()
endfunction()