Correct me if I'm wrong but I think there's an issue here:
|
FILE(READ "${PROJECT_SOURCE_DIR}/include/git2.h" LIBGIT2_INCLUDE) |
|
STRING(REGEX REPLACE "#include \"git2\/" "#include \"${LIBGIT2_FILENAME}/" LIBGIT2_INCLUDE "${LIBGIT2_INCLUDE}") |
|
FILE(WRITE "${PROJECT_BINARY_DIR}/include/${LIBGIT2_FILENAME}.h" ${LIBGIT2_INCLUDE}) |
This regex needs to be applied to more than just git2.h. E.g. sys/alloc.h here references git2/common.h
Seems like the CMake needs to do something more like:
# Replace `git/` with `git-experimental/` in all headers
# Also, write all headers to the project binary dir; any of them could have been modified
foreach(HEADER_SOURCE ${SRC_H})
# Compute desired path in the binary dir
FILE(RELATIVE_PATH HEADER_RELATIVE ${PROJECT_SOURCE_DIR} ${HEADER_SOURCE})
FILE(REAL_PATH ${HEADER_RELATIVE} HEADER_OUT BASE_DIRECTORY ${PROJECT_BINARY_DIR})
FILE(READ "${HEADER_SOURCE}" HEADER_CONTENTS)
STRING(REGEX REPLACE "#include \"git2\/" "#include \"${LIBGIT2_FILENAME}/" HEADER_CONTENTS "${HEADER_CONTENTS}")
FILE(WRITE "${HEADER_OUT}" ${HEADER_CONTENTS})
endforeach()
# Rename git2.h after the regex & move
FILE(RENAME "${PROJECT_BINARY_DIR}/include/git2.h" "${PROJECT_BINARY_DIR}/include/${LIBGIT2_FILENAME}.h")
And I guess we'd need to make a change here too
|
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/git2/ |
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBGIT2_FILENAME}") |
install(DIRECTORY ${PROJECT_BINARY_DIR}/include/git2/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBGIT2_FILENAME}")
I have run into this issue on a project. We want to use libgit2's experimental SHA256 support but without a normal version of libgit2 installed next to it.
Correct me if I'm wrong but I think there's an issue here:
libgit2/src/libgit2/CMakeLists.txt
Lines 102 to 104 in e9cfa20
This regex needs to be applied to more than just
git2.h. E.g.sys/alloc.hhere referencesgit2/common.hlibgit2/include/git2/sys/alloc.h
Line 11 in e9cfa20
Seems like the CMake needs to do something more like:
And I guess we'd need to make a change here too
libgit2/src/libgit2/CMakeLists.txt
Lines 135 to 136 in e9cfa20
I have run into this issue on a project. We want to use libgit2's experimental SHA256 support but without a normal version of libgit2 installed next to it.