]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: link compressor plugins against lib the modern way 23852/head
authorKefu Chai <kchai@redhat.com>
Sun, 2 Sep 2018 06:42:54 +0000 (14:42 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 2 Sep 2018 06:43:57 +0000 (14:43 +0800)
* always link against the target library not library paths
* import their include directories by linking against their target
  library, instead of doing so using target_include_directories()
  manually.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/compressor/brotli/CMakeLists.txt
src/compressor/lz4/CMakeLists.txt
src/compressor/snappy/CMakeLists.txt
src/compressor/zlib/CMakeLists.txt
src/compressor/zstd/CMakeLists.txt

index bbf90b1603ea14ec1322bc60859f83b0e4738b37..84648362d286fc9a75950fdf6c131d5bc0195cac 100644 (file)
@@ -26,12 +26,13 @@ set(bortli_libs enc dec common)
 foreach(lib ${bortli_libs})
   add_library(brotli::${lib} STATIC IMPORTED)
   add_dependencies(brotli::${lib} brotli_ext)
-  set_property(TARGET brotli::${lib} PROPERTY IMPORTED_LOCATION "${CMAKE_BINARY_DIR}/src/brotli/libbrotli${lib}-static.a")
+  set_target_properties(brotli::${lib} PROPERTIES
+    INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}/src/brotli/c/include"
+    IMPORTED_LOCATION "${CMAKE_BINARY_DIR}/src/brotli/libbrotli${lib}-static.a")
   list(APPEND BROTLI_LIBRARIES brotli::${lib})
 endforeach()
 
 add_library(ceph_brotli SHARED ${brotli_sources})
-target_include_directories(ceph_brotli PRIVATE "${CMAKE_BINARY_DIR}/src/brotli/c/include")
-List(REVERSE bortli_libs)
-target_link_libraries(ceph_brotli ${BROTLI_LIBRARIES})
+list(REVERSE bortli_libs)
+target_link_libraries(ceph_brotli PRIVATE ${BROTLI_LIBRARIES})
 install(TARGETS ceph_brotli DESTINATION ${compressor_plugin_dir})
index 11d8576fac2309b37bb67cf96cf6c08a81e321d0..7a8a15d674fc9e2c0361c642729c6d1305236f5f 100644 (file)
@@ -5,7 +5,7 @@ set(lz4_sources
 )
 
 add_library(ceph_lz4 SHARED ${lz4_sources})
-target_link_libraries(ceph_lz4 ${LZ4_LIBRARY})
+target_link_libraries(ceph_lz4 PRIVATE LZ4::LZ4)
 set_target_properties(ceph_lz4 PROPERTIES
   VERSION 2.0.0
   SOVERSION 2
index 05df62024ca5451b92605304e3f35dc6ab2e131d..0bb233d4cde5b0f1e7db5a118c32e11652f34ec4 100644 (file)
@@ -5,9 +5,7 @@ set(snappy_sources
 )
 
 add_library(ceph_snappy SHARED ${snappy_sources})
-target_include_directories(ceph_snappy SYSTEM PRIVATE
-  "${SNAPPY_INCLUDE_DIR}")
-target_link_libraries(ceph_snappy snappy::snappy)
+target_link_libraries(ceph_snappy PRIVATE snappy::snappy)
 set_target_properties(ceph_snappy PROPERTIES
   VERSION 2.0.0
   SOVERSION 2
index 109fef521fc1ec031899e0377528506e84b6b27c..51aba0834d356b4085ac0f3cfc8aaa0c90045c1f 100644 (file)
@@ -38,7 +38,7 @@ else(HAVE_INTEL_SSE4_1 AND HAVE_BETTER_YASM_ELF64 AND (NOT APPLE))
 endif(HAVE_INTEL_SSE4_1 AND HAVE_BETTER_YASM_ELF64 AND (NOT APPLE))
 
 add_library(ceph_zlib SHARED ${zlib_sources})
-target_link_libraries(ceph_zlib ${ZLIB_LIBRARIES})
+target_link_libraries(ceph_zlib ZLIB::ZLIB)
 target_include_directories(ceph_zlib SYSTEM PRIVATE "${CMAKE_SOURCE_DIR}/src/isa-l/include")
 set_target_properties(ceph_zlib PROPERTIES
   VERSION 2.0.0
index e30cb895aee29e145122daf98f4d3a95ded3070a..c730e48b16d6d1b0ddd2d4ea53e3a1a5c550f4bc 100644 (file)
@@ -22,18 +22,17 @@ ExternalProject_Add_Step(zstd_ext forcebuild
   ALWAYS 1)
 
 add_library(zstd STATIC IMPORTED)
-set_property(TARGET zstd PROPERTY
+set_target_properties(zstd PROPERTIES
+  INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/src/zstd/lib"
   IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/libzstd/lib/libzstd.a")
 add_dependencies(zstd zstd_ext)
-set(ZSTD_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/zstd/lib)
 
-#
 set(zstd_sources
   CompressionPluginZstd.cc
 )
 
 add_library(ceph_zstd SHARED ${zstd_sources})
-target_link_libraries(ceph_zstd zstd)
+target_link_libraries(ceph_zstd PRIVATE zstd)
 set_target_properties(ceph_zstd PROPERTIES
   VERSION 2.0.0
   SOVERSION 2