Commit 4218403e by Patrick Steinhardt

cmake: use target-specific compile definitions

We set up some compile definitions as part of our src/CMakeLists.txt.
While the definitions are global, we really only need them as part of
the git2internal target which compiles all the objects. Let's thus use
`target_compile_definitions` instead of `add_definitions`.
parent 53911edd
...@@ -41,19 +41,19 @@ CHECK_PROTOTYPE_DEFINITION(qsort_r ...@@ -41,19 +41,19 @@ CHECK_PROTOTYPE_DEFINITION(qsort_r
"void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))" "void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))"
"" "stdlib.h" HAVE_QSORT_R_BSD) "" "stdlib.h" HAVE_QSORT_R_BSD)
IF (HAVE_QSORT_R_BSD) IF (HAVE_QSORT_R_BSD)
ADD_DEFINITIONS(-DHAVE_QSORT_R_BSD) target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_BSD)
ENDIF() ENDIF()
CHECK_PROTOTYPE_DEFINITION(qsort_r CHECK_PROTOTYPE_DEFINITION(qsort_r
"void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)" "void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)"
"" "stdlib.h" HAVE_QSORT_R_GNU) "" "stdlib.h" HAVE_QSORT_R_GNU)
IF (HAVE_QSORT_R_GNU) IF (HAVE_QSORT_R_GNU)
ADD_DEFINITIONS(-DHAVE_QSORT_R_GNU) target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_GNU)
ENDIF() ENDIF()
CHECK_FUNCTION_EXISTS(qsort_s HAVE_QSORT_S) CHECK_FUNCTION_EXISTS(qsort_s HAVE_QSORT_S)
IF (HAVE_QSORT_S) IF (HAVE_QSORT_S)
ADD_DEFINITIONS(-DHAVE_QSORT_S) target_compile_definitions(git2internal PRIVATE HAVE_QSORT_S)
ENDIF () ENDIF ()
# Find required dependencies # Find required dependencies
...@@ -273,7 +273,7 @@ ELSEIF (HAVE_STRUCT_STAT_ST_MTIME_NSEC) ...@@ -273,7 +273,7 @@ ELSEIF (HAVE_STRUCT_STAT_ST_MTIME_NSEC)
SET(GIT_USE_STAT_MTIME_NSEC 1) SET(GIT_USE_STAT_MTIME_NSEC 1)
ENDIF() ENDIF()
ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64) target_compile_definitions(git2internal PRIVATE _FILE_OFFSET_BITS=64)
# Collect sourcefiles # Collect sourcefiles
file(GLOB SRC_H file(GLOB SRC_H
...@@ -291,7 +291,7 @@ if(WIN32 AND NOT CYGWIN) ...@@ -291,7 +291,7 @@ if(WIN32 AND NOT CYGWIN)
list(SORT SRC_OS) list(SORT SRC_OS)
target_sources(git2internal PRIVATE ${SRC_OS}) target_sources(git2internal PRIVATE ${SRC_OS})
elseif(AMIGA) elseif(AMIGA)
add_definitions(-DNO_ADDRINFO -DNO_READDIR_R -DNO_MMAP) target_compile_definitions(git2internal PRIVATE NO_ADDRINFO NO_READDIR_R NO_MMAP)
else() else()
file(GLOB SRC_OS unix/*.c unix/*.h) file(GLOB SRC_OS unix/*.c unix/*.h)
list(SORT SRC_OS) list(SORT SRC_OS)
...@@ -299,7 +299,7 @@ else() ...@@ -299,7 +299,7 @@ else()
endif() endif()
IF (USE_LEAK_CHECKER STREQUAL "valgrind") IF (USE_LEAK_CHECKER STREQUAL "valgrind")
ADD_DEFINITIONS(-DVALGRIND) target_compile_definitions(git2internal PRIVATE VALGRIND)
ENDIF() ENDIF()
file(GLOB SRC_GIT2 *.c *.h file(GLOB SRC_GIT2 *.c *.h
...@@ -374,7 +374,7 @@ if(SONAME) ...@@ -374,7 +374,7 @@ if(SONAME)
set_target_properties(git2 PROPERTIES VERSION ${libgit2_VERSION}) set_target_properties(git2 PROPERTIES VERSION ${libgit2_VERSION})
set_target_properties(git2 PROPERTIES SOVERSION "${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}") set_target_properties(git2 PROPERTIES SOVERSION "${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}")
if(LIBGIT2_FILENAME) if(LIBGIT2_FILENAME)
add_definitions(-DLIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\") target_compile_definitions(git2internal PRIVATE LIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\")
set_target_properties(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME}) set_target_properties(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME})
elseif(DEFINED LIBGIT2_PREFIX) elseif(DEFINED LIBGIT2_PREFIX)
set_target_properties(git2 PROPERTIES PREFIX "${LIBGIT2_PREFIX}") set_target_properties(git2 PROPERTIES PREFIX "${LIBGIT2_PREFIX}")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment