From 22de81e6ccc68772ef6ba6a76268669a443d8e96 Mon Sep 17 00:00:00 2001 From: Andrey Davydov Date: Wed, 21 Jun 2017 08:25:36 +0300 Subject: cmake: use `target_include_directories` for modern cmake Apply `target_include_directories` when CMAKE_VERSION >= 2.8.12 --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3f5a995c..82e086d59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -207,7 +207,6 @@ FILE(STRINGS "include/git2/version.h" GIT2_HEADER_SOVERSION REGEX "^#define LIBG STRING(REGEX REPLACE "^.*LIBGIT2_SOVERSION ([0-9]+)$" "\\1" LIBGIT2_SOVERSION "${GIT2_HEADER_SOVERSION}") # Find required dependencies -INCLUDE_DIRECTORIES(src include) IF (SECURITY_FOUND) # OS X 10.7 and older do not have some functions we use, fall back to OpenSSL there @@ -619,6 +618,13 @@ TARGET_LINK_LIBRARIES(git2 ${GSSAPI_LIBRARIES}) TARGET_LINK_LIBRARIES(git2 ${ICONV_LIBRARIES}) TARGET_OS_LIBRARIES(git2) +IF (${CMAKE_VERSION} VERSION_LESS 2.8.12) + INCLUDE_DIRECTORIES(src include) + SET(LIBGIT2_INNER_DIRECTORIES_ARE_INCLUDED TRUE) +ELSE() + TARGET_INCLUDE_DIRECTORIES(git2 PRIVATE src PUBLIC include) +ENDIF() + # Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240) # Win64+MSVC+static libs = linker error IF(MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS) @@ -688,6 +694,10 @@ IF (BUILD_CLAR) ${CLAR_PATH}/clar.c PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clar.suite) + IF (NOT LIBGIT2_INNER_DIRECTORIES_ARE_INCLUDED) + INCLUDE_DIRECTORIES(src include) + ENDIF() + ADD_EXECUTABLE(libgit2_clar ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_CLAR} ${SRC_TEST} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SSH} ${SRC_SHA1}) TARGET_LINK_LIBRARIES(libgit2_clar ${COREFOUNDATION_DIRS}) -- cgit v1.2.1 From 56893bb9a1c759d2b1670a1e15d0f45ae35b51db Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 28 Jun 2017 12:11:44 +0200 Subject: cmake: consistently use TARGET_INCLUDE_DIRECTORIES if available Instead of using INCLUDE_DIRECTORIES again for the libgit2_clar test suite, we should just be using TARGET_INCLUDE_DIRECTORIES again if the CMake version is greater than 2.8.11. --- CMakeLists.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 82e086d59..f3b360494 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -620,7 +620,6 @@ TARGET_OS_LIBRARIES(git2) IF (${CMAKE_VERSION} VERSION_LESS 2.8.12) INCLUDE_DIRECTORIES(src include) - SET(LIBGIT2_INNER_DIRECTORIES_ARE_INCLUDED TRUE) ELSE() TARGET_INCLUDE_DIRECTORIES(git2 PRIVATE src PUBLIC include) ENDIF() @@ -694,12 +693,12 @@ IF (BUILD_CLAR) ${CLAR_PATH}/clar.c PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clar.suite) - IF (NOT LIBGIT2_INNER_DIRECTORIES_ARE_INCLUDED) - INCLUDE_DIRECTORIES(src include) - ENDIF() - ADD_EXECUTABLE(libgit2_clar ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_CLAR} ${SRC_TEST} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SSH} ${SRC_SHA1}) + IF (${CMAKE_VERSION} VERSION_GREATER 2.8.11) + TARGET_INCLUDE_DIRECTORIES(libgit2_clar PRIVATE src PUBLIC include) + ENDIF() + TARGET_LINK_LIBRARIES(libgit2_clar ${COREFOUNDATION_DIRS}) TARGET_LINK_LIBRARIES(libgit2_clar ${SECURITY_DIRS}) TARGET_LINK_LIBRARIES(libgit2_clar ${SSL_LIBRARIES}) -- cgit v1.2.1