cmake: fix include directories
authorMichael Wallner <mike@php.net>
Mon, 14 Sep 2020 07:45:20 +0000 (09:45 +0200)
committerMichael Wallner <mike@php.net>
Mon, 14 Sep 2020 07:45:20 +0000 (09:45 +0200)
CMakeLists.txt
src/bin/CMakeLists.txt
src/libhashkit/CMakeLists.txt
src/libmemcached/CMakeLists.txt
src/libmemcachedprotocol/CMakeLists.txt
src/libmemcachedutil/CMakeLists.txt

index 09d1ad5023d57200962666fda56e8ea7ca604016..e13c1fd420cff4a700cce21444500163d2117907 100644 (file)
@@ -18,13 +18,6 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 include(CMakeConfig.txt)
 
 if(NOT BUILD_DOCSONLY)
-    foreach(INCLUDE IN ITEMS ${CMAKE_BINARY_DIR} .)
-        include_directories(
-                ${INCLUDE}/
-                ${INCLUDE}/include
-                ${INCLUDE}/src
-                )
-    endforeach()
 
     set(AUTOHEADER_FILE mem_config.h)
 
index 8cd42462c3c07497d015887f2e0e3b45b53414fd..a568dd1c20a9142c3d26ecfa7630cac9fcc31e48 100644 (file)
@@ -1,7 +1,14 @@
 
 add_library(libclient_utilities STATIC utilities.cc generator.cc execute.cc)
 add_library(client_utilities ALIAS libclient_utilities)
-target_link_libraries(libclient_utilities libmemcachedinternal)
+target_link_libraries(libclient_utilities PRIVATE libmemcachedinternal)
+target_include_directories(libclient_utilities PUBLIC
+        ${CMAKE_SOURCE_DIR}/include
+        ${CMAKE_BINARY_DIR}/include
+        ${CMAKE_SOURCE_DIR}/src
+        ${CMAKE_BINARY_DIR}/src
+        ${CMAKE_BINARY_DIR})
+
 
 foreach(CLIENT IN LISTS CLIENTS)
     add_executable(${CLIENT} ${CLIENT}.cc)
