@@ -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.
@@ -67,7 +74,27 @@ if(NOT DEFINED CMAKE_EXPORT_COMPILE_COMMANDS)
67
74
endif ()
68
75
69
76
if (USE_VCPKG)
70
- set (VCPKG_DIR "${CMAKE_SOURCE_DIR} /compat/vcbuild/vcpkg" )
77
+ if (NOT DEFINED VCPKG_DIR)
78
+ if (DEFINED ENV{VCPKG_ROOT})
79
+ set (VCPKG_DIR "$ENV{VCPKG_ROOT} " )
80
+ else ()
81
+ set (VCPKG_DIR "${CMAKE_SOURCE_DIR} /compat/vcbuild/vcpkg" )
82
+ endif ()
83
+
84
+ # Make sure ENV{VCPKG_ROOT} is set for vcpkg_install.bat
85
+ # and anything else that may need it.
86
+ set (ENV{VCPKG_ROOT} "${VCPKG_DIR} " )
87
+ endif ()
88
+
89
+ if (NOT DEFINED VCPKG_ARCH)
90
+ if (DEFINED VCPKG_TARGET_TRIPLET)
91
+ set (VCPKG_ARCH "${VCPKG_TARGET_TRIPLET} " )
92
+ else ()
93
+ message ("VCPKG_ARCH: unset, using 'x64-windows'" )
94
+ set (VCPKG_ARCH "x64-windows" )
95
+ endif ()
96
+ endif ()
97
+
71
98
message ("WIN32: ${WIN32} " ) # show its underlying text values
72
99
message ("VCPKG_DIR: ${VCPKG_DIR} " )
73
100
message ("VCPKG_ARCH: ${VCPKG_ARCH} " ) # maybe unset
@@ -77,14 +104,8 @@ if(USE_VCPKG)
77
104
message ("CMAKE_GENERATOR_PLATFORM: ${CMAKE_GENERATOR_PLATFORM} " )
78
105
message ("CMAKE_EXPORT_COMPILE_COMMANDS: ${CMAKE_EXPORT_COMPILE_COMMANDS} " )
79
106
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 ()
107
+ message ("Initializing vcpkg and building the Git's dependencies (this may take a while...)" )
108
+ execute_process (COMMAND ${CMAKE_SOURCE_DIR} /compat/vcbuild/vcpkg_install.bat ${VCPKG_ARCH} )
88
109
list (APPEND CMAKE_PREFIX_PATH "${VCPKG_DIR} /installed/${VCPKG_ARCH} " )
89
110
90
111
# In the vcpkg edition, we need this to be able to link to libcurl
@@ -207,19 +228,50 @@ if(WIN32 AND NOT MSVC)#not required for visual studio builds
207
228
endif ()
208
229
endif ()
209
230
210
- if (NO_GETTEXT)
211
- message (STATUS "msgfmt not used under NO_GETTEXT" )
212
- else ()
231
+ macro (get_nuget)
232
+ if (NOT EXISTS ${CMAKE_BINARY_DIR} /nuget.exe)
233
+ file (DOWNLOAD "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" ${CMAKE_BINARY_DIR} /nuget.exe)
234
+ endif ()
235
+
236
+ # Add nuget package source.
237
+ execute_process (
238
+ COMMAND nuget sources add -Name "NuGet official package source" -Source "https://api.nuget.org/v3/index.json"
239
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
240
+ )
241
+ endmacro ()
242
+
243
+ macro (nuget_install pkg)
244
+ execute_process (
245
+ COMMAND nuget.exe install ${pkg} -OutputDirectory ${CMAKE_BINARY_DIR} /nuget
246
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
247
+ )
248
+
249
+ # Find the path to the binaries in the package and add them to find path.
250
+ file (GLOB pkg_dir ${CMAKE_BINARY_DIR} /nuget/${pkg} *)
251
+
252
+ list (APPEND CMAKE_PROGRAM_PATH ${pkg_dir} /tools/bin)
253
+
254
+ set (CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH} " CACHE STRING "External Program Search Path" FORCE)
255
+ endmacro ()
256
+
257
+ find_program (msgfmt msgfmt)
258
+ if (NOT msgfmt)
259
+ if (WIN32 )
260
+ get_nuget()
261
+ nuget_install(Gettext.Tools)
262
+ endif ()
263
+
213
264
find_program (MSGFMT_EXE msgfmt)
265
+
214
266
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 ()
267
+ message (WARNING "msgfmt not available and/or could not be installed, text translations won't be built." )
222
268
endif ()
269
+ else ()
270
+ set (MSGFMT_EXE ${msgfmt} )
271
+ endif ()
272
+
273
+ if (MSGFMT_EXE)
274
+ set (MSGFMT_EXE ${MSGFMT_EXE} CACHE STRING "gettext msgfmt utility path" FORCE)
223
275
endif ()
224
276
225
277
#Force all visual studio outputs to CMAKE_BINARY_DIR
@@ -813,7 +865,8 @@ endif()
813
865
814
866
add_custom_command (OUTPUT ${git_links} ${git_http_links}
815
867
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR} /CreateLinks.cmake
816
- DEPENDS git git-remote-http)
868
+ DEPENDS git git-remote-http
869
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} )
817
870
add_custom_target (git-links ALL DEPENDS ${git_links} ${git_http_links} )
818
871
819
872
@@ -1074,7 +1127,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PRE
1074
1127
file (APPEND ${CMAKE_BINARY_DIR} /GIT-BUILD -OPTIONS "NO_PYTHON='${NO_PYTHON} '\n " )
1075
1128
file (APPEND ${CMAKE_BINARY_DIR} /GIT-BUILD -OPTIONS "SUPPORTS_SIMPLE_IPC='${SUPPORTS_SIMPLE_IPC} '\n " )
1076
1129
if (USE_VCPKG)
1077
- file (APPEND ${CMAKE_BINARY_DIR} /GIT-BUILD -OPTIONS "PATH=\" $PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg /installed/${VCPKG_ARCH} /bin\"\n " )
1130
+ file (APPEND ${CMAKE_BINARY_DIR} /GIT-BUILD -OPTIONS "PATH=\" $PATH:${VCPKG_DIR} /installed/${VCPKG_ARCH} /bin\"\n " )
1078
1131
endif ()
1079
1132
1080
1133
#Make the tests work when building out of the source tree
0 commit comments