git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/4] cmake: learn to optionally skip linking dashed built-ins
@ 2021-03-27 23:06 Johannes Schindelin via GitGitGadget
  2021-03-27 23:06 ` [PATCH 1/4] cmake: support SKIP_DASHED_BUILT_INS Johannes Schindelin via GitGitGadget
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2021-03-27 23:06 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin

In Git for Windows, we would like to make use of the fact that our
CMake-based build can also install the files into their final location. This
patch series helps with that.

Dennis Ameling (2):
  cmake(install): fix double .exe suffixes
  cmake(install): include vcpkg dlls

Johannes Schindelin (2):
  cmake: support SKIP_DASHED_BUILT_INS
  cmake: add a preparatory work-around to accommodate `vcpkg`

 .github/workflows/main.yml          |  5 +++++
 contrib/buildsystems/CMakeLists.txt | 26 +++++++++++++++++++-------
 2 files changed, 24 insertions(+), 7 deletions(-)


base-commit: 773e25afc41b1b6533fa9ae2cd825d0b4a697fad
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-887%2Fdscho%2Fskip-dashed-built-ins-in-cmake-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-887/dscho/skip-dashed-built-ins-in-cmake-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/887
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/4] cmake: support SKIP_DASHED_BUILT_INS
  2021-03-27 23:06 [PATCH 0/4] cmake: learn to optionally skip linking dashed built-ins Johannes Schindelin via GitGitGadget
@ 2021-03-27 23:06 ` Johannes Schindelin via GitGitGadget
  2021-03-27 23:06 ` [PATCH 2/4] cmake(install): fix double .exe suffixes Dennis Ameling via GitGitGadget
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2021-03-27 23:06 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

Just like the Makefile-based build learned to skip hard-linking the
dashed built-ins in 179227d6e21 (Optionally skip linking/copying the
built-ins, 2020-09-21), this patch teaches the CMake-based build the
same trick.

Note: In contrast to the Makefile-based process, the built-ins would
only be linked during installation, not already when Git is built.
Therefore, the CMake-based build that we use in our CI builds _already_
does not link those built-ins (because the files are not installed
anywhere, they are used to run the test suite in-place).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 contrib/buildsystems/CMakeLists.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index c151dd7257f3..12c40a72bfff 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -685,13 +685,17 @@ endif()
 
 parse_makefile_for_executables(git_builtin_extra "BUILT_INS")
 
+option(SKIP_DASHED_BUILT_INS "Skip hardlinking the dashed versions of the built-ins")
+
 #Creating hardlinks
+if(NOT SKIP_DASHED_BUILT_INS)
 foreach(s ${git_SOURCES} ${git_builtin_extra})
 	string(REPLACE "${CMAKE_SOURCE_DIR}/builtin/" "" s ${s})
 	string(REPLACE ".c" "" s ${s})
 	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\n")
 	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})
 endforeach()
+endif()
 
 if(CURL_FOUND)
 	set(remote_exes
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/4] cmake(install): fix double .exe suffixes
  2021-03-27 23:06 [PATCH 0/4] cmake: learn to optionally skip linking dashed built-ins Johannes Schindelin via GitGitGadget
  2021-03-27 23:06 ` [PATCH 1/4] cmake: support SKIP_DASHED_BUILT_INS Johannes Schindelin via GitGitGadget
@ 2021-03-27 23:06 ` Dennis Ameling via GitGitGadget
  2021-03-27 23:06 ` [PATCH 3/4] cmake: add a preparatory work-around to accommodate `vcpkg` Johannes Schindelin via GitGitGadget
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Dennis Ameling via GitGitGadget @ 2021-03-27 23:06 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Dennis Ameling

From: Dennis Ameling <dennis@dennisameling.com>

By mistake, the `.exe` extension is appended _twice_ when installing the
dashed executables into `libexec/git-core/` on Windows (the extension is
already appended when adding items to the `git_links` list in the
`#Creating hardlinks` section).

