Skip to content

Commit 9e449e5

Browse files
committed
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.
1 parent 4324850 commit 9e449e5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,9 @@ ENDIF()
453453

454454
# Include POSIX regex when it is required
455455
IF(WIN32 OR AMIGA OR CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
456-
LIST(APPEND LBIGIT2_INCLUDES "${CMAKE_SOURCE_DIR}/deps/regex")
457-
SET(SRC_REGEX "${CMAKE_SOURCE_DIR}/deps/regex/regex.c")
456+
ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/deps/regex" "${CMAKE_BINARY_DIR}/deps/regex")
457+
LIST(APPEND LIBGIT2_INCLUDES "${CMAKE_SOURCE_DIR}/deps/regex")
458+
LIST(APPEND LIBGIT2_LIBS regex)
458459
ENDIF()
459460

460461
# Optional external dependency: http-parser
@@ -599,7 +600,7 @@ ENDIF()
599600

600601
CONFIGURE_FILE(src/features.h.in git2/sys/features.h)
601602

602-
SET(GIT2INTERNAL_OBJECTS ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SSH} ${SRC_SHA1})
603+
SET(GIT2INTERNAL_OBJECTS ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_SSH} ${SRC_SHA1})
603604

604605
LIST(APPEND LIBGIT2_INCLUDES ${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_SOURCE_DIR}/src" "${CMAKE_SOURCE_DIR}/include")
605606

deps/regex/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
INCLUDE_DIRECTORIES(".")
2+
ADD_LIBRARY(regex STATIC "regex.c" "regex.h")

0 commit comments

Comments
 (0)