vcpkg/ports/libgit2/fix-configcmake.patch
2023-05-30 12:31:00 -07:00

56 lines
2.2 KiB
Diff

diff --git a/cmake/SelectRegex.cmake b/cmake/SelectRegex.cmake
index 2a3a91b8c..cbb409350 100644
--- a/cmake/SelectRegex.cmake
+++ b/cmake/SelectRegex.cmake
@@ -1,5 +1,4 @@
# Specify regular expression implementation
-find_package(PCRE)
if(REGEX_BACKEND STREQUAL "")
check_symbol_exists(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
@@ -33,8 +32,8 @@ elseif(REGEX_BACKEND STREQUAL "pcre")
add_feature_info(regex ON "using system PCRE")
set(GIT_REGEX_PCRE 1)
- list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE_INCLUDE_DIRS})
- list(APPEND LIBGIT2_SYSTEM_LIBS ${PCRE_LIBRARIES})
+ find_package(unofficial-pcre CONFIG REQUIRED)
+ list(APPEND LIBGIT2_SYSTEM_LIBS unofficial::pcre::pcre)
list(APPEND LIBGIT2_PC_REQUIRES "libpcre")
elseif(REGEX_BACKEND STREQUAL "regcomp")
add_feature_info(regex ON "using system regcomp")
diff --git a/src/libgit2/CMakeLists.txt b/src/libgit2/CMakeLists.txt
index 876a703e8..8283f9585 100644
--- a/src/libgit2/CMakeLists.txt
+++ b/src/libgit2/CMakeLists.txt
@@ -110,10 +110,28 @@ FILE(WRITE "${PROJECT_BINARY_DIR}/include/${LIBGIT2_FILENAME}.h" ${LIBGIT2_INCLU
# Install
-install(TARGETS libgit2package
+install(TARGETS libgit2package EXPORT unofficial-git2Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+install(EXPORT unofficial-git2Targets
+ NAMESPACE unofficial::git2::
+ DESTINATION share/unofficial-git2
+)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/unofficial-git2-config.cmake.in"
+[[include(CMakeFindDependencyMacro)
+if(@USE_BUNDLED_ZLIB@ STREQUAL "OFF")
+ find_dependency(ZLIB)
+endif()
+if(@REGEX_BACKEND@ STREQUAL "pcre")
+ find_dependency(unofficial-pcre CONFIG)
+endif()
+include("${CMAKE_CURRENT_LIST_DIR}/unofficial-git2Targets.cmake")
+]])
+configure_file("${CMAKE_CURRENT_BINARY_DIR}/unofficial-git2-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/unofficial-git2-config.cmake" @ONLY)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unofficial-git2-config.cmake DESTINATION share/unofficial-git2)
+
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/git2/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBGIT2_FILENAME}")
install(FILES ${PROJECT_BINARY_DIR}/include/git2/experimental.h