@@ -44,8 +44,15 @@ This process generates a Makefile(Linux/*BSD/MacOS), Visual Studio solution(Wind
44
44
Run `make` to build Git on Linux/*BSD/MacOS.
45
45
Open git.sln on Windows and build Git.
46
46
47
- NOTE: By default CMake will install vcpkg locally to your source tree on configuration,
48
- to avoid this, add `-DNO_VCPKG=TRUE` to the command line when configuring.
47
+ NOTE: By default CMake will install vcpkg locally to your source tree on
48
+ configuration, to use your own VCPKG tree, set `$env:VCPKG_ROOT` to the
49
+ path or pass `VCPKG_DIR`.
50
+
51
+ To set the vcpkg arch (target triplet) pass `VCPKG_ARCH` e.g.:
52
+ `-DVCPKG_ARCH=x64-windows`.
53
+
54
+ To not use VCPKG, add `-DUSE_VCPKG=FALSE` to the command line when
55
+ configuring.
49
56
50
57
The Visual Studio default generator changed in v16.6 from its Visual Studio
51
58
implemenation to `Ninja` This required changes to many CMake scripts.
@@ -56,6 +63,8 @@ cmake_minimum_required(VERSION 3.14)
56
63
#set the source directory to root of git
57
64
set (CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} /../..)
58
65
66
+ list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} /cmake)
67
+
59
68
option (USE_VCPKG "Whether or not to use vcpkg for obtaining dependencies. Only applicable to Windows platforms" ON )
60
69
if (NOT WIN32 )
61
70
set (USE_VCPKG OFF CACHE BOOL FORCE)
@@ -67,7 +76,27 @@ if(NOT DEFINED CMAKE_EXPORT_COMPILE_COMMANDS)
67
76
endif ()
68
77
69
78
if (USE_VCPKG)
70
- set (VCPKG_DIR "${CMAKE_SOURCE_DIR} /compat/vcbuild/vcpkg" )
79
+ if (NOT DEFINED VCPKG_DIR)
80
+ if (DEFINED ENV{VCPKG_ROOT})
81
+ set (VCPKG_DIR "$ENV{VCPKG_ROOT} " )
82
+ else ()
83
+ set (VCPKG_DIR "${CMAKE_SOURCE_DIR} /compat/vcbuild/vcpkg" )
84
+ endif ()
85
+
86
+ # Make sure ENV{VCPKG_ROOT} is set for vcpkg_install.bat
87
+ # and anything else that may need it.
88
+ set (ENV{VCPKG_ROOT} "${VCPKG_DIR} " )
89
+ endif ()
90
+
91
+ if (NOT DEFINED VCPKG_ARCH)
92
+ if (DEFINED VCPKG_TARGET_TRIPLET)
93
+ set (VCPKG_ARCH "${VCPKG_TARGET_TRIPLET} " )
94
+ else ()
95
+ message ("VCPKG_ARCH: unset, using 'x64-windows'" )
96
+ set (VCPKG_ARCH "x64-windows" )
97
+ endif ()
98
+ endif ()
99
+
71
100
message ("WIN32: ${WIN32} " ) # show its underlying text values
72
101
message ("VCPKG_DIR: ${VCPKG_DIR} " )
73
102
message ("VCPKG_ARCH: ${VCPKG_ARCH} " ) # maybe unset
@@ -77,14 +106,8 @@ if(USE_VCPKG)
77
106
message ("CMAKE_GENERATOR_PLATFORM: ${CMAKE_GENERATOR_PLATFORM} " )
78
107
message ("CMAKE_EXPORT_COMPILE_COMMANDS: ${CMAKE_EXPORT_COMPILE_COMMANDS} " )
79
108
message ("ENV(CMAKE_EXPORT_COMPILE_COMMANDS): $ENV{CMAKE_EXPORT_COMPILE_COMMANDS} " )
80
- if (NOT EXISTS ${VCPKG_DIR} )
81
- message ("Initializing vcpkg and building the Git's dependencies (this will take a while...)" )
82
- execute_process (COMMAND ${CMAKE_SOURCE_DIR} /compat/vcbuild/vcpkg_install.bat ${VCPKG_ARCH} )
83
- 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 ()
109
+ message ("Initializing vcpkg and building the Git's dependencies (this may take a while...)" )
110
+ execute_process (COMMAND ${CMAKE_SOURCE_DIR} /compat/vcbuild/vcpkg_install.bat ${VCPKG_ARCH} )
88
111
list (APPEND CMAKE_PREFIX_PATH "${VCPKG_DIR} /installed/${VCPKG_ARCH} " )
89
112
90
113
# In the vcpkg edition, we need this to be able to link to libcurl
@@ -207,18 +230,22 @@ if(WIN32 AND NOT MSVC)#not required for visual studio builds
207
230
endif ()
208
231
endif ()
209
232
210
- if (NO_GETTEXT)
211
- message (STATUS "msgfmt not used under NO_GETTEXT" )
212
- else ()
233
+
234
+ find_program (MSGFMT_EXE msgfmt)
235
+
236
+ if (NOT MSGFMT_EXE)
237
+ if (WIN32 )
238
+ include (NuGet)
239
+ nuget_install(Gettext.Tools)
240
+ endif ()
241
+
242
+ unset (MSGFMT_EXE)
243
+ unset (MSGFMT_EXE CACHE )
244
+
213
245
find_program (MSGFMT_EXE msgfmt)
246
+
214
247
if (NOT MSGFMT_EXE)
215
- if (USE_VCPKG)
216
- set (MSGFMT_EXE ${CMAKE_SOURCE_DIR} /compat/vcbuild/vcpkg/downloads/tools/msys2/msys64/usr/bin/msgfmt.exe)
217
- endif ()
218
- if (NOT EXISTS ${MSGFMT_EXE} )
219
- message (WARNING "Text Translations won't be built" )
220
- unset (MSGFMT_EXE)
221
- endif ()
248
+ message (WARNING "msgfmt not available and/or could not be installed, text translations won't be built." )
222
249
endif ()
223
250
endif ()
224
251
@@ -813,7 +840,8 @@ endif()
813
840
814
841
add_custom_command (OUTPUT ${git_links} ${git_http_links}
815
842
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR} /CreateLinks.cmake
816
- DEPENDS git git-remote-http)
843
+ DEPENDS git git-remote-http
844
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} )
817
845
add_custom_target (git-links ALL DEPENDS ${git_links} ${git_http_links} )
818
846
819
847
@@ -1074,7 +1102,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PRE
1074
1102
file (APPEND ${CMAKE_BINARY_DIR} /GIT-BUILD -OPTIONS "NO_PYTHON='${NO_PYTHON} '\n " )
1075
1103
file (APPEND ${CMAKE_BINARY_DIR} /GIT-BUILD -OPTIONS "SUPPORTS_SIMPLE_IPC='${SUPPORTS_SIMPLE_IPC} '\n " )
1076
1104
if (USE_VCPKG)
1077
- file (APPEND ${CMAKE_BINARY_DIR} /GIT-BUILD -OPTIONS "PATH=\" $PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg /installed/${VCPKG_ARCH} /bin\"\n " )
1105
+ file (APPEND ${CMAKE_BINARY_DIR} /GIT-BUILD -OPTIONS "PATH=\" $PATH:${VCPKG_DIR} /installed/${VCPKG_ARCH} /bin\"\n " )
1078
1106
endif ()
1079
1107
1080
1108
#Make the tests work when building out of the source tree
@@ -1106,3 +1134,5 @@ foreach(tsh ${test_scipts})
1106
1134
endforeach ()
1107
1135
1108
1136
endif ()#BUILD_TESTING
1137
+
1138
+ # vim:set sw=8 ts=8 noet:
0 commit comments