Skip to content

Commit d9b3f6d

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
Merge pull request #3306 from PhilipOakley/vs-sln
Make Git for Windows start builds in modern Visual Studio
2 parents 9448b7f + 9ac6ce3 commit d9b3f6d

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -251,5 +251,6 @@ Release/
251251
/git.VC.db
252252
*.dSYM
253253
/contrib/buildsystems/out
254+
CMakeSettings.json
254255
/contrib/libgit-rs/target
255256
/contrib/libgit-sys/target

contrib/buildsystems/CMakeLists.txt

+24-6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ Note: Visual Studio also has the option of opening `CMakeLists.txt`
1414
directly; Using this option, Visual Studio will not find the source code,
1515
though, therefore the `File>Open>Folder...` option is preferred.
1616
17+
Visual Studio does not produce a .sln solution file nor the .vcxproj files
18+
that may be required by VS extension tools.
19+
20+
To generate the .sln/.vcxproj files run CMake manually, as described below.
21+
1722
Instructions to run CMake manually:
1823
1924
mkdir -p contrib/buildsystems/out
@@ -22,7 +27,7 @@ Instructions to run CMake manually:
2227
2328
This will build the git binaries in contrib/buildsystems/out
2429
directory (our top-level .gitignore file knows to ignore contents of
25-
this directory).
30+
this directory). The project .sln and .vcxproj files are also generated.
2631
2732
Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
2833
compiler flags
@@ -35,17 +40,16 @@ empty(default) :
3540
NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio
3641
this option is ignored
3742
38-
This process generates a Makefile(Linux/*BSD/MacOS) , Visual Studio solution(Windows) by default.
43+
This process generates a Makefile(Linux/*BSD/MacOS), Visual Studio solution(Windows) by default.
3944
Run `make` to build Git on Linux/*BSD/MacOS.
4045
Open git.sln on Windows and build Git.
4146
42-
NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,
43-
to use another tool say `ninja` add this to the command line when configuring.
44-
`-G Ninja`
45-
4647
NOTE: By default CMake will install vcpkg locally to your source tree on configuration,
4748
to avoid this, add `-DNO_VCPKG=TRUE` to the command line when configuring.
4849
50+
The Visual Studio default generator changed in v16.6 from its Visual Studio
51+
implemenation to `Ninja` This required changes to many CMake scripts.
52+
4953
]]
5054
cmake_minimum_required(VERSION 3.14)
5155

@@ -59,14 +63,28 @@ endif()
5963

6064
if(NOT DEFINED CMAKE_EXPORT_COMPILE_COMMANDS)
6165
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
66+
message("settting CMAKE_EXPORT_COMPILE_COMMANDS: ${CMAKE_EXPORT_COMPILE_COMMANDS}")
6267
endif()
6368

6469
if(USE_VCPKG)
6570
set(VCPKG_DIR "${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg")
71+
message("WIN32: ${WIN32}") # show its underlying text values
72+
message("VCPKG_DIR: ${VCPKG_DIR}")
73+
message("VCPKG_ARCH: ${VCPKG_ARCH}") # maybe unset
74+
message("MSVC: ${MSVC}")
75+
message("CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
76+
message("CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
77+
message("CMAKE_GENERATOR_PLATFORM: ${CMAKE_GENERATOR_PLATFORM}")
78+
message("CMAKE_EXPORT_COMPILE_COMMANDS: ${CMAKE_EXPORT_COMPILE_COMMANDS}")
79+
message("ENV(CMAKE_EXPORT_COMPILE_COMMANDS): $ENV{CMAKE_EXPORT_COMPILE_COMMANDS}")
6680
if(NOT EXISTS ${VCPKG_DIR})
6781
message("Initializing vcpkg and building the Git's dependencies (this will take a while...)")
6882
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat ${VCPKG_ARCH})
6983
endif()
84+
if(NOT EXISTS ${VCPKG_ARCH})
85+
message("VCPKG_ARCH: unset, using 'x64-windows'")
86+
set(VCPKG_ARCH "x64-windows") # default from vcpkg_install.bat
87+
endif()
7088
list(APPEND CMAKE_PREFIX_PATH "${VCPKG_DIR}/installed/${VCPKG_ARCH}")
7189

7290
# In the vcpkg edition, we need this to be able to link to libcurl

0 commit comments

Comments
 (0)