From 223bdd3daa3115f3f686a61524f9adb5c997e9fd Mon Sep 17 00:00:00 2001 From: Guoxin Date: Tue, 31 May 2022 13:05:54 +0800 Subject: [PATCH] cmake with local installed zstd (#9) --- AnnService/CMakeLists.txt | 6 ++++-- CMakeLists.txt | 15 +++------------ Dockerfile | 3 --- Dockerfile.cuda | 1 + 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/AnnService/CMakeLists.txt b/AnnService/CMakeLists.txt index b8d6525e..470f7d65 100644 --- a/AnnService/CMakeLists.txt +++ b/AnnService/CMakeLists.txt @@ -2,8 +2,10 @@ # Licensed under the MIT License. set(AnnService ${PROJECT_SOURCE_DIR}/AnnService) +set(Zstd ${PROJECT_SOURCE_DIR}/ThirdParty/zstd) include_directories(${AnnService}) +include_directories(${Zstd}/lib) file(GLOB_RECURSE HDR_FILES ${AnnService}/inc/Core/*.h ${AnnService}/inc/Helper/*.h) file(GLOB_RECURSE SRC_FILES ${AnnService}/src/Core/*.cpp ${AnnService}/src/Helper/*.cpp) @@ -32,9 +34,9 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") endif() add_library (SPTAGLib SHARED ${SRC_FILES} ${HDR_FILES}) -target_link_libraries (SPTAGLib DistanceUtils zstd::libzstd_shared) +target_link_libraries (SPTAGLib DistanceUtils libzstd_shared) add_library (SPTAGLibStatic STATIC ${SRC_FILES} ${HDR_FILES}) -target_link_libraries (SPTAGLibStatic DistanceUtils zstd::libzstd_static) +target_link_libraries (SPTAGLibStatic DistanceUtils libzstd_static) if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") target_compile_options(SPTAGLibStatic PRIVATE -fPIC) endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index af3148a4..f1b97a45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,20 +90,11 @@ else() message (FATAL_ERROR "Could not find Boost >= 1.67!") endif() -find_package(zstd) -if (zstd_FOUND) - include_directories (${zstd_INCLUDE_DIR}) - link_directories (${zstd_LIBRARY_DIR}) - message (STATUS "Found zstd.") - message (STATUS "Include Path: ${zstd_INCLUDE_DIR}") - message (STATUS "Library Path: ${zstd_LIBRARY_DIR}") - message (STATUS "Library: ${zstd_LIBRARIES}") -else() - message (FATAL_ERROR "Could not find zstd") -endif() - option(GPU "GPU" ON) option(LIBRARYONLY "LIBRARYONLY" OFF) + +add_subdirectory (ThirdParty/zstd/build/cmake) + add_subdirectory (AnnService) add_subdirectory (Test) add_subdirectory (GPUSupport) diff --git a/Dockerfile b/Dockerfile index ef8be89c..f2a9f208 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,9 +14,6 @@ COPY AnnService ./AnnService/ COPY Test ./Test/ COPY Wrappers ./Wrappers/ COPY GPUSupport ./GPUSupport/ - -# install zstd COPY ThirdParty ./ThirdParty/ -RUN cd ThirdParty/zstd/build/cmake && rm -rf builddir && mkdir builddir && cd builddir && cmake .. && make -j$(nproc) && make install RUN mkdir build && cd build && cmake .. && make -j$(nproc) diff --git a/Dockerfile.cuda b/Dockerfile.cuda index 6e984fdf..4d6bf5ee 100644 --- a/Dockerfile.cuda +++ b/Dockerfile.cuda @@ -14,5 +14,6 @@ COPY AnnService ./AnnService/ COPY Test ./Test/ COPY Wrappers ./Wrappers/ COPY GPUSupport ./GPUSupport/ +COPY ThirdParty ./ThirdParty/ RUN mkdir build && cd build && cmake .. && make -j && cd ..