blosc-mods.patch 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. From 7cf6c014a36f1712efbdbe9bc52d2d4922b54673 Mon Sep 17 00:00:00 2001
  2. From: tamasmeszaros <meszaros.q@gmail.com>
  3. Date: Wed, 30 Oct 2019 12:54:52 +0100
  4. Subject: [PATCH] Blosc 1.17 fixes and cmake config script
  5. Signed-off-by: tamasmeszaros <meszaros.q@gmail.com>
  6. ---
  7. CMakeLists.txt | 105 +++++++++++++++++-----------------
  8. blosc/CMakeLists.txt | 118 +++++++++------------------------------
  9. cmake/FindLZ4.cmake | 6 +-
  10. cmake/FindSnappy.cmake | 8 ++-
  11. cmake/FindZstd.cmake | 8 ++-
  12. cmake_config.cmake.in | 24 ++++++++
  13. internal-complibs/CMakeLists.txt | 35 ++++++++++++
  14. 7 files changed, 157 insertions(+), 147 deletions(-)
  15. create mode 100644 cmake_config.cmake.in
  16. create mode 100644 internal-complibs/CMakeLists.txt
  17. diff --git a/CMakeLists.txt b/CMakeLists.txt
  18. index 59d9fab..e9134c2 100644
  19. --- a/CMakeLists.txt
  20. +++ b/CMakeLists.txt
  21. @@ -71,7 +71,7 @@
  22. # DEV: static includes blosc.a and blosc.h
  23. -cmake_minimum_required(VERSION 2.8.12)
  24. +cmake_minimum_required(VERSION 3.1) # Threads::Threads target available from 3.1
  25. if (NOT CMAKE_VERSION VERSION_LESS 3.3)
  26. cmake_policy(SET CMP0063 NEW)
  27. endif()
  28. @@ -124,55 +124,30 @@ option(PREFER_EXTERNAL_ZSTD
  29. set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
  30. -
  31. -if(NOT DEACTIVATE_LZ4)
  32. - if(PREFER_EXTERNAL_LZ4)
  33. - find_package(LZ4)
  34. - else()
  35. - message(STATUS "Using LZ4 internal sources.")
  36. - endif(PREFER_EXTERNAL_LZ4)
  37. - # HAVE_LZ4 will be set to true because even if the library is
  38. - # not found, we will use the included sources for it
  39. - set(HAVE_LZ4 TRUE)
  40. -endif(NOT DEACTIVATE_LZ4)
  41. -
  42. -if(NOT DEACTIVATE_SNAPPY)
  43. - if(PREFER_EXTERNAL_SNAPPY)
  44. - find_package(Snappy)
  45. - else()
  46. - message(STATUS "Using Snappy internal sources.")
  47. - endif(PREFER_EXTERNAL_SNAPPY)
  48. - # HAVE_SNAPPY will be set to true because even if the library is not found,
  49. - # we will use the included sources for it
  50. - set(HAVE_SNAPPY TRUE)
  51. -endif(NOT DEACTIVATE_SNAPPY)
  52. -
  53. -if(NOT DEACTIVATE_ZLIB)
  54. - # import the ZLIB_ROOT environment variable to help finding the zlib library
  55. - if(PREFER_EXTERNAL_ZLIB)
  56. - set(ZLIB_ROOT $ENV{ZLIB_ROOT})
  57. - find_package(ZLIB)
  58. - if (NOT ZLIB_FOUND )
  59. - message(STATUS "No zlib found. Using internal sources.")
  60. - endif (NOT ZLIB_FOUND )
  61. - else()
  62. - message(STATUS "Using zlib internal sources.")
  63. - endif(PREFER_EXTERNAL_ZLIB)
  64. - # HAVE_ZLIB will be set to true because even if the library is not found,
  65. - # we will use the included sources for it
  66. - set(HAVE_ZLIB TRUE)
  67. -endif(NOT DEACTIVATE_ZLIB)
  68. -
  69. -if (NOT DEACTIVATE_ZSTD)
  70. - if (PREFER_EXTERNAL_ZSTD)
  71. - find_package(Zstd)
  72. - else ()
  73. - message(STATUS "Using ZSTD internal sources.")
  74. - endif (PREFER_EXTERNAL_ZSTD)
  75. - # HAVE_ZSTD will be set to true because even if the library is
  76. - # not found, we will use the included sources for it
  77. - set(HAVE_ZSTD TRUE)
  78. -endif (NOT DEACTIVATE_ZSTD)
  79. +set(LIBS "")
  80. +macro(use_package _pkg _tgt)
  81. + string(TOUPPER ${_pkg} _PKG)
  82. + if(NOT DEACTIVATE_${_PKG})
  83. + if(PREFER_EXTERNAL_${_PKG})
  84. + find_package(${_pkg})
  85. + if (NOT ${_pkg}_FOUND )
  86. + message(STATUS "No ${_pkg} found. Using internal sources.")
  87. + endif()
  88. + else()
  89. + message(STATUS "Using ${_pkg} internal sources.")
  90. + endif(PREFER_EXTERNAL_${_PKG})
  91. + # HAVE_${_pkg} will be set to true because even if the library is
  92. + # not found, we will use the included sources for it
  93. + set(HAVE_${_PKG} TRUE)
  94. + list(APPEND LIBS ${_pkg}::${_tgt})
  95. + endif(NOT DEACTIVATE_${_PKG})
  96. +endmacro()
  97. +
  98. +set(ZLIB_ROOT $ENV{ZLIB_ROOT})
  99. +use_package(ZLIB ZLIB)
  100. +use_package(LZ4 LZ4)
  101. +use_package(Snappy snappy)
  102. +use_package(Zstd Zstd)
  103. # create the config.h file
  104. configure_file ("blosc/config.h.in" "blosc/config.h" )
  105. @@ -316,6 +291,7 @@ endif()
  106. # subdirectories
  107. +add_subdirectory(internal-complibs)
  108. add_subdirectory(blosc)
  109. if(BUILD_TESTS)
  110. @@ -328,7 +304,6 @@ if(BUILD_BENCHMARKS)
  111. add_subdirectory(bench)
  112. endif(BUILD_BENCHMARKS)
  113. -
  114. # uninstall target
  115. if (BLOSC_INSTALL)
  116. configure_file(
  117. @@ -338,10 +313,38 @@ if (BLOSC_INSTALL)
  118. install(FILES "${CMAKE_CURRENT_BINARY_DIR}/blosc.pc"
  119. DESTINATION lib/pkgconfig COMPONENT DEV)
  120. + configure_file(
  121. + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_config.cmake.in"
  122. + "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/BloscConfig.cmake"
  123. + @ONLY)
  124. +
  125. configure_file(
  126. "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  127. "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  128. IMMEDIATE @ONLY)
  129. +
  130. + include(CMakePackageConfigHelpers)
  131. + write_basic_package_version_file(
  132. + "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/BloscConfigVersion.cmake"
  133. + VERSION ${BLOSC_VERSION_MAJOR}.${BLOSC_VERSION_MINOR}.${BLOSC_VERSION_PATCH}
  134. + COMPATIBILITY AnyNewerVersion
  135. + )
  136. +
  137. + export(EXPORT BloscTargets
  138. + FILE "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/BloscTargets.cmake"
  139. + NAMESPACE Blosc::)
  140. +
  141. + install(EXPORT BloscTargets
  142. + FILE BloscTargets.cmake
  143. + NAMESPACE Blosc::
  144. + DESTINATION lib/cmake/Blosc
  145. + EXPORT_LINK_INTERFACE_LIBRARIES)
  146. +
  147. + install(FILES
  148. + "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/BloscConfig.cmake"
  149. + "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/BloscConfigVersion.cmake"
  150. + DESTINATION lib/cmake/Blosc COMPONENT DEV)
  151. +
  152. add_custom_target(uninstall
  153. COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
  154. endif()
  155. diff --git a/blosc/CMakeLists.txt b/blosc/CMakeLists.txt
  156. index 1d1bebe..f554abe 100644
  157. --- a/blosc/CMakeLists.txt
  158. +++ b/blosc/CMakeLists.txt
  159. @@ -1,52 +1,11 @@
  160. # a simple way to detect that we are using CMAKE
  161. add_definitions(-DUSING_CMAKE)
  162. -set(INTERNAL_LIBS ${PROJECT_SOURCE_DIR}/internal-complibs)
  163. -
  164. # Hide symbols by default unless they're specifically exported.
  165. # This makes it easier to keep the set of exported symbols the
  166. # same across all compilers/platforms.
  167. set(CMAKE_C_VISIBILITY_PRESET hidden)
  168. -# includes
  169. -set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR})
  170. -if(NOT DEACTIVATE_LZ4)
  171. - if (LZ4_FOUND)
  172. - set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${LZ4_INCLUDE_DIR})
  173. - else(LZ4_FOUND)
  174. - set(LZ4_LOCAL_DIR ${INTERNAL_LIBS}/lz4-1.9.1)
  175. - set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${LZ4_LOCAL_DIR})
  176. - endif(LZ4_FOUND)
  177. -endif(NOT DEACTIVATE_LZ4)
  178. -
  179. -if(NOT DEACTIVATE_SNAPPY)
  180. - if (SNAPPY_FOUND)
  181. - set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${SNAPPY_INCLUDE_DIR})
  182. - else(SNAPPY_FOUND)
  183. - set(SNAPPY_LOCAL_DIR ${INTERNAL_LIBS}/snappy-1.1.1)
  184. - set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${SNAPPY_LOCAL_DIR})
  185. - endif(SNAPPY_FOUND)
  186. -endif(NOT DEACTIVATE_SNAPPY)
  187. -
  188. -if(NOT DEACTIVATE_ZLIB)
  189. - if (ZLIB_FOUND)
  190. - set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR})
  191. - else(ZLIB_FOUND)
  192. - set(ZLIB_LOCAL_DIR ${INTERNAL_LIBS}/zlib-1.2.8)
  193. - set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZLIB_LOCAL_DIR})
  194. - endif(ZLIB_FOUND)
  195. -endif(NOT DEACTIVATE_ZLIB)
  196. -
  197. -if (NOT DEACTIVATE_ZSTD)
  198. - if (ZSTD_FOUND)
  199. - set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZSTD_INCLUDE_DIR})
  200. - else (ZSTD_FOUND)
  201. - set(ZSTD_LOCAL_DIR ${INTERNAL_LIBS}/zstd-1.4.1)
  202. - set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZSTD_LOCAL_DIR} ${ZSTD_LOCAL_DIR}/common)
  203. - endif (ZSTD_FOUND)
  204. -endif (NOT DEACTIVATE_ZSTD)
  205. -
  206. -include_directories(${BLOSC_INCLUDE_DIRS})
  207. # library sources
  208. set(SOURCES blosc.c blosclz.c fastcopy.c shuffle-generic.c bitshuffle-generic.c
  209. @@ -73,53 +32,13 @@ if(WIN32)
  210. message(STATUS "using the internal pthread library for win32 systems.")
  211. set(SOURCES ${SOURCES} win32/pthread.c)
  212. else(NOT Threads_FOUND)
  213. - set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
  214. + list(APPEND LIBS Threads::Threads)
  215. endif(NOT Threads_FOUND)
  216. else(WIN32)
  217. find_package(Threads REQUIRED)
  218. - set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
  219. + list(APPEND LIBS Threads::Threads)
  220. endif(WIN32)
  221. -if(NOT DEACTIVATE_LZ4)
  222. - if(LZ4_FOUND)
  223. - set(LIBS ${LIBS} ${LZ4_LIBRARY})
  224. - else(LZ4_FOUND)
  225. - file(GLOB LZ4_FILES ${LZ4_LOCAL_DIR}/*.c)
  226. - set(SOURCES ${SOURCES} ${LZ4_FILES})
  227. - endif(LZ4_FOUND)
  228. -endif(NOT DEACTIVATE_LZ4)
  229. -
  230. -if(NOT DEACTIVATE_SNAPPY)
  231. - if(SNAPPY_FOUND)
  232. - set(LIBS ${LIBS} ${SNAPPY_LIBRARY})
  233. - else(SNAPPY_FOUND)
  234. - file(GLOB SNAPPY_FILES ${SNAPPY_LOCAL_DIR}/*.cc)
  235. - set(SOURCES ${SOURCES} ${SNAPPY_FILES})
  236. - endif(SNAPPY_FOUND)
  237. -endif(NOT DEACTIVATE_SNAPPY)
  238. -
  239. -if(NOT DEACTIVATE_ZLIB)
  240. - if(ZLIB_FOUND)
  241. - set(LIBS ${LIBS} ${ZLIB_LIBRARY})
  242. - else(ZLIB_FOUND)
  243. - file(GLOB ZLIB_FILES ${ZLIB_LOCAL_DIR}/*.c)
  244. - set(SOURCES ${SOURCES} ${ZLIB_FILES})
  245. - endif(ZLIB_FOUND)
  246. -endif(NOT DEACTIVATE_ZLIB)
  247. -
  248. -if (NOT DEACTIVATE_ZSTD)
  249. - if (ZSTD_FOUND)
  250. - set(LIBS ${LIBS} ${ZSTD_LIBRARY})
  251. - else (ZSTD_FOUND)
  252. - file(GLOB ZSTD_FILES
  253. - ${ZSTD_LOCAL_DIR}/common/*.c
  254. - ${ZSTD_LOCAL_DIR}/compress/*.c
  255. - ${ZSTD_LOCAL_DIR}/decompress/*.c)
  256. - set(SOURCES ${SOURCES} ${ZSTD_FILES})
  257. - endif (ZSTD_FOUND)
  258. -endif (NOT DEACTIVATE_ZSTD)
  259. -
  260. -
  261. # targets
  262. if (BUILD_SHARED)
  263. add_library(blosc_shared SHARED ${SOURCES})
  264. @@ -191,14 +110,17 @@ if (BUILD_TESTS)
  265. endif()
  266. endif()
  267. +add_library(blosc INTERFACE)
  268. +
  269. if (BUILD_SHARED)
  270. - target_link_libraries(blosc_shared ${LIBS})
  271. - target_include_directories(blosc_shared PUBLIC ${BLOSC_INCLUDE_DIRS})
  272. + target_link_libraries(blosc_shared PRIVATE ${LIBS})
  273. + target_include_directories(blosc_shared PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
  274. + target_link_libraries(blosc INTERFACE blosc_shared)
  275. endif()
  276. if (BUILD_TESTS)
  277. - target_link_libraries(blosc_shared_testing ${LIBS})
  278. - target_include_directories(blosc_shared_testing PUBLIC ${BLOSC_INCLUDE_DIRS})
  279. + target_link_libraries(blosc_shared_testing PRIVATE ${LIBS})
  280. + target_include_directories(blosc_shared_testing PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
  281. endif()
  282. if(BUILD_STATIC)
  283. @@ -207,17 +129,31 @@ if(BUILD_STATIC)
  284. if (MSVC)
  285. set_target_properties(blosc_static PROPERTIES PREFIX lib)
  286. endif()
  287. - target_link_libraries(blosc_static ${LIBS})
  288. - target_include_directories(blosc_static PUBLIC ${BLOSC_INCLUDE_DIRS})
  289. + # With the static library, cmake has to deal with transitive dependencies
  290. + target_link_libraries(blosc_static PRIVATE ${LIBS})
  291. + target_include_directories(blosc_static PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
  292. + if (NOT BUILD_SHARED)
  293. + target_link_libraries(blosc INTERFACE blosc_static)
  294. + endif()
  295. endif(BUILD_STATIC)
  296. +
  297. # install
  298. if(BLOSC_INSTALL)
  299. install(FILES blosc.h blosc-export.h DESTINATION include COMPONENT DEV)
  300. + set(_inst_libs "blosc")
  301. if(BUILD_SHARED)
  302. - install(TARGETS blosc_shared DESTINATION ${lib_dir} COMPONENT LIB)
  303. + list(APPEND _inst_libs blosc_shared)
  304. endif(BUILD_SHARED)
  305. if(BUILD_STATIC)
  306. - install(TARGETS blosc_static DESTINATION ${lib_dir} COMPONENT DEV)
  307. + list(APPEND _inst_libs blosc_static)
  308. endif(BUILD_STATIC)
  309. +
  310. + install(TARGETS ${_inst_libs}
  311. + EXPORT BloscTargets
  312. + LIBRARY DESTINATION ${lib_dir}
  313. + ARCHIVE DESTINATION ${lib_dir}
  314. + RUNTIME DESTINATION bin
  315. + COMPONENT DEV
  316. + INCLUDES DESTINATION include)
  317. endif(BLOSC_INSTALL)
  318. diff --git a/cmake/FindLZ4.cmake b/cmake/FindLZ4.cmake
  319. index e581a80..05de6ef 100644
  320. --- a/cmake/FindLZ4.cmake
  321. +++ b/cmake/FindLZ4.cmake
  322. @@ -5,6 +5,10 @@ find_library(LZ4_LIBRARY NAMES lz4)
  323. if (LZ4_INCLUDE_DIR AND LZ4_LIBRARY)
  324. set(LZ4_FOUND TRUE)
  325. message(STATUS "Found LZ4 library: ${LZ4_LIBRARY}")
  326. + add_library(LZ4::LZ4 UNKNOWN IMPORTED)
  327. + set_target_properties(LZ4::LZ4 PROPERTIES
  328. + IMPORTED_LOCATION ${LZ4_LIBRARY}
  329. + INTERFACE_INCLUDE_DIRECTORIES ${LZ4_INCLUDE_DIR})
  330. else ()
  331. message(STATUS "No LZ4 library found. Using internal sources.")
  332. -endif ()
  333. +endif ()
  334. \ No newline at end of file
  335. diff --git a/cmake/FindSnappy.cmake b/cmake/FindSnappy.cmake
  336. index 688d4d5..21dbee1 100644
  337. --- a/cmake/FindSnappy.cmake
  338. +++ b/cmake/FindSnappy.cmake
  339. @@ -3,8 +3,12 @@ find_path(SNAPPY_INCLUDE_DIR snappy-c.h)
  340. find_library(SNAPPY_LIBRARY NAMES snappy)
  341. if (SNAPPY_INCLUDE_DIR AND SNAPPY_LIBRARY)
  342. - set(SNAPPY_FOUND TRUE)
  343. + set(Snappy_FOUND TRUE)
  344. + add_library(Snappy::snappy UNKNOWN IMPORTED)
  345. + set_target_properties(Snappy::snappy PROPERTIES
  346. + IMPORTED_LOCATION ${SNAPPY_LIBRARY}
  347. + INTERFACE_INCLUDE_DIRECTORIES ${SNAPPY_INCLUDE_DIR})
  348. message(STATUS "Found SNAPPY library: ${SNAPPY_LIBRARY}")
  349. else ()
  350. message(STATUS "No snappy found. Using internal sources.")
  351. -endif ()
  352. +endif ()
  353. \ No newline at end of file
  354. diff --git a/cmake/FindZstd.cmake b/cmake/FindZstd.cmake
  355. index 7db4bb9..cabc2f8 100644
  356. --- a/cmake/FindZstd.cmake
  357. +++ b/cmake/FindZstd.cmake
  358. @@ -3,8 +3,12 @@ find_path(ZSTD_INCLUDE_DIR zstd.h)
  359. find_library(ZSTD_LIBRARY NAMES zstd)
  360. if (ZSTD_INCLUDE_DIR AND ZSTD_LIBRARY)
  361. - set(ZSTD_FOUND TRUE)
  362. + set(Zstd_FOUND TRUE)
  363. + add_library(Zstd::Zstd UNKNOWN IMPORTED)
  364. + set_target_properties(Zstd::Zstd PROPERTIES
  365. + IMPORTED_LOCATION ${ZSTD_LIBRARY}
  366. + INTERFACE_INCLUDE_DIRECTORIES ${ZSTD_INCLUDE_DIR})
  367. message(STATUS "Found Zstd library: ${ZSTD_LIBRARY}")
  368. else ()
  369. message(STATUS "No Zstd library found. Using internal sources.")
  370. -endif ()
  371. +endif ()
  372. \ No newline at end of file
  373. diff --git a/cmake_config.cmake.in b/cmake_config.cmake.in
  374. new file mode 100644
  375. index 0000000..0f6af24
  376. --- /dev/null
  377. +++ b/cmake_config.cmake.in
  378. @@ -0,0 +1,24 @@
  379. +include(CMakeFindDependencyMacro)
  380. +
  381. +include("${CMAKE_CURRENT_LIST_DIR}/BloscTargets.cmake")
  382. +
  383. +function(_blosc_remap_configs from_Cfg to_Cfg)
  384. + string(TOUPPER ${from_Cfg} from_CFG)
  385. + string(TOLOWER ${from_Cfg} from_cfg)
  386. +
  387. + if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/BloscTargets-${from_cfg}.cmake)
  388. + foreach(tgt IN ITEMS blosc_static blosc_shared blosc)
  389. + if(TARGET Blosc::${tgt})
  390. + set_target_properties(Blosc::${tgt} PROPERTIES
  391. + MAP_IMPORTED_CONFIG_${from_CFG} ${to_Cfg})
  392. + endif()
  393. + endforeach()
  394. + endif()
  395. +endfunction()
  396. +
  397. +# MSVC will try to link RelWithDebInfo or MinSizeRel target with debug config
  398. +# if no matching installation is present which would result in link errors.
  399. +if(MSVC)
  400. + _blosc_remap_configs(RelWithDebInfo Release)
  401. + _blosc_remap_configs(MinSizeRel Release)
  402. +endif()
  403. diff --git a/internal-complibs/CMakeLists.txt b/internal-complibs/CMakeLists.txt
  404. new file mode 100644
  405. index 0000000..4586efa
  406. --- /dev/null
  407. +++ b/internal-complibs/CMakeLists.txt
  408. @@ -0,0 +1,35 @@
  409. +macro(add_lib_target pkg tgt incdir files)
  410. + string(TOUPPER ${pkg} TGT)
  411. + if(NOT DEACTIVATE_${TGT} AND NOT ${pkg}_FOUND)
  412. + add_library(${tgt}_objs OBJECT ${files})
  413. + add_library(${tgt} INTERFACE)
  414. + target_include_directories(${tgt}_objs PRIVATE $<BUILD_INTERFACE:${incdir}>)
  415. + target_include_directories(${tgt} INTERFACE $<BUILD_INTERFACE:${incdir}>)
  416. + #set_target_properties(${tgt} PROPERTIES INTERFACE_SOURCES "$<TARGET_OBJECTS:${tgt}_objs>")
  417. + set_target_properties(${tgt}_objs PROPERTIES POSITION_INDEPENDENT_CODE ON)
  418. + target_sources(${tgt} INTERFACE "$<BUILD_INTERFACE:$<TARGET_OBJECTS:${tgt}_objs>>")
  419. + add_library(${pkg}::${tgt} ALIAS ${tgt})
  420. +
  421. + # This creates dummy (empty) interface targets in the exported config.
  422. + install(TARGETS ${tgt} EXPORT BloscTargets INCLUDES DESTINATION include)
  423. + endif()
  424. + unset(TGT)
  425. +endmacro()
  426. +
  427. +set(ZLIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zlib-1.2.8)
  428. +file(GLOB ZLIB_FILES ${ZLIB_DIR}/*.c)
  429. +add_lib_target(ZLIB ZLIB ${ZLIB_DIR} "${ZLIB_FILES}")
  430. +
  431. +set(SNAPPY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/snappy-1.1.1)
  432. +file(GLOB SNAPPY_FILES ${SNAPPY_DIR}/*.cc)
  433. +add_lib_target(Snappy snappy ${SNAPPY_DIR} "${SNAPPY_FILES}")
  434. +
  435. +set(LZ4_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lz4-1.9.1)
  436. +file(GLOB LZ4_FILES ${LZ4_DIR}/*.c)
  437. +add_lib_target(LZ4 LZ4 ${LZ4_DIR} "${LZ4_FILES}")
  438. +
  439. +set(ZSTD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zstd-1.4.1)
  440. +file(GLOB ZSTD_FILES ${ZSTD_DIR}/common/*.c ${ZSTD_DIR}/compress/*.c ${ZSTD_DIR}/decompress/*.c)
  441. +add_lib_target(Zstd Zstd ${ZSTD_DIR} "${ZSTD_FILES}")
  442. +target_include_directories(Zstd INTERFACE $<BUILD_INTERFACE:${ZSTD_DIR}/common>)
  443. +target_include_directories(Zstd_objs PRIVATE $<BUILD_INTERFACE:${ZSTD_DIR}/common>)
  444. \ No newline at end of file
  445. --
  446. 2.16.2.windows.1