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 08f46bb400
Pick-to: 6.2 6.3 6.4
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I1888681e2e9362d3237acbdacc83222d6a60b48e
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
f9eb2a7bdb
commit
0e2f218ee7
@ -284,15 +284,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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user