diff mbox series

[08/10] cmake (Windows): initialize vcpkg/build dependencies automatically

Message ID 3a07bd4916c3949eadaa10fde142fba0acaa974b.1601044118.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series CMake and Visual Studio | expand

Commit Message

Jean-Noël Avila via GitGitGadget Sept. 25, 2020, 2:28 p.m. UTC
From: Johannes Schindelin <johannes.schindelin@gmx.de>

The idea of having CMake support in Git's source tree is to enable
contributors on Windows to start contributing with little effort. To
that end, we just added some sensible defaults that will let users open
the worktree in Visual Studio and start building.

This expects the dependencies (such as zlib) to be available already,
though. If they are not available, we expect the user to run
`compat/vcbuild/vcpkg_install.bat`.

Rather than requiring this step to be manual, detect the situation and
run it as part of the CMake configuration step.

This concludes our journey to make it as effortless as possible to start
developing Git in Visual Studio: all the developer needs to do is to
clone Git's repository, open the worktree via `File>Open>Folder...` and
wait for CMake to finish configuring.

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

Comments

Sibi Siddharthan Sept. 30, 2020, 5:05 a.m. UTC | #1
On Fri, Sep 25, 2020 at 7:58 PM Johannes Schindelin via GitGitGadget
<gitgitgadget@gmail.com> wrote:
>
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> The idea of having CMake support in Git's source tree is to enable
> contributors on Windows to start contributing with little effort. To
> that end, we just added some sensible defaults that will let users open
> the worktree in Visual Studio and start building.
>
> This expects the dependencies (such as zlib) to be available already,
> though. If they are not available, we expect the user to run
> `compat/vcbuild/vcpkg_install.bat`.
>
> Rather than requiring this step to be manual, detect the situation and
> run it as part of the CMake configuration step.
>
> This concludes our journey to make it as effortless as possible to start
> developing Git in Visual Studio: all the developer needs to do is to
> clone Git's repository, open the worktree via `File>Open>Folder...` and
> wait for CMake to finish configuring.
>
> 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 d21849b730..1eaeb8b8e0 100644
> --- a/contrib/buildsystems/CMakeLists.txt
> +++ b/contrib/buildsystems/CMakeLists.txt
> @@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)
>  set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
>  if(WIN32)
>         set(VCPKG_DIR "${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg")
> +       if(NOT EXISTS ${VCPKG_DIR})
> +               message("Initializinge vcpkg and building the Git's dependencies (this will take a while...)")
> +               execute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat)
> +       endif()
>         list(APPEND CMAKE_PREFIX_PATH "${VCPKG_DIR}/installed/x64-windows")
>
>         # In the vcpkg edition, we need this to be able to link to libcurl
> --
> gitgitgadget
>

After reading the patch series I seem to get to feeling that people on
Windows are being nudged to use Visual Studio and vcpkg.
Although they are great tools, when I want to specify my own libraries
I don't see an option here.
I think we need to define a variable, which this conditional block
uses, which is set to true if we are using a Visual Studio Generator.
We also need a way to override this option if needed.
If this variable(explained above) is not set or false or OFF, we defer
building vcpkg libraries. This can also save time in the case
when we already have the dependencies(libraries) and just want to
point to them instead of building with vcpkg.
I also see that people who use gcc(MinGW) are left out. I think we
also need to set the supported compiler(s) here before executing
vcpkg_install.bat. People who use gcc would need to point to their own
libraries with CMAKE_PREFIX_PATH.

Thank You,
Sibi Siddharthan
Johannes Schindelin Sept. 30, 2020, 3:25 p.m. UTC | #2
Hi Sibi,

On Wed, 30 Sep 2020, Sibi Siddharthan wrote:

> On Fri, Sep 25, 2020 at 7:58 PM Johannes Schindelin via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
> >
> > From: Johannes Schindelin <johannes.schindelin@gmx.de>
> >
> > The idea of having CMake support in Git's source tree is to enable
> > contributors on Windows to start contributing with little effort. To
> > that end, we just added some sensible defaults that will let users open
> > the worktree in Visual Studio and start building.
> >
> > This expects the dependencies (such as zlib) to be available already,
> > though. If they are not available, we expect the user to run
> > `compat/vcbuild/vcpkg_install.bat`.
> >
> > Rather than requiring this step to be manual, detect the situation and
> > run it as part of the CMake configuration step.
> >
> > This concludes our journey to make it as effortless as possible to start
> > developing Git in Visual Studio: all the developer needs to do is to
> > clone Git's repository, open the worktree via `File>Open>Folder...` and
> > wait for CMake to finish configuring.
> >
> > 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 d21849b730..1eaeb8b8e0 100644
> > --- a/contrib/buildsystems/CMakeLists.txt
> > +++ b/contrib/buildsystems/CMakeLists.txt
> > @@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)
> >  set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
> >  if(WIN32)
> >         set(VCPKG_DIR "${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg")
> > +       if(NOT EXISTS ${VCPKG_DIR})
> > +               message("Initializinge vcpkg and building the Git's dependencies (this will take a while...)")
> > +               execute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat)
> > +       endif()
> >         list(APPEND CMAKE_PREFIX_PATH "${VCPKG_DIR}/installed/x64-windows")
> >
> >         # In the vcpkg edition, we need this to be able to link to libcurl
> > --
> > gitgitgadget
> >
>
> After reading the patch series I seem to get to feeling that people on
> Windows are being nudged to use Visual Studio and vcpkg.
> Although they are great tools, when I want to specify my own libraries
> I don't see an option here.
> I think we need to define a variable, which this conditional block
> uses, which is set to true if we are using a Visual Studio Generator.
> We also need a way to override this option if needed.
> If this variable(explained above) is not set or false or OFF, we defer
> building vcpkg libraries. This can also save time in the case
> when we already have the dependencies(libraries) and just want to
> point to them instead of building with vcpkg.
> I also see that people who use gcc(MinGW) are left out. I think we
> also need to set the supported compiler(s) here before executing
> vcpkg_install.bat. People who use gcc would need to point to their own
> libraries with CMAKE_PREFIX_PATH.

Good points, even if our current CMake push really tries to cater only to
Visual Studio (or at least, MS Visual C) users.

I added a further guard to the conditional: `MSVC` needs to be true. This
makes sense, as our current support for MSVC/Visual Studio hinges on
having vcpkg build the dependencies, we simply do not support anything
else. (And it would be easy enough for a proficient Visual Studio user to
_still_ override the vcpkg system with their own libraries, if they
really want to make that work.)

Thanks,
Dscho
diff mbox series

Patch

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index d21849b730..1eaeb8b8e0 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -42,6 +42,10 @@  cmake_minimum_required(VERSION 3.14)
 set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
 if(WIN32)
 	set(VCPKG_DIR "${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg")
+	if(NOT EXISTS ${VCPKG_DIR})
+		message("Initializinge vcpkg and building the Git's dependencies (this will take a while...)")
+		execute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat)
+	endif()
 	list(APPEND CMAKE_PREFIX_PATH "${VCPKG_DIR}/installed/x64-windows")
 
 	# In the vcpkg edition, we need this to be able to link to libcurl