Skip to content

Commit 76c4f02

Browse files
committed
Fix fetching lz4
1 parent 5db7ecc commit 76c4f02

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

.github/workflows/windows.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ jobs:
7272
7373
- name: Configure using cmake
7474
run: |
75-
#choco install pkgconfiglite
7675
cmake -S ./ -B ./build \
7776
-DSPARROW_IPC_BUILD_SHARED=${{ matrix.build_shared }} \
7877
-DSPARROW_IPC_BUILD_TESTS=ON \

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,6 @@ target_link_libraries(sparrow-ipc
245245
lz4::lz4
246246
)
247247

248-
# target_include_directories(sparrow-ipc PRIVATE ${LZ4_INCLUDE_DIRS})
249-
# target_link_libraries(sparrow-ipc PRIVATE ${LZ4_LIBRARIES})
250-
251248
# Ensure generated headers are available when building sparrow-ipc
252249
add_dependencies(sparrow-ipc generate_flatbuffers_headers)
253250

cmake/external_dependencies.cmake

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ endif()
1111

1212
function(find_package_or_fetch)
1313
set(options)
14-
set(oneValueArgs CONAN_PKG_NAME PACKAGE_NAME GIT_REPOSITORY TAG)
15-
set(multiValueArgs)
14+
set(oneValueArgs CONAN_PKG_NAME PACKAGE_NAME GIT_REPOSITORY TAG SOURCE_SUBDIR)
15+
set(multiValueArgs CMAKE_ARGS)
1616
cmake_parse_arguments(PARSE_ARGV 0 arg
1717
"${options}" "${oneValueArgs}" "${multiValueArgs}"
1818
)
@@ -29,18 +29,26 @@ function(find_package_or_fetch)
2929
if(FETCH_DEPENDENCIES_WITH_CMAKE STREQUAL "ON" OR FETCH_DEPENDENCIES_WITH_CMAKE STREQUAL "MISSING")
3030
if(NOT ${actual_pkg_name}_FOUND)
3131
message(STATUS "📦 Fetching ${arg_PACKAGE_NAME}")
32-
FetchContent_Declare(
32+
# Apply CMAKE_ARGS before fetching
33+
foreach(cmake_arg ${arg_CMAKE_ARGS})
34+
string(REGEX MATCH "^([^=]+)=(.*)$" _ ${cmake_arg})
35+
if(CMAKE_MATCH_1)
36+
set(${CMAKE_MATCH_1} ${CMAKE_MATCH_2} CACHE BOOL "" FORCE)
37+
endif()
38+
endforeach()
39+
set(fetch_args
3340
${arg_PACKAGE_NAME}
3441
GIT_SHALLOW TRUE
3542
GIT_REPOSITORY ${arg_GIT_REPOSITORY}
3643
GIT_TAG ${arg_TAG}
3744
GIT_PROGRESS TRUE
3845
SYSTEM
3946
EXCLUDE_FROM_ALL)
47+
if(arg_SOURCE_SUBDIR)
48+
list(APPEND fetch_args SOURCE_SUBDIR ${arg_SOURCE_SUBDIR})
49+
endif()
50+
FetchContent_Declare(${fetch_args})
4051
FetchContent_MakeAvailable(${arg_PACKAGE_NAME})
41-
# get_property(all_targets GLOBAL PROPERTY TARGETS)
42-
get_property(all_targets TARGET ${arg_PACKAGE_NAME} PROPERTY ALL_TARGETS)
43-
message(STATUS "Available targets after ${arg_PACKAGE_NAME} build: ${all_targets}")
4452
message(STATUS "\t✅ Fetched ${arg_PACKAGE_NAME}")
4553
else()
4654
message(STATUS "📦 ${actual_pkg_name} found here: ${${actual_pkg_name}_DIR}")
@@ -82,29 +90,23 @@ if(NOT TARGET flatbuffers::flatbuffers)
8290
endif()
8391
unset(FLATBUFFERS_BUILD_TESTS CACHE)
8492

93+
# Fetching lz4
94+
# Disable bundled mode to allow shared libraries if needed
95+
# lz4 is built as static by default if bundled
96+
# set(LZ4_BUNDLED_MODE OFF CACHE BOOL "" FORCE)
97+
# set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
8598
find_package_or_fetch(
8699
PACKAGE_NAME lz4
87100
GIT_REPOSITORY https://github.com/lz4/lz4.git
88101
TAG v1.10.0
102+
SOURCE_SUBDIR build/cmake
103+
CMAKE_ARGS
104+
"LZ4_BUILD_CLI=OFF"
105+
"LZ4_BUILD_LEGACY_LZ4C=OFF"
89106
)
90107

91108
if(NOT TARGET lz4::lz4)
92-
if(TARGET LZ4::lz4)
93-
message(STATUS "📦 Found LZ4::lz4")
94-
add_library(lz4::lz4 ALIAS LZ4::lz4)
95-
elseif(TARGET LZ4::LZ4)
96-
message(STATUS "📦 Found LZ4::LZ4")
97-
add_library(lz4::lz4 ALIAS LZ4::LZ4)
98-
elseif(TARGET lz4_static)
99-
message(STATUS "📦 Found lz4_static")
100-
add_library(lz4::lz4 ALIAS lz4_static)
101-
elseif(TARGET lz4_shared)
102-
message(STATUS "📦 Found lz4_shared")
103-
add_library(lz4::lz4 ALIAS lz4_shared)
104-
else()
105-
message(STATUS "📦 NOTHING Found")
106-
add_library(lz4::lz4 ALIAS lz4)
107-
endif()
109+
add_library(lz4::lz4 ALIAS lz4)
108110
endif()
109111

110112
if(SPARROW_IPC_BUILD_TESTS)

0 commit comments

Comments
 (0)