git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 3/4] cmake: add a preparatory work-around to accommodate `vcpkg`

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Mar 29, 2021, 12:41 UTC
Message-ID
<5d953a21e9bd6b5da562c9d285159bda2289b4fa.1617021705.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.887.v2.git.1617021705.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

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>
---
 contrib/buildsystems/CMakeLists.txt | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index da2811ae3aad..3b94b5f62109 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -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)
 
-- 
gitgitgadget
Previous: Dennis Ameling via GitGitGadget
Message 12 of 12 in “cmake: learn to optionally skip linking dashed built-ins”
  1. 0/4 cmake: learn to optionally skip linking dashed built-insJohannes Schindelin via GitGitGadget, Mar 27, 2021
  2. 1/4 cmake: support SKIP_DASHED_BUILT_INSJohannes Schindelin via GitGitGadget, Mar 27, 2021
  3. 2/4 cmake(install): fix double .exe suffixesDennis Ameling via GitGitGadget, Mar 27, 2021
  4. 3/4 cmake: add a preparatory work-around to accommodate `vcpkg`Johannes Schindelin via GitGitGadget, Mar 27, 2021
  5. Đoàn Trần Công DanhMar 28, 2021
  6. Johannes SchindelinMar 29, 2021
  7. 4/4 cmake(install): include vcpkg dllsDennis Ameling via GitGitGadget, Mar 27, 2021
  8. 0/4 cmake: learn to optionally skip linking dashed built-insJohannes Schindelin via GitGitGadget, Mar 29, 2021
  9. 1/4 cmake: support SKIP_DASHED_BUILT_INSJohannes Schindelin via GitGitGadget, Mar 29, 2021
  10. 2/4 cmake(install): fix double .exe suffixesDennis Ameling via GitGitGadget, Mar 29, 2021
  11. 4/4 cmake(install): include vcpkg dllsDennis Ameling via GitGitGadget, Mar 29, 2021
  12. 3/4 cmake: add a preparatory work-around to accommodate `vcpkg`Johannes Schindelin via GitGitGadget, Mar 29, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.