mirror of
https://github.com/libgit2/libgit2.git
synced 2026-01-25 11:06:32 +00:00
Also applies to *_BINARY_DIR.
This effectively reverts 84083dcc8b,
which broke all users of libgit2 that use it as a CMake subdirectory
(via `add_subdirectory()`). This is because CMAKE_SOURCE_DIR refers
to the root-most CMake directory, which in the case of
`add_subdirectory()` is a parent project to libgit2 and thus the paths
don't make any sense to the configuration files. Corollary,
CMAKE_SOURCE_DIR only makes sense if the CMake project is always the
root project - which can rarely be guaranteed.
In all honesty, CMake should deprecate and eventually remove
CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR. It's been the source of headaches
and confusion for years, they're rarely useful over
CMAKE_CURRENT_(SOURCE|BINARY)_DIR or PROJECT_(SOURCE|BINARY)_DIR,
and they cause a lot of confusing configuration and source
code layouts to boot.
Any time they are used, they break `add_subdirectory()` almost 100% of
the time, cause confusing error messages, and hide subtle bugs.
52 lines
1.6 KiB
CMake
52 lines
1.6 KiB
CMake
# Specify regular expression implementation
|
|
find_package(PCRE)
|
|
|
|
if(REGEX_BACKEND STREQUAL "")
|
|
check_symbol_exists(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
|
|
|
|
if(HAVE_REGCOMP_L)
|
|
set(REGEX_BACKEND "regcomp_l")
|
|
elseif(PCRE_FOUND)
|
|
set(REGEX_BACKEND "pcre")
|
|
else()
|
|
set(REGEX_BACKEND "builtin")
|
|
endif()
|
|
endif()
|
|
|
|
if(REGEX_BACKEND STREQUAL "regcomp_l")
|
|
add_feature_info(regex ON "using system regcomp_l")
|
|
set(GIT_REGEX_REGCOMP_L 1)
|
|
elseif(REGEX_BACKEND STREQUAL "pcre2")
|
|
find_package(PCRE2)
|
|
|
|
if(NOT PCRE2_FOUND)
|
|
MESSAGE(FATAL_ERROR "PCRE2 support was requested but not found")
|
|
endif()
|
|
|
|
add_feature_info(regex ON "using system PCRE2")
|
|
set(GIT_REGEX_PCRE2 1)
|
|
|
|
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE2_INCLUDE_DIRS})
|
|
list(APPEND LIBGIT2_SYSTEM_LIBS ${PCRE2_LIBRARIES})
|
|
list(APPEND LIBGIT2_PC_REQUIRES "libpcre2-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})
|
|
list(APPEND LIBGIT2_PC_REQUIRES "libpcre")
|
|
elseif(REGEX_BACKEND STREQUAL "regcomp")
|
|
add_feature_info(regex ON "using system regcomp")
|
|
set(GIT_REGEX_REGCOMP 1)
|
|
elseif(REGEX_BACKEND STREQUAL "builtin")
|
|
add_feature_info(regex ON "using bundled PCRE")
|
|
set(GIT_REGEX_BUILTIN 1)
|
|
|
|
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/pcre" "${PROJECT_BINARY_DIR}/deps/pcre")
|
|
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/pcre")
|
|
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS $<TARGET_OBJECTS:pcre>)
|
|
else()
|
|
message(FATAL_ERROR "The REGEX_BACKEND option provided is not supported")
|
|
endif()
|