@@ -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 )
@@ -26,21 +26,43 @@ function(find_package_or_fetch)
2626 find_package (${actual_pkg_name} ${FIND_PACKAGE_OPTIONS} )
2727 endif ()
2828
29- if (FETCH_DEPENDENCIES_WITH_CMAKE STREQUAL "ON" OR FETCH_DEPENDENCIES_WITH_CMAKE STREQUAL "MISSING" )
30- if (NOT ${actual_pkg_name} _FOUND)
31- message (STATUS "📦 Fetching ${arg_PACKAGE_NAME} " )
32- FetchContent_Declare(
33- ${arg_PACKAGE_NAME}
34- GIT_SHALLOW TRUE
35- GIT_REPOSITORY ${arg_GIT_REPOSITORY}
36- GIT_TAG ${arg_TAG}
37- GIT_PROGRESS TRUE
38- SYSTEM
39- EXCLUDE_FROM_ALL )
40- FetchContent_MakeAvailable(${arg_PACKAGE_NAME} )
41- message (STATUS "\t ✅ Fetched ${arg_PACKAGE_NAME} " )
42- else ()
29+ if (arg_GIT_REPOSITORY)
30+ if (FETCH_DEPENDENCIES_WITH_CMAKE STREQUAL "ON" OR FETCH_DEPENDENCIES_WITH_CMAKE STREQUAL "MISSING" )
31+ if (NOT ${actual_pkg_name} _FOUND)
32+ message (STATUS "📦 Fetching ${arg_PACKAGE_NAME} " )
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
41+ ${arg_PACKAGE_NAME}
42+ GIT_SHALLOW TRUE
43+ GIT_REPOSITORY ${arg_GIT_REPOSITORY}
44+ GIT_TAG ${arg_TAG}
45+ GIT_PROGRESS TRUE
46+ SYSTEM
47+ 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} )
52+ FetchContent_MakeAvailable(${arg_PACKAGE_NAME} )
53+ message (STATUS "\t ✅ Fetched ${arg_PACKAGE_NAME} " )
54+ else ()
55+ message (STATUS "📦 ${actual_pkg_name} found here: ${${actual_pkg_name} _DIR}" )
56+ endif ()
57+ endif ()
58+ else ()
59+ # No GIT_REPOSITORY provided - only find_package is attempted
60+ if (${actual_pkg_name} _FOUND)
4361 message (STATUS "📦 ${actual_pkg_name} found here: ${${actual_pkg_name} _DIR}" )
62+ elseif (FETCH_DEPENDENCIES_WITH_CMAKE STREQUAL "OFF" )
63+ message (FATAL_ERROR "Could not find ${actual_pkg_name} and no GIT_REPOSITORY provided for fetching" )
64+ else ()
65+ message (WARNING "Could not find ${actual_pkg_name} and no GIT_REPOSITORY provided for fetching" )
4466 endif ()
4567 endif ()
4668endfunction ()
@@ -52,14 +74,17 @@ endif()
5274find_package_or_fetch(
5375 PACKAGE_NAME sparrow
5476 GIT_REPOSITORY https://github.com/man-group/sparrow.git
55- TAG 1.2 .0
77+ TAG 1.3 .0
5678)
5779unset (CREATE_JSON_READER_TARGET)
5880
5981if (NOT TARGET sparrow::sparrow)
6082 add_library (sparrow::sparrow ALIAS sparrow)
6183endif ()
6284if (${SPARROW_IPC_BUILD_TESTS} )
85+ find_package_or_fetch(
86+ PACKAGE_NAME sparrow-json-reader
87+ )
6388 if (NOT TARGET sparrow::json_reader)
6489 add_library (sparrow::json_reader ALIAS json_reader)
6590 endif ()
@@ -79,6 +104,50 @@ if(NOT TARGET flatbuffers::flatbuffers)
79104endif ()
80105unset (FLATBUFFERS_BUILD_TESTS CACHE )
81106
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+
126+ find_package_or_fetch(
127+ PACKAGE_NAME zstd
128+ GIT_REPOSITORY https://github.com/facebook/zstd.git
129+ TAG v1.5.7
130+ SOURCE_SUBDIR build /cmake
131+ CMAKE_ARGS
132+ "ZSTD_BUILD_PROGRAMS=OFF"
133+ )
134+
135+ if (NOT TARGET zstd::libzstd)
136+ if (SPARROW_IPC_BUILD_SHARED)
137+ if (TARGET zstd::libzstd_shared) # Linux case
138+ add_library (zstd::libzstd ALIAS zstd::libzstd_shared)
139+ elseif (TARGET libzstd_shared) # Windows case
140+ add_library (zstd::libzstd ALIAS libzstd_shared)
141+ endif ()
142+ else ()
143+ if (TARGET zstd::libzstd_static) # Linux case
144+ add_library (zstd::libzstd ALIAS zstd::libzstd_static)
145+ elseif (TARGET libzstd_static) # Windows case
146+ add_library (zstd::libzstd ALIAS libzstd_static)
147+ endif ()
148+ endif ()
149+ endif ()
150+
82151if (SPARROW_IPC_BUILD_TESTS)
83152 find_package_or_fetch(
84153 PACKAGE_NAME doctest
@@ -109,10 +178,18 @@ if(SPARROW_IPC_BUILD_TESTS)
109178 )
110179 message (STATUS "\t ✅ Fetched arrow-testing" )
111180
112- # Iterate over all the files in the arrow-testing-data source directiory. When it's a gz, extract in place.
113- file (GLOB_RECURSE arrow_testing_data_targz_files CONFIGURE_DEPENDS
181+ # Fetch all the files in the cpp-21.0.0 directory
182+ file (GLOB_RECURSE arrow_testing_data_targz_files_cpp_21 CONFIGURE_DEPENDS
114183 "${arrow-testing_SOURCE_DIR}/data/arrow-ipc-stream/integration/cpp-21.0.0/*.json.gz"
115184 )
185+ # Fetch all the files in the 2.0.0-compression directory
186+ file (GLOB_RECURSE arrow_testing_data_targz_files_compression CONFIGURE_DEPENDS
187+ "${arrow-testing_SOURCE_DIR}/data/arrow-ipc-stream/integration/2.0.0-compression/*.json.gz"
188+ )
189+
190+ # Combine lists of files
191+ list (APPEND arrow_testing_data_targz_files ${arrow_testing_data_targz_files_cpp_21} ${arrow_testing_data_targz_files_compression} )
192+ # Iterate over all the files in the arrow-testing-data source directory. When it's a gz, extract in place.
116193 foreach (file_path IN LISTS arrow_testing_data_targz_files)
117194 cmake_path(GET file_path PARENT_PATH parent_dir)
118195 cmake_path(GET file_path STEM filename)
@@ -128,5 +205,4 @@ if(SPARROW_IPC_BUILD_TESTS)
128205 endif ()
129206 endif ()
130207 endforeach ()
131-
132208endif ()
0 commit comments