Skip to content

Commit 83fa548

Browse files
committed
cmake: refactor WinHTTP selection
Move WinHTTP selection into its own cmake module.
1 parent e35a22a commit 83fa548

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

cmake/SelectWinHTTP.cmake

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
if(WIN32 AND WINHTTP)
2+
set(GIT_WINHTTP 1)
3+
4+
# Since MinGW does not come with headers or an import library for winhttp,
5+
# we have to include a private header and generate our own import library
6+
if(MINGW)
7+
add_subdirectory("${libgit2_SOURCE_DIR}/deps/winhttp" "${libgit2_BINARY_DIR}/deps/winhttp")
8+
list(APPEND LIBGIT2_LIBS winhttp)
9+
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
10+
else()
11+
list(APPEND LIBGIT2_LIBS "winhttp")
12+
list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
13+
endif()
14+
15+
list(APPEND LIBGIT2_LIBS "rpcrt4" "crypt32" "ole32")
16+
list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
17+
endif()

src/CMakeLists.txt

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,29 +93,12 @@ if(WIN32 AND EMBED_SSH_PATH)
9393
set(GIT_SSH 1)
9494
endif()
9595

96-
if(WIN32 AND USE_WINHTTP)
97-
set(GIT_WINHTTP 1)
98-
99-
# Since MinGW does not come with headers or an import library for winhttp,
100-
# we have to include a private header and generate our own import library
101-
if(MINGW)
102-
add_subdirectory("${libgit2_SOURCE_DIR}/deps/winhttp" "${libgit2_BINARY_DIR}/deps/winhttp")
103-
list(APPEND LIBGIT2_LIBS winhttp)
104-
list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
105-
else()
106-
list(APPEND LIBGIT2_LIBS "winhttp")
107-
list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
108-
endif()
109-
110-
list(APPEND LIBGIT2_LIBS "rpcrt4" "crypt32" "ole32")
111-
list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
112-
endif()
113-
11496
include(SelectHTTPSBackend)
11597
include(SelectHashes)
11698
include(SelectHTTPParser)
11799
include(SelectRegex)
118100
include(SelectSSH)
101+
include(SelectWinHTTP)
119102

120103
target_sources(git2internal PRIVATE ${SRC_SHA1})
121104

0 commit comments

Comments
 (0)