Skip to content

Commit

Permalink
Makes it possible to use the lib through FetchContent or ExternalProj…
Browse files Browse the repository at this point in the history
…ect_Add
  • Loading branch information
dsvi authored and hswong3i committed Mar 27, 2024
1 parent 280fdf5 commit 13deffd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions build/cmake/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ if(NOT ZSTD_BUILD_SHARED AND NOT ZSTD_BUILD_STATIC)
message(SEND_ERROR "You need to build at least one flavor of libzstd")
endif()

# Define library directory, where sources and header files are located
include_directories(${LIBRARY_DIR} ${LIBRARY_DIR}/common)

file(GLOB CommonSources ${LIBRARY_DIR}/common/*.c)
file(GLOB CompressSources ${LIBRARY_DIR}/compress/*.c)
if (MSVC)
Expand Down Expand Up @@ -115,10 +112,14 @@ macro (add_definition target var)
endif ()
endmacro ()

# Define include directories, where header files are located
set(LIBRARY_INCLUDES "${LIBRARY_DIR} ${LIBRARY_DIR}/common")

# Split project to static and shared libraries build
set(library_targets)
if (ZSTD_BUILD_SHARED)
add_library(libzstd_shared SHARED ${Sources} ${Headers} ${PlatformDependResources})
target_include_directories(libzstd_shared PUBLIC $<BUILD_INTERFACE:${LIBRARY_INCLUDES}>)
list(APPEND library_targets libzstd_shared)
if (ZSTD_MULTITHREAD_SUPPORT)
set_property(TARGET libzstd_shared APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
Expand All @@ -132,6 +133,7 @@ if (ZSTD_BUILD_SHARED)
endif ()
if (ZSTD_BUILD_STATIC)
add_library(libzstd_static STATIC ${Sources} ${Headers})
target_include_directories(libzstd_static PUBLIC $<BUILD_INTERFACE:${LIBRARY_INCLUDES}>)
list(APPEND library_targets libzstd_static)
if (ZSTD_MULTITHREAD_SUPPORT)
set_property(TARGET libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
Expand Down

0 comments on commit 13deffd

Please sign in to comment.