index d31a54909b7b9edbce6d0d4c2b3c45bd92920115..a75e08e7a6095cdc5ffdaac1bb9919aec89ded9c 100644 (file)
@@ -33,7 +33,14 @@ add_library(libhashkit SHARED
 add_library(hashkit ALIAS libhashkit)
 set_target_properties(libhashkit PROPERTIES LIBRARY_OUTPUT_NAME hashkit)
 target_compile_options(libhashkit PRIVATE -DBUILDING_HASHKIT)
-
+target_include_directories(libhashkit PRIVATE
+        ${CMAKE_SOURCE_DIR}/src
+        ${CMAKE_BINARY_DIR}/src
+        ${CMAKE_BINARY_DIR})
+target_include_directories(libhashkit PUBLIC
+        $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
+        $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
+        $<INSTALL_INTERFACE:include>)
 configure_file(hashkitcon.h.in hashkitcon.h @ONLY)
 
 set_target_properties(libhashkit PROPERTIES SOVERSION ${LIBHASHKIT_SO_VERSION})
index ebb0d83bb4c0abd603033bf19e4235a8e298f972..96338c9b84a5b613406722f27fda40bcf52462d5 100644 (file)
@@ -90,9 +90,17 @@ add_library(libmemcached SHARED
         ${LIBMEMCACHED_SOURCES})
 add_library(memcached ALIAS libmemcached)
 set_target_properties(libmemcached PROPERTIES LIBRARY_OUTPUT_NAME memcached)
-target_link_libraries(libmemcached libhashkit Threads::Threads ${LIBSASL_LIBRARIES} ${CMAKE_DL_LIBS})
-target_include_directories(libmemcached PRIVATE ${LIBSASL_INCLUDEDIR})
 target_compile_definitions(libmemcached PRIVATE -DBUILDING_LIBMEMCACHED)
+target_link_libraries(libmemcached PUBLIC libhashkit Threads::Threads ${LIBSASL_LIBRARIES} ${CMAKE_DL_LIBS})
+target_include_directories(libmemcached PRIVATE ${LIBSASL_INCLUDEDIR})
+target_include_directories(libmemcached PRIVATE
+        ${CMAKE_SOURCE_DIR}/src
+        ${CMAKE_BINARY_DIR}/src
+        ${CMAKE_BINARY_DIR})
+target_include_directories(libmemcached PUBLIC
+        $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
+        $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
+        $<INSTALL_INTERFACE:include>)
 
 set_target_properties(libmemcached PROPERTIES SOVERSION ${LIBMEMCACHED_SO_VERSION})
 install(TARGETS libmemcached EXPORT libmemcached
@@ -112,9 +120,17 @@ add_library(libmemcachedinternal STATIC
         ${LIBMEMCACHED_SOURCES})
 add_library(memcachedinternal ALIAS libmemcachedinternal)
 set_target_properties(libmemcachedinternal PROPERTIES LIBRARY_OUTPUT_NAME memcachedinternal)
-target_link_libraries(libmemcachedinternal libhashkit Threads::Threads ${LIBSASL_LIBRARIES} ${CMAKE_DL_LIBS})
-target_include_directories(libmemcachedinternal PRIVATE ${LIBSASL_INCLUDEDIR})
 target_compile_definitions(libmemcachedinternal PRIVATE -DBUILDING_LIBMEMCACHEDINTERNAL)
+target_link_libraries(libmemcachedinternal PUBLIC libhashkit Threads::Threads ${LIBSASL_LIBRARIES} ${CMAKE_DL_LIBS})
+target_include_directories(libmemcachedinternal PRIVATE ${LIBSASL_INCLUDEDIR})
+target_include_directories(libmemcachedinternal PRIVATE
+        ${CMAKE_SOURCE_DIR}/src
+        ${CMAKE_BINARY_DIR}/src
+        ${CMAKE_BINARY_DIR})
+target_include_directories(libmemcachedinternal PUBLIC
+        $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
+        $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
+        $<INSTALL_INTERFACE:include>)
 
 # let libmemcached depend on libmemcachedinternal to ensure that they do not
 # compete for the same generated dependencies
index 3712cf445f14b610ced8d8beead310a440446591..a826e0aa12e1399b11589c5cab1ce37d07297610 100644 (file)
@@ -10,7 +10,15 @@ add_library(libmemcachedprotocol SHARED
 add_library(memcachedprotocol ALIAS libmemcachedprotocol)
 set_target_properties(libmemcachedprotocol PROPERTIES LIBRARY_OUTPUT_NAME memcachedprotocol)
 target_compile_definitions(libmemcachedprotocol PRIVATE -DBUILDING_LIBMEMCACHED)
-target_link_libraries(libmemcachedprotocol libmemcached Threads::Threads)
+target_link_libraries(libmemcachedprotocol PUBLIC libmemcached Threads::Threads)
+target_include_directories(libmemcachedprotocol PRIVATE
+        ${CMAKE_SOURCE_DIR}/src
+        ${CMAKE_BINARY_DIR}/src
+        ${CMAKE_BINARY_DIR})
+target_include_directories(libmemcachedprotocol PUBLIC
+        $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
+        $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
+        $<INSTALL_INTERFACE:include>)
 
 set_target_properties(libmemcachedprotocol PROPERTIES SOVERSION ${LIBMEMCACHEDPROTOCOL_SO_VERSION})
 install(TARGETS libmemcachedprotocol EXPORT libmemcachedprotocol
index e99e7256f295806be6807c82f9cdc15374eba9a7..d087d63d19caa8c6be34a42c23014ae09234a726 100644 (file)
@@ -11,7 +11,15 @@ add_library(libmemcachedutil SHARED
 add_library(memcachedutil ALIAS libmemcachedutil)
 set_target_properties(libmemcachedutil PROPERTIES LIBRARY_OUTPUT_NAME memcachedutil)
 target_compile_definitions(libmemcachedutil PRIVATE -DBUILDING_LIBMEMCACHED)
-target_link_libraries(libmemcachedutil libmemcached Threads::Threads)
+target_link_libraries(libmemcachedutil PUBLIC libmemcached Threads::Threads)
+target_include_directories(libmemcachedutil PRIVATE
+        ${CMAKE_SOURCE_DIR}/src
+        ${CMAKE_BINARY_DIR}/src
+        ${CMAKE_BINARY_DIR})
+target_include_directories(libmemcachedutil PUBLIC
+        $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
+        $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
+        $<INSTALL_INTERFACE:include>)
 
 set_target_properties(libmemcachedutil PROPERTIES SOVERSION ${LIBMEMCACHEDUTIL_SO_VERSION})
 install(TARGETS libmemcachedutil EXPORT libmemcachedutil