]> git.ipfire.org Git - thirdparty/git.git/commitdiff
cmake: add a preparatory work-around to accommodate `vcpkg`
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 29 Mar 2021 12:41:44 +0000 (12:41 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 29 Mar 2021 20:49:04 +0000 (13:49 -0700)
We are about to add support for installing the `.dll` files of Git's
dependencies (such as libcurl) in the CMake configuration. The `vcpkg`
ecosystem from which we get said dependencies makes that relatively
easy: simply turn on `X_VCPKG_APPLOCAL_DEPS_INSTALL`.

However, current `vcpkg` introduces a limitation if one does that:
While it is totally cool with CMake to specify multiple targets within
one invocation of `install(TARGETS ...) (at least according to
https://cmake.org/cmake/help/latest/command/install.html#command:install),
`vcpkg`'s parser insists on a single target per `install(TARGETS ...)`
invocation.

Well, that's easily accomplished: Let's feed the targets individually to
the `install(TARGETS ...)` function in a `foreach()` look.

This also has the advantage that we do not have to manually cull off the
two entries from the `${PROGRAMS_BUILT}` array before scheduling the
remainder to be installed into `libexec/git-core`. Instead, we iterate
through the array and decide for each entry where it wants to go.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/buildsystems/CMakeLists.txt

index 4a79a9f32636c0bfcf67a86ca1ba533c67fda45c..72e4c5abcd9babd1efd49c615adab0d5ad2125b4 100644 (file)
@@ -811,15 +811,19 @@ list(TRANSFORM git_shell_scripts PREPEND "${CMAKE_BINARY_DIR}/")
 list(TRANSFORM git_perl_scripts PREPEND "${CMAKE_BINARY_DIR}/")
 
 #install
-install(TARGETS git git-shell
+foreach(program ${PROGRAMS_BUILT})
+if(program STREQUAL "git" OR program STREQUAL "git-shell")
+install(TARGETS ${program}
        RUNTIME DESTINATION bin)
+else()
+install(TARGETS ${program}
+       RUNTIME DESTINATION libexec/git-core)
+endif()
+endforeach()
+
 install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver
        DESTINATION bin)
 
-list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)
-install(TARGETS ${PROGRAMS_BUILT}
-       RUNTIME DESTINATION libexec/git-core)
-
 set(bin_links
        git-receive-pack git-upload-archive git-upload-pack)