diff options
author | fuzzard <fuzzard@kodi.tv> | 2024-07-08 20:30:58 +1000 |
---|---|---|
committer | fuzzard <fuzzard@kodi.tv> | 2024-07-09 20:46:38 +1000 |
commit | 3f5848989c460f36445033306e0a24cedc3ce4bc (patch) | |
tree | 60d29796ba14b74a34872376cf1562b4303c0264 | |
parent | d7876de3e6d9045941cc12eb4150248e01c1ea64 (diff) |
[cmake] create function to add dependency to a target
A target may not always use target_link_libraries to create dependency chains.
export-files is an example, and we want to make sure it has a dependency on all libs to
be acquired/built before trying to execute the export-files script
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | cmake/scripts/common/Macros.cmake | 18 |
2 files changed, 20 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f6ba1e9097..0ef3151592 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -509,6 +509,8 @@ add_custom_target(gen_skin_pack DEPENDS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/${ add_custom_target(generate-packaging ALL DEPENDS TexturePacker::TexturePacker::Executable export-files gen_skin_pack gen_system_addons) +core_target_add_dependencies(export-files) + # Add to lib${APP_NAME_LC} solely for Win UWP. msix building doesnt seem to pick up the # generated buildtree if we do it later. Other platforms dont care when this happens. add_dependencies(lib${APP_NAME_LC} generate-packaging) diff --git a/cmake/scripts/common/Macros.cmake b/cmake/scripts/common/Macros.cmake index e3ae5ed9b1..987301cb22 100644 --- a/cmake/scripts/common/Macros.cmake +++ b/cmake/scripts/common/Macros.cmake @@ -797,3 +797,21 @@ function(core_target_link_libraries core_lib) endif() endforeach() endfunction() + +# Iterate over optional/required dep lists and create dependency +# to the target supplied as first argument +function(core_target_add_dependencies core_target) + foreach(_depspec ${required_deps}) + split_dependency_specification(${_depspec} dep version) + if(TARGET ${APP_NAME_LC}::${dep}) + add_dependencies(${core_target} ${APP_NAME_LC}::${dep}) + endif() + endforeach() + + foreach(_depspec ${optional_deps}) + split_dependency_specification(${_depspec} dep version) + if(TARGET ${APP_NAME_LC}::${dep}) + add_dependencies(${core_target} ${APP_NAME_LC}::${dep}) + endif() + endforeach() +endfunction() |