cmake: refactor WinHTTP selection Move WinHTTP selection into its own cmake module.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
diff --git a/cmake/SelectWinHTTP.cmake b/cmake/SelectWinHTTP.cmake
new file mode 100644
index 0000000..a411004
--- /dev/null
+++ b/cmake/SelectWinHTTP.cmake
@@ -0,0 +1,17 @@
+if(WIN32 AND WINHTTP)
+ set(GIT_WINHTTP 1)
+
+ # Since MinGW does not come with headers or an import library for winhttp,
+ # we have to include a private header and generate our own import library
+ if(MINGW)
+ add_subdirectory("${libgit2_SOURCE_DIR}/deps/winhttp" "${libgit2_BINARY_DIR}/deps/winhttp")
+ list(APPEND LIBGIT2_LIBS winhttp)
+ list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
+ else()
+ list(APPEND LIBGIT2_LIBS "winhttp")
+ list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
+ endif()
+
+ list(APPEND LIBGIT2_LIBS "rpcrt4" "crypt32" "ole32")
+ list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
+endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 819fc42..8a57b23 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -93,29 +93,12 @@ if(WIN32 AND EMBED_SSH_PATH)
set(GIT_SSH 1)
endif()
-if(WIN32 AND USE_WINHTTP)
- set(GIT_WINHTTP 1)
-
- # Since MinGW does not come with headers or an import library for winhttp,
- # we have to include a private header and generate our own import library
- if(MINGW)
- add_subdirectory("${libgit2_SOURCE_DIR}/deps/winhttp" "${libgit2_BINARY_DIR}/deps/winhttp")
- list(APPEND LIBGIT2_LIBS winhttp)
- list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
- else()
- list(APPEND LIBGIT2_LIBS "winhttp")
- list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
- endif()
-
- list(APPEND LIBGIT2_LIBS "rpcrt4" "crypt32" "ole32")
- list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
-endif()
-
include(SelectHTTPSBackend)
include(SelectHashes)
include(SelectHTTPParser)
include(SelectRegex)
include(SelectSSH)
+include(SelectWinHTTP)
target_sources(git2internal PRIVATE ${SRC_SHA1})