Signed-off-by: Dennis Ameling <dennis@dennisameling.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 contrib/buildsystems/CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 12c40a72bfff..da2811ae3aad 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -832,12 +832,12 @@ install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENS
 
 foreach(b ${git_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
 endforeach()
 
 foreach(b ${git_http_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
 endforeach()
 
 install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/4] cmake: add a preparatory work-around to accommodate `vcpkg`
  2021-03-27 23:06 [PATCH 0/4] cmake: learn to optionally skip linking dashed built-ins Johannes Schindelin via GitGitGadget
  2021-03-27 23:06 ` [PATCH 1/4] cmake: support SKIP_DASHED_BUILT_INS Johannes Schindelin via GitGitGadget
  2021-03-27 23:06 ` [PATCH 2/4] cmake(install): fix double .exe suffixes Dennis Ameling via GitGitGadget
@ 2021-03-27 23:06 ` Johannes Schindelin via GitGitGadget
  2021-03-28  3:19   ` Đoàn Trần Công Danh
  2021-03-27 23:06 ` [PATCH 4/4] cmake(install): include vcpkg dlls Dennis Ameling via GitGitGadget
  2021-03-29 12:41 ` [PATCH v2 0/4] cmake: learn to optionally skip linking dashed built-ins Johannes Schindelin via GitGitGadget
  4 siblings, 1 reply; 12+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2021-03-27 23:06 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

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..a166be0eb1b8 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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/4] cmake(install): include vcpkg dlls
  2021-03-27 23:06 [PATCH 0/4] cmake: learn to optionally skip linking dashed built-ins Johannes Schindelin via GitGitGadget
                   ` (2 preceding siblings ...)
  2021-03-27 23:06 ` [PATCH 3/4] cmake: add a preparatory work-around to accommodate `vcpkg` Johannes Schindelin via GitGitGadget
@ 2021-03-27 23:06 ` Dennis Ameling via GitGitGadget
  2021-03-29 12:41 ` [PATCH v2 0/4] cmake: learn to optionally skip linking dashed built-ins Johannes Schindelin via GitGitGadget
  4 siblings, 0 replies; 12+ messages in thread
From: Dennis Ameling via GitGitGadget @ 2021-03-27 23:06 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Dennis Ameling

From: Dennis Ameling <dennis@dennisameling.com>

Our CMake configuration generates not only build definitions, but also
install definitions: After building Git using `msbuild git.sln`, the
built artifacts can be installed via `msbuild INSTALL.vcxproj`.

To specify _where_ the files should be installed, the
`-DCMAKE_INSTALL_PREFIX=<path>` option can be used when running CMake.

However, this process would really only install the files that were just
built. On Windows, we need more than that: We also need the `.dll` files
of the dependencies (such as libcurl). The `vcpkg` ecosystem, which we
use to obtain those dependencies, can be asked to install said `.dll`
files really easily, so let's do that.

This requires more than just the built `vcpkg` artifacts in the CI build
definition; We now clone the `vcpkg` repository so that the relevant
CMake scripts are available, in particular the ones related to defining
the toolchain.

Signed-off-by: Dennis Ameling <dennis@dennisameling.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 .github/workflows/main.yml          | 5 +++++
 contrib/buildsystems/CMakeLists.txt | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index f6885e88ee6b..c13afe2bf058 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -186,6 +186,11 @@ jobs:
         ## Unzip and remove the artifact
         unzip artifacts.zip
         rm artifacts.zip
+    - name: initialize vcpkg
+      uses: actions/checkout@v2
+      with:
+        repository: 'microsoft/vcpkg'
+        path: 'compat/vcbuild/vcpkg'
     - name: download vcpkg artifacts
       shell: powershell
       run: |
diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index a166be0eb1b8..98b2507f222e 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -58,6 +58,10 @@ if(WIN32)
 
 	# In the vcpkg edition, we need this to be able to link to libcurl
 	set(CURL_NO_CURL_CMAKE ON)
+
+	# Copy the necessary vcpkg DLLs (like iconv) to the install dir
+	set(X_VCPKG_APPLOCAL_DEPS_INSTALL ON)
+	set(CMAKE_TOOLCHAIN_FILE ${VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake CACHE STRING "Vcpkg toolchain file")
 endif()
 
 find_program(SH_EXE sh PATHS "C:/Program Files/Git/bin")
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/4] cmake: add a preparatory work-around to accommodate `vcpkg`
  2021-03-27 23:06 ` [PATCH 3/4] cmake: add a preparatory work-around to accommodate `vcpkg` Johannes Schindelin via GitGitGadget
@ 2021-03-28  3:19   ` Đoàn Trần Công Danh
  2021-03-29 13:36     ` Johannes Schindelin
  0 siblings, 1 reply; 12+ messages in thread
From: Đoàn Trần Công Danh @ 2021-03-28  3:19 UTC (permalink / raw)
  To: Johannes Schindelin via GitGitGadget; +Cc: git, Johannes Schindelin

On 2021-03-27 23:06:24+0000, Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com> wrote:
> 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..a166be0eb1b8 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)

Please don't use `${}` around variable inside `if()`, and quote the
string. CMake has a quirk with the `${}` inside if (expanded variable
will be treated as a variable if it is defined, or string otherwise).
Unquoted string will be seen as a variable if it's defined, string
otherwise. IOW, suggested command:

	if (program STREQUAL "git" OR program STREQUAL "git-shell")

We also have another problem with quoted arguments could be interpreted
as variable or keyword if CMP0054 policy not enabled, too.
I think it's better to have it enabled, but it's not in the scope of
this patch.

 https://cmake.org/cmake/help/latest/policy/CMP0054.html


-- 
Danh

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 0/4] cmake: learn to optionally skip linking dashed built-ins
  2021-03-27 23:06 [PATCH 0/4] cmake: learn to optionally skip linking dashed built-ins Johannes Schindelin via GitGitGadget
                   ` (3 preceding siblings ...)
  2021-03-27 23:06 ` [PATCH 4/4] cmake(install): include vcpkg dlls Dennis Ameling via GitGitGadget
@ 2021-03-29 12:41 ` Johannes Schindelin via GitGitGadget
  2021-03-29 12:41   ` [PATCH v2 1/4] cmake: support SKIP_DASHED_BUILT_INS Johannes Schindelin via GitGitGadget
                     ` (3 more replies)
  4 siblings, 4 replies; 12+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2021-03-29 12:41 UTC (permalink / raw)
  To: git; +Cc: Đoàn Trần Công Danh, Johannes Schindelin

In Git for Windows, we would like to make use of the fact that our
CMake-based build can also install the files into their final location. This
patch series helps with that.

Changes since v1:

 * Use proper string/variable CMake syntax, as pointed out by Danh

Dennis Ameling (2):
  cmake(install): fix double .exe suffixes
  cmake(install): include vcpkg dlls

Johannes Schindelin (2):
  cmake: support SKIP_DASHED_BUILT_INS
  cmake: add a preparatory work-around to accommodate `vcpkg`

 .github/workflows/main.yml          |  5 +++++
 contrib/buildsystems/CMakeLists.txt | 26 +++++++++++++++++++-------
 2 files changed, 24 insertions(+), 7 deletions(-)


base-commit: 773e25afc41b1b6533fa9ae2cd825d0b4a697fad
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-887%2Fdscho%2Fskip-dashed-built-ins-in-cmake-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-887/dscho/skip-dashed-built-ins-in-cmake-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/887

Range-diff vs v1:

 1:  ff7e8121d7a4 = 1:  ff7e8121d7a4 cmake: support SKIP_DASHED_BUILT_INS
 2:  69856f278645 = 2:  69856f278645 cmake(install): fix double .exe suffixes
 3:  543fd0f5d7e5 ! 3:  5d953a21e9bd cmake: add a preparatory work-around to accommodate `vcpkg`
     @@ contrib/buildsystems/CMakeLists.txt: list(TRANSFORM git_shell_scripts PREPEND "$
       #install
      -install(TARGETS git git-shell
      +foreach(program ${PROGRAMS_BUILT})
     -+if(${program} STREQUAL git OR ${program} STREQUAL git-shell)
     ++if(program STREQUAL "git" OR program STREQUAL "git-shell")
      +install(TARGETS ${program}
       	RUNTIME DESTINATION bin)
      +else()
 4:  4b183c7def58 = 4:  f020cb517dfc cmake(install): include vcpkg dlls

-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 1/4] cmake: support SKIP_DASHED_BUILT_INS
  2021-03-29 12:41 ` [PATCH v2 0/4] cmake: learn to optionally skip linking dashed built-ins Johannes Schindelin via GitGitGadget
@ 2021-03-29 12:41   ` Johannes Schindelin via GitGitGadget
  2021-03-29 12:41   ` [PATCH v2 2/4] cmake(install): fix double .exe suffixes Dennis Ameling via GitGitGadget
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2021-03-29 12:41 UTC (permalink / raw)
  To: git
  Cc: Đoàn Trần Công Danh, Johannes Schindelin,
	Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

Just like the Makefile-based build learned to skip hard-linking the
dashed built-ins in 179227d6e21 (Optionally skip linking/copying the
built-ins, 2020-09-21), this patch teaches the CMake-based build the
same trick.

Note: In contrast to the Makefile-based process, the built-ins would
only be linked during installation, not already when Git is built.
Therefore, the CMake-based build that we use in our CI builds _already_
does not link those built-ins (because the files are not installed
anywhere, they are used to run the test suite in-place).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 contrib/buildsystems/CMakeLists.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index c151dd7257f3..12c40a72bfff 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -685,13 +685,17 @@ endif()
 
 parse_makefile_for_executables(git_builtin_extra "BUILT_INS")
 
+option(SKIP_DASHED_BUILT_INS "Skip hardlinking the dashed versions of the built-ins")
+
 #Creating hardlinks
+if(NOT SKIP_DASHED_BUILT_INS)
 foreach(s ${git_SOURCES} ${git_builtin_extra})
 	string(REPLACE "${CMAKE_SOURCE_DIR}/builtin/" "" s ${s})
 	string(REPLACE ".c" "" s ${s})
 	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\n")
 	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})
 endforeach()
+endif()
 
 if(CURL_FOUND)
 	set(remote_exes
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 2/4] cmake(install): fix double .exe suffixes
  2021-03-29 12:41 ` [PATCH v2 0/4] cmake: learn to optionally skip linking dashed built-ins Johannes Schindelin via GitGitGadget
  2021-03-29 12:41   ` [PATCH v2 1/4] cmake: support SKIP_DASHED_BUILT_INS Johannes Schindelin via GitGitGadget
@ 2021-03-29 12:41   ` Dennis Ameling via GitGitGadget
  2021-03-29 12:41   ` [PATCH v2 3/4] cmake: add a preparatory work-around to accommodate `vcpkg` Johannes Schindelin via GitGitGadget
  2021-03-29 12:41   ` [PATCH v2 4/4] cmake(install): include vcpkg dlls Dennis Ameling via GitGitGadget
  3 siblings, 0 replies; 12+ messages in thread
From: Dennis Ameling via GitGitGadget @ 2021-03-29 12:41 UTC (permalink / raw)
  To: git
  Cc: Đoàn Trần Công Danh, Johannes Schindelin,
	Dennis Ameling

From: Dennis Ameling <dennis@dennisameling.com>

By mistake, the `.exe` extension is appended _twice_ when installing the
dashed executables into `libexec/git-core/` on Windows (the extension is
already appended when adding items to the `git_links` list in the
`#Creating hardlinks` section).

Signed-off-by: Dennis Ameling <dennis@dennisameling.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 contrib/buildsystems/CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 12c40a72bfff..da2811ae3aad 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -832,12 +832,12 @@ install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENS
 
 foreach(b ${git_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
 endforeach()
 
 foreach(b ${git_http_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
 endforeach()
 
 install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 3/4] cmake: add a preparatory work-around to accommodate `vcpkg`
  2021-03-29 12:41 ` [PATCH v2 0/4] cmake: learn to optionally skip linking dashed built-ins Johannes Schindelin via GitGitGadget
  2021-03-29 12:41   ` [PATCH v2 1/4] cmake: support SKIP_DASHED_BUILT_INS Johannes Schindelin via GitGitGadget
  2021-03-29 12:41   ` [PATCH v2 2/4] cmake(install): fix double .exe suffixes Dennis Ameling via GitGitGadget
@ 2021-03-29 12:41   ` Johannes Schindelin via GitGitGadget
  2021-03-29 12:41   ` [PATCH v2 4/4] cmake(install): include vcpkg dlls Dennis Ameling via GitGitGadget
  3 siblings, 0 replies; 12+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2021-03-29 12:41 UTC (permalink / raw)
  To: git
  Cc: Đoàn Trần Công Danh, Johannes Schindelin,
	Johannes Schindelin

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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 4/4] cmake(install): include vcpkg dlls
  2021-03-29 12:41 ` [PATCH v2 0/4] cmake: learn to optionally skip linking dashed built-ins Johannes Schindelin via GitGitGadget
                     ` (2 preceding siblings ...)
  2021-03-29 12:41   ` [PATCH v2 3/4] cmake: add a preparatory work-around to accommodate `vcpkg` Johannes Schindelin via GitGitGadget
@ 2021-03-29 12:41   ` Dennis Ameling via GitGitGadget
  3 siblings, 0 replies; 12+ messages in thread
From: Dennis Ameling via GitGitGadget @ 2021-03-29 12:41 UTC (permalink / raw)
  To: git
  Cc: Đoàn Trần Công Danh, Johannes Schindelin,
	Dennis Ameling

From: Dennis Ameling <dennis@dennisameling.com>

Our CMake configuration generates not only build definitions, but also
install definitions: After building Git using `msbuild git.sln`, the
built artifacts can be installed via `msbuild INSTALL.vcxproj`.

To specify _where_ the files should be installed, the
`-DCMAKE_INSTALL_PREFIX=<path>` option can be used when running CMake.

However, this process would really only install the files that were just
built. On Windows, we need more than that: We also need the `.dll` files
of the dependencies (such as libcurl). The `vcpkg` ecosystem, which we
use to obtain those dependencies, can be asked to install said `.dll`
files really easily, so let's do that.

This requires more than just the built `vcpkg` artifacts in the CI build
definition; We now clone the `vcpkg` repository so that the relevant
CMake scripts are available, in particular the ones related to defining
the toolchain.

Signed-off-by: Dennis Ameling <dennis@dennisameling.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 .github/workflows/main.yml          | 5 +++++
 contrib/buildsystems/CMakeLists.txt | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index f6885e88ee6b..c13afe2bf058 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -186,6 +186,11 @@ jobs:
         ## Unzip and remove the artifact
         unzip artifacts.zip
         rm artifacts.zip
+    - name: initialize vcpkg
+      uses: actions/checkout@v2
+      with:
+        repository: 'microsoft/vcpkg'
+        path: 'compat/vcbuild/vcpkg'
     - name: download vcpkg artifacts
       shell: powershell
       run: |
diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 3b94b5f62109..485c7662dc58 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -58,6 +58,10 @@ if(WIN32)
 
 	# In the vcpkg edition, we need this to be able to link to libcurl
 	set(CURL_NO_CURL_CMAKE ON)
+
+	# Copy the necessary vcpkg DLLs (like iconv) to the install dir
+	set(X_VCPKG_APPLOCAL_DEPS_INSTALL ON)
+	set(CMAKE_TOOLCHAIN_FILE ${VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake CACHE STRING "Vcpkg toolchain file")
 endif()
 
 find_program(SH_EXE sh PATHS "C:/Program Files/Git/bin")
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/4] cmake: add a preparatory work-around to accommodate `vcpkg`
  2021-03-28  3:19   ` Đoàn Trần Công Danh
@ 2021-03-29 13:36     ` Johannes Schindelin
  0 siblings, 0 replies; 12+ messages in thread
From: Johannes Schindelin @ 2021-03-29 13:36 UTC (permalink / raw)
  To: Đoàn Trần Công Danh
  Cc: Johannes Schindelin via GitGitGadget, git

[-- Attachment #1: Type: text/plain, Size: 2903 bytes --]

Hi Danh,

On Sun, 28 Mar 2021, Đoàn Trần Công Danh wrote:

> On 2021-03-27 23:06:24+0000, Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com> wrote:
> > 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..a166be0eb1b8 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)
>
> Please don't use `${}` around variable inside `if()`, and quote the
> string. CMake has a quirk with the `${}` inside if (expanded variable
> will be treated as a variable if it is defined, or string otherwise).
> Unquoted string will be seen as a variable if it's defined, string
> otherwise. IOW, suggested command:
>
> 	if (program STREQUAL "git" OR program STREQUAL "git-shell")
>
> We also have another problem with quoted arguments could be interpreted
> as variable or keyword if CMP0054 policy not enabled, too.
> I think it's better to have it enabled, but it's not in the scope of
> this patch.
>
>  https://cmake.org/cmake/help/latest/policy/CMP0054.html

Thank you for this information! I've sent out v2 based on your suggestion.

Thanks,
Dscho

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-03-29 13:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-27 23:06 [PATCH 0/4] cmake: learn to optionally skip linking dashed built-ins Johannes Schindelin via GitGitGadget
2021-03-27 23:06 ` [PATCH 1/4] cmake: support SKIP_DASHED_BUILT_INS Johannes Schindelin via GitGitGadget
2021-03-27 23:06 ` [PATCH 2/4] cmake(install): fix double .exe suffixes Dennis Ameling via GitGitGadget
2021-03-27 23:06 ` [PATCH 3/4] cmake: add a preparatory work-around to accommodate `vcpkg` Johannes Schindelin via GitGitGadget
2021-03-28  3:19   ` Đoàn Trần Công Danh
2021-03-29 13:36     ` Johannes Schindelin
2021-03-27 23:06 ` [PATCH 4/4] cmake(install): include vcpkg dlls Dennis Ameling via GitGitGadget
2021-03-29 12:41 ` [PATCH v2 0/4] cmake: learn to optionally skip linking dashed built-ins Johannes Schindelin via GitGitGadget
2021-03-29 12:41   ` [PATCH v2 1/4] cmake: support SKIP_DASHED_BUILT_INS Johannes Schindelin via GitGitGadget
2021-03-29 12:41   ` [PATCH v2 2/4] cmake(install): fix double .exe suffixes Dennis Ameling via GitGitGadget
2021-03-29 12:41   ` [PATCH v2 3/4] cmake: add a preparatory work-around to accommodate `vcpkg` Johannes Schindelin via GitGitGadget
2021-03-29 12:41   ` [PATCH v2 4/4] cmake(install): include vcpkg dlls Dennis Ameling via GitGitGadget

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).