cmake: move regex build instructions into subdirectory Extract code required to build the regex library into its own CMakeLists.txt, which is included as required.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ab6077e..1458bb8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -453,8 +453,9 @@ ENDIF()
# Include POSIX regex when it is required
IF(WIN32 OR AMIGA OR CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
- LIST(APPEND LBIGIT2_INCLUDES "${CMAKE_SOURCE_DIR}/deps/regex")
- SET(SRC_REGEX "${CMAKE_SOURCE_DIR}/deps/regex/regex.c")
+ ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/deps/regex" "${CMAKE_BINARY_DIR}/deps/regex")
+ LIST(APPEND LIBGIT2_INCLUDES "${CMAKE_SOURCE_DIR}/deps/regex")
+ LIST(APPEND LIBGIT2_LIBS regex)
ENDIF()
# Optional external dependency: http-parser
@@ -599,7 +600,7 @@ ENDIF()
CONFIGURE_FILE(src/features.h.in git2/sys/features.h)
-SET(GIT2INTERNAL_OBJECTS ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SSH} ${SRC_SHA1})
+SET(GIT2INTERNAL_OBJECTS ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_SSH} ${SRC_SHA1})
LIST(APPEND LIBGIT2_INCLUDES ${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_SOURCE_DIR}/src" "${CMAKE_SOURCE_DIR}/include")
diff --git a/deps/regex/CMakeLists.txt b/deps/regex/CMakeLists.txt
new file mode 100644
index 0000000..6ef8a27
--- /dev/null
+++ b/deps/regex/CMakeLists.txt
@@ -0,0 +1,2 @@
+INCLUDE_DIRECTORIES(".")
+ADD_LIBRARY(regex STATIC "regex.c" "regex.h")