summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-08-03 15:22:50 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-08-05 15:26:13 +0000
commit5f4dc9cd3a6db18a79f14efd88a5e7a9bf6e129a (patch)
tree1d03cff239b86374b9b5b3770274a8f8e0270b5c /cmake
parent010f977f9b53940ef535284c835ff247863b4b2a (diff)
CMake: Fix Ninja Multi-Config dependency issues for top-level targets
When building qtsvg examples as external projects on Windows with Ninja Multi-Config in a prefix build on the CI, the build would fail with an error message like: ninja: error: 'C:/Users/qt/work/qt/qtsvg/lib/Qt6SvgWidgets.lib', needed by 'RelWithDebInfo/svgviewer.exe', missing and no known rule to make it This can be reproduced locally on Windows if one calls 'ninja svgviewer' instead of just 'ninja'. I wasn't able to reproduce it on macOS, although I have seen some peculiarities in the dependencies there as well. External project examples depend on the ${repo_name}_src custom target to ensure all Qt modules are built, so one would expect that dependency to be sufficient. While trying to figure out what's going wrong, I noticed that running 'ninja -t query qtsvg_src:Debug' showed dependencies on Release libraries, which should not happen. The :Release target looked fine though. I'm still not quite sure why the Release libraries are not built on the first ninja run, despite the example having a proper dependency on qtsvg:Release. Running 'ninja svgviewer' a few more times ends up succeeding at one point, because the SvgWidgets Release library does get built in parallel with the failing example, and the next rebuild would succeed. While trying to fix the :Debug target to have proper dependencies, I noticed that we add dependencies to the ${repo_name}_src custom target via the DEPENDS option of add_custom_target(). That is incorrect, that option should only be used for file level dependencies. For target dependencies, add_dependencies should be used. Doing that fixed both the :Debug dependencies as well as the Windows issue, which is good enough for me. Amends 08f46bb40075778e89ba9aed3cef53d990852022 Task-number: QTBUG-90820 Task-number: QTBUG-96232 Change-Id: I1888681e2e9362d3237acbdacc83222d6a60b48e Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 0e2f218ee7b7ff96cc227f743aa6df11b86a74fa) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsConfig.cmake8
1 files changed, 5 insertions, 3 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
index 4c4adaac0f..0d8e6754b4 100644
--- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
+++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
@@ -281,15 +281,17 @@ function(qt_build_internals_add_toplevel_targets)
set(qt_repo_target_name "${qt_repo_targets_name}_${qt_repo_target_basename}")
message(DEBUG "${qt_repo_target_name} depends on ${qt_repo_targets}")
add_custom_target("${qt_repo_target_name}"
- DEPENDS ${qt_repo_targets}
- COMMENT "Building everything in ${qt_repo_targets_name}/${qt_repo_target_basename}")
+ COMMENT "Building everything in ${qt_repo_targets_name}/${qt_repo_target_basename}")
+ add_dependencies("${qt_repo_target_name}" ${qt_repo_targets})
list(APPEND qt_repo_target_all "${qt_repo_target_name}")
endif()
endforeach()
if (qt_repo_target_all)
+ # Note qt_repo_targets_name is different from qt_repo_target_name that is used above.
add_custom_target("${qt_repo_targets_name}"
- DEPENDS ${qt_repo_target_all}
COMMENT "Building everything in ${qt_repo_targets_name}")
+ add_dependencies("${qt_repo_targets_name}" ${qt_repo_target_all})
+ message(DEBUG "${qt_repo_targets_name} depends on ${qt_repo_target_all}")
endif()
endfunction()