-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow one to use system ZSTD #131
Conversation
Looks good thanks a lot |
The proposed change doesn't work on FreeBSD 14.1:
I need to add
Instead of appending diff --git a/CMakeLists.txt b/CMakeLists.txt
index a9625d4..b92fba5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,7 @@ if(CMAKE_PROJECT_NAME STREQUAL "chdr")
endif()
option(INSTALL_STATIC_LIBS "Install static libraries" OFF)
option(WITH_SYSTEM_ZLIB "Use system provided zlib library" OFF)
+option(WITH_SYSTEM_ZSTD "Use system provided zstd library" OFF)
option(BUILD_LTO "Compile libchdr with link-time optimization if supported" OFF)
if(BUILD_LTO)
@@ -41,11 +42,18 @@ else()
endif()
# zstd
-option(ZSTD_BUILD_SHARED "BUILD SHARED LIBRARIES" OFF)
-option(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" OFF)
-option(ZSTD_LEGACY_SUPPORT "LEGACY SUPPORT" OFF)
-add_subdirectory(deps/zstd-1.5.6/build/cmake EXCLUDE_FROM_ALL)
-list(APPEND CHDR_LIBS libzstd_static)
+if (WITH_SYSTEM_ZSTD)
+ find_path(ZSTD_INCLUDE_DIR NAMES zstd.h)
+ find_library(ZSTD_LIBRARIES NAMES zstd HINTS ${ZSTD_ROOT_DIR}/lib)
+ list(APPEND CHDR_INCLUDES ${ZSTD_INCLUDE_DIR})
+ list(APPEND PLATFORM_LIBS ${ZSTD_LIBRARIES})
+else()
+ option(ZSTD_BUILD_SHARED "BUILD SHARED LIBRARIES" OFF)
+ option(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" OFF)
+ option(ZSTD_LEGACY_SUPPORT "LEGACY SUPPORT" OFF)
+ add_subdirectory(deps/zstd-1.5.6/build/cmake EXCLUDE_FROM_ALL)
+ list(APPEND CHDR_LIBS libzstd_static)
+endif()
#--------------------------------------------------
# chdr
#-------------------------------------------------- Now, CMake should also install diff --git a/CMakeLists.txt b/CMakeLists.txt
index a9625d4..65dcaf6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,7 @@ if(CMAKE_PROJECT_NAME STREQUAL "chdr")
endif()
option(INSTALL_STATIC_LIBS "Install static libraries" OFF)
option(WITH_SYSTEM_ZLIB "Use system provided zlib library" OFF)
+option(WITH_SYSTEM_ZSTD "Use system provided zstd library" OFF)
option(BUILD_LTO "Compile libchdr with link-time optimization if supported" OFF)
if(BUILD_LTO)
@@ -41,11 +42,16 @@ else()
endif()
# zstd
-option(ZSTD_BUILD_SHARED "BUILD SHARED LIBRARIES" OFF)
-option(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" OFF)
-option(ZSTD_LEGACY_SUPPORT "LEGACY SUPPORT" OFF)
-add_subdirectory(deps/zstd-1.5.6/build/cmake EXCLUDE_FROM_ALL)
-list(APPEND CHDR_LIBS libzstd_static)
+if (WITH_SYSTEM_ZSTD)
+ find_package(zstd REQUIRED)
+ list(APPEND PLATFORM_LIBS zstd::libzstd)
+else()
+ option(ZSTD_BUILD_SHARED "BUILD SHARED LIBRARIES" OFF)
+ option(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" OFF)
+ option(ZSTD_LEGACY_SUPPORT "LEGACY SUPPORT" OFF)
+ add_subdirectory(deps/zstd-1.5.6/build/cmake EXCLUDE_FROM_ALL)
+ list(APPEND CHDR_LIBS libzstd_static)
+endif()
#--------------------------------------------------
# chdr
#-------------------------------------------------- @a-detiste: can you test if this also works for you? I think this would be a more proper way to handle this, but I'm no CMake expert. |
Actually it should be |
Hi, my CMake patch was the result of long & hesitant fumbling. Version 2 of yours is much better. |
Thanks! I see you used diff --git a/CMakeLists.txt b/CMakeLists.txt
index a9625d4..65dcaf6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,7 @@ if(CMAKE_PROJECT_NAME STREQUAL "chdr")
endif()
option(INSTALL_STATIC_LIBS "Install static libraries" OFF)
option(WITH_SYSTEM_ZLIB "Use system provided zlib library" OFF)
+option(WITH_SYSTEM_ZSTD "Use system provided zstd library" OFF)
option(BUILD_LTO "Compile libchdr with link-time optimization if supported" OFF)
if(BUILD_LTO)
@@ -41,11 +42,16 @@ else()
endif()
# zstd
-option(ZSTD_BUILD_SHARED "BUILD SHARED LIBRARIES" OFF)
-option(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" OFF)
-option(ZSTD_LEGACY_SUPPORT "LEGACY SUPPORT" OFF)
-add_subdirectory(deps/zstd-1.5.6/build/cmake EXCLUDE_FROM_ALL)
-list(APPEND CHDR_LIBS libzstd_static)
+if (WITH_SYSTEM_ZSTD)
+ find_package(zstd REQUIRED)
+ list(APPEND PLATFORM_LIBS zstd::libzstd_shared)
+else()
+ option(ZSTD_BUILD_SHARED "BUILD SHARED LIBRARIES" OFF)
+ option(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" OFF)
+ option(ZSTD_LEGACY_SUPPORT "LEGACY SUPPORT" OFF)
+ add_subdirectory(deps/zstd-1.5.6/build/cmake EXCLUDE_FROM_ALL)
+ list(APPEND CHDR_LIBS libzstd_static)
+endif()
#--------------------------------------------------
# chdr
#-------------------------------------------------- I think this is also what this PR should use after you have confirmed that this works for you. |
Let’s run CI and merge if okay |
Thanks! |
Hi, I used this to de-vendor ZSTD