4
4
5
5
#[[
6
6
7
- Instructions to run CMake :
7
+ Instructions how to use this in Visual Studio :
8
8
9
- cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release
10
- Eg.
11
- From the root of git source tree
12
- `cmake contrib/buildsystems/ `
13
- This will build the git binaries at the root
9
+ Open the worktree as a folder. Visual Studio 2019 and later will detect
10
+ the CMake configuration automatically and set everything up for you,
11
+ ready to build. You can then run the tests in `t/` via a regular Git Bash.
14
12
15
- For out of source builds, say build in 'git/git-build/'
16
- `mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`
17
- This will build the git binaries in git-build directory
13
+ Note: Visual Studio also has the option of opening `CMakeLists.txt`
14
+ directly; Using this option, Visual Studio will not find the source code,
15
+ though, therefore the `File>Open>Folder...` option is preferred.
16
+
17
+ Instructions to run CMake manually:
18
+
19
+ mkdir -p contrib/buildsystems/out
20
+ cd contrib/buildsystems/out
21
+ cmake ../ -DCMAKE_BUILD_TYPE=Release
22
+
23
+ This will build the git binaries in contrib/buildsystems/out
24
+ directory (our top-level .gitignore file knows to ignore contents of
25
+ this directory).
18
26
19
27
Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
20
28
compiler flags
@@ -40,8 +48,19 @@ cmake_minimum_required(VERSION 3.14)
40
48
41
49
#set the source directory to root of git
42
50
set (CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} /../.. )
51
+ if (WIN32 )
52
+ set (VCPKG_DIR "${CMAKE_SOURCE_DIR} /compat/vcbuild/vcpkg" )
53
+ if (MSVC AND NOT EXISTS ${VCPKG_DIR} )
54
+ message ("Initializing vcpkg and building the Git's dependencies (this will take a while...)" )
55
+ execute_process (COMMAND ${CMAKE_SOURCE_DIR} /compat/vcbuild/vcpkg_install.bat )
56
+ endif ()
57
+ list (APPEND CMAKE_PREFIX_PATH "${VCPKG_DIR} /installed/x64-windows" )
43
58
44
- find_program (SH_EXE sh )
59
+ # In the vcpkg edition, we need this to be able to link to libcurl
60
+ set (CURL_NO_CURL_CMAKE ON )
61
+ endif ()
62
+
63
+ find_program (SH_EXE sh PATHS "C:/Program Files/Git/bin" )
45
64
if (NOT SH_EXE )
46
65
message (FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
47
66
"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/" )
@@ -145,7 +164,11 @@ endif()
145
164
146
165
find_program (MSGFMT_EXE msgfmt )
147
166
if (NOT MSGFMT_EXE )
148
- message (WARNING "Text Translations won't be build" )
167
+ set (MSGFMT_EXE ${CMAKE_SOURCE_DIR} /compat/vcbuild/vcpkg/downloads/tools/msys2/msys64/usr/bin/msgfmt.exe )
168
+ if (NOT EXISTS ${MSGFMT_EXE} )
169
+ message (WARNING "Text Translations won't be built" )
170
+ unset (MSGFMT_EXE )
171
+ endif ()
149
172
endif ()
150
173
151
174
#Force all visual studio outputs to CMAKE_BINARY_DIR
@@ -606,6 +629,8 @@ if(WIN32)
606
629
target_link_options (common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj )
607
630
elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC" )
608
631
target_link_options (common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj )
632
+ else ()
633
+ message (FATAL_ERROR "Unhandled compiler: ${CMAKE_C_COMPILER_ID} " )
609
634
endif ()
610
635
elseif (UNIX )
611
636
target_link_libraries (common-main pthread rt )
@@ -928,6 +953,9 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X='${EXE_EXTENSION}'\n")
928
953
file (APPEND ${CMAKE_BINARY_DIR} /GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT} '\n " )
929
954
file (APPEND ${CMAKE_BINARY_DIR} /GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX} '\n " )
930
955
file (APPEND ${CMAKE_BINARY_DIR} /GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON} '\n " )
956
+ if (WIN32 )
957
+ file (APPEND ${CMAKE_BINARY_DIR} /GIT-BUILD-OPTIONS "PATH=\" $PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n " )
958
+ endif ()
931
959
932
960
#Make the tests work when building out of the source tree
933
961
get_filename_component (CACHE_PATH ${CMAKE_CURRENT_LIST_DIR} /../../CMakeCache.txt ABSOLUTE )
@@ -938,7 +966,7 @@ if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})
938
966
file (WRITE ${CMAKE_BINARY_DIR} /CTestCustom.cmake
939
967
"file(STRINGS ${CMAKE_SOURCE_DIR} /t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \" GIT_BUILD_DIR=(.*)\" )\n "
940
968
"file(STRINGS ${CMAKE_SOURCE_DIR} /t/test-lib.sh content NEWLINE_CONSUME)\n "
941
- "string(REPLACE \"\$ {GIT_BUILD_DIR_REPL}\" \" GIT_BUILD_DIR=\\\" $TEST_DIRECTORY\\\" /../${BUILD_DIR_RELATIVE} \" content \"\$ {content}\" )\n "
969
+ "string(REPLACE \"\$ {GIT_BUILD_DIR_REPL}\" \" GIT_BUILD_DIR=\\\" $TEST_DIRECTORY/../${BUILD_DIR_RELATIVE} \\\" \" content \"\$ {content}\" )\n "
942
970
"file(WRITE ${CMAKE_SOURCE_DIR} /t/test-lib.sh \$ {content})" )
943
971
#misc copies
944
972
file (COPY ${CMAKE_SOURCE_DIR} /t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR} /t/ )
0 commit comments