@@ -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 )
@@ -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)
8290endif ()
8391unset (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)
8598find_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
91108if (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)
108110endif ()
109111
110112if (SPARROW_IPC_BUILD_TESTS)
0 commit comments