@@ -11,8 +11,8 @@ endif()
1111
1212function (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 )
@@ -30,14 +30,25 @@ function(find_package_or_fetch)
3030 if (FETCH_DEPENDENCIES_WITH_CMAKE STREQUAL "ON" OR FETCH_DEPENDENCIES_WITH_CMAKE STREQUAL "MISSING" )
3131 if (NOT ${actual_pkg_name} _FOUND)
3232 message (STATUS "📦 Fetching ${arg_PACKAGE_NAME} " )
33- FetchContent_Declare(
33+ # Apply CMAKE_ARGS before fetching
34+ foreach (cmake_arg ${arg_CMAKE_ARGS} )
35+ string (REGEX MATCH "^([^=]+)=(.*)$" _ ${cmake_arg} )
36+ if (CMAKE_MATCH_1)
37+ set (${CMAKE_MATCH_1} ${CMAKE_MATCH_2} CACHE BOOL "" FORCE)
38+ endif ()
39+ endforeach ()
40+ set (fetch_args
3441 ${arg_PACKAGE_NAME}
3542 GIT_SHALLOW TRUE
3643 GIT_REPOSITORY ${arg_GIT_REPOSITORY}
3744 GIT_TAG ${arg_TAG}
3845 GIT_PROGRESS TRUE
3946 SYSTEM
4047 EXCLUDE_FROM_ALL )
48+ if (arg_SOURCE_SUBDIR)
49+ list (APPEND fetch_args SOURCE_SUBDIR ${arg_SOURCE_SUBDIR} )
50+ endif ()
51+ FetchContent_Declare(${fetch_args} )
4152 FetchContent_MakeAvailable(${arg_PACKAGE_NAME} )
4253 message (STATUS "\t ✅ Fetched ${arg_PACKAGE_NAME} " )
4354 else ()
@@ -93,6 +104,25 @@ if(NOT TARGET flatbuffers::flatbuffers)
93104endif ()
94105unset (FLATBUFFERS_BUILD_TESTS CACHE )
95106
107+ # Fetching lz4
108+ # Disable bundled mode to allow shared libraries if needed
109+ # lz4 is built as static by default if bundled
110+ # set(LZ4_BUNDLED_MODE OFF CACHE BOOL "" FORCE)
111+ # set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
112+ find_package_or_fetch(
113+ PACKAGE_NAME lz4
114+ GIT_REPOSITORY https://github.com/lz4/lz4.git
115+ TAG v1.10.0
116+ SOURCE_SUBDIR build /cmake
117+ CMAKE_ARGS
118+ "LZ4_BUILD_CLI=OFF"
119+ "LZ4_BUILD_LEGACY_LZ4C=OFF"
120+ )
121+
122+ if (NOT TARGET lz4::lz4)
123+ add_library (lz4::lz4 ALIAS lz4)
124+ endif ()
125+
96126if (SPARROW_IPC_BUILD_TESTS)
97127 find_package_or_fetch(
98128 PACKAGE_NAME doctest
@@ -123,10 +153,18 @@ if(SPARROW_IPC_BUILD_TESTS)
123153 )
124154 message (STATUS "\t ✅ Fetched arrow-testing" )
125155
126- # Iterate over all the files in the arrow-testing-data source directiory. When it's a gz, extract in place.
127- file (GLOB_RECURSE arrow_testing_data_targz_files CONFIGURE_DEPENDS
156+ # Fetch all the files in the cpp-21.0.0 directory
157+ file (GLOB_RECURSE arrow_testing_data_targz_files_cpp_21 CONFIGURE_DEPENDS
128158 "${arrow-testing_SOURCE_DIR}/data/arrow-ipc-stream/integration/cpp-21.0.0/*.json.gz"
129159 )
160+ # Fetch all the files in the 2.0.0-compression directory
161+ file (GLOB_RECURSE arrow_testing_data_targz_files_compression CONFIGURE_DEPENDS
162+ "${arrow-testing_SOURCE_DIR}/data/arrow-ipc-stream/integration/2.0.0-compression/*.json.gz"
163+ )
164+
165+ # Combine lists of files
166+ list (APPEND arrow_testing_data_targz_files ${arrow_testing_data_targz_files_cpp_21} ${arrow_testing_data_targz_files_compression} )
167+ # Iterate over all the files in the arrow-testing-data source directory. When it's a gz, extract in place.
130168 foreach (file_path IN LISTS arrow_testing_data_targz_files)
131169 cmake_path(GET file_path PARENT_PATH parent_dir)
132170 cmake_path(GET file_path STEM filename)
@@ -142,5 +180,4 @@ if(SPARROW_IPC_BUILD_TESTS)
142180 endif ()
143181 endif ()
144182 endforeach ()
145-
146183endif ()
0 commit comments