Skip to content

Commit 798c257

Browse files
committed
wip
1 parent 33d04e1 commit 798c257

File tree

8 files changed

+62
-66
lines changed

8 files changed

+62
-66
lines changed

.github/workflows/linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
environment-name: build_env
2828
cache-environment: true
2929
- name: Install external dependencies
30-
run: micromamba install -n build_env -y -f ./environment-dev-external-deps.yml
30+
run: micromamba install -n build_env -y -f ./environment-dev.yml
3131
- name: Build sparrow-ipc
3232
run: |
3333
cmake -B build/ -G Ninja \

.github/workflows/osx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
environment-name: build_env
2828
cache-environment: true
2929
- name: Install external dependencies
30-
run: micromamba install -n build_env -y -f ./environment-dev-external-deps.yml
30+
run: micromamba install -n build_env -y -f ./environment-dev.yml
3131
- name: Build sparrow-ipc
3232
run: |
3333
cmake -B build/ -G Ninja \

.github/workflows/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
cache-environment: true
3030
init-shell: cmd.exe
3131
- name: Install external dependencies
32-
run: micromamba install -n build_env -y -f ./environment-dev-external-deps.yml
32+
run: micromamba install -n build_env -y -f ./environment-dev.yml
3333
- name: Build sparrow-ipc
3434
run: |
3535
cmake -B build/ -G Ninja ^

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@
3333

3434
# Build directories
3535
/build*/
36+
.cache
37+
.vscode

CMakeLists.txt

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,14 @@ set(SPARROW_IPC_SRC
4343
${SPARROW_IPC_SOURCE_DIR}/serialize.cpp
4444
)
4545

46-
set(SCHEMA_DIR ${CMAKE_BINARY_DIR}/format)
47-
set(FLATBUFFERS_GENERATED_DIR ${CMAKE_BINARY_DIR}/generated)
46+
# find_program(FLATC_EXECUTABLE flatc)
4847

49-
find_program(FLATC_EXECUTABLE flatc)
50-
51-
if(NOT FLATC_EXECUTABLE)
52-
message(FATAL_ERROR "flatc not found. Please install Flatbuffers.")
53-
endif()
48+
# if(NOT FLATC_EXECUTABLE)
49+
# message(FATAL_ERROR "flatc not found. Please install Flatbuffers.")
50+
# endif()
5451

5552
# Fetch schemas from apache arrow
53+
set(SCHEMA_DIR ${CMAKE_BINARY_DIR}/format)
5654
set(SCHEMA_URLS
5755
"https://raw.githubusercontent.com/apache/arrow/refs/heads/main/format/File.fbs"
5856
"https://raw.githubusercontent.com/apache/arrow/refs/heads/main/format/Message.fbs"
@@ -68,14 +66,17 @@ file(MAKE_DIRECTORY ${SCHEMA_DIR})
6866
set(FLATBUFFERS_SCHEMAS "")
6967
foreach(url IN LISTS SCHEMA_URLS)
7068
get_filename_component(filename ${url} NAME)
71-
message(STATUS "Downloading schema: ${url}")
72-
file(DOWNLOAD ${url} ${SCHEMA_DIR}/${filename}
73-
STATUS status
74-
SHOW_PROGRESS)
69+
if(NOT EXISTS ${SCHEMA_DIR}/${filename})
70+
message(STATUS "Downloading schema: ${url}")
71+
file(DOWNLOAD ${url} ${SCHEMA_DIR}/${filename}
72+
STATUS status)
73+
endif()
74+
7575
list(APPEND FLATBUFFERS_SCHEMAS ${SCHEMA_DIR}/${filename})
7676
endforeach()
7777

7878
# Generate Flatbuffers C++ headers from the schemas
79+
set(FLATBUFFERS_GENERATED_DIR ${CMAKE_BINARY_DIR}/generated)
7980
file(MAKE_DIRECTORY ${FLATBUFFERS_GENERATED_DIR})
8081

8182
# Generate output files list
@@ -88,7 +89,7 @@ endforeach()
8889

8990
add_custom_command(
9091
OUTPUT ${FLATBUFFERS_GENERATED_HEADERS}
91-
COMMAND ${FLATC_EXECUTABLE} --cpp -o ${FLATBUFFERS_GENERATED_DIR} --cpp-std c++17 --scoped-enums ${FLATBUFFERS_SCHEMAS}
92+
COMMAND flatc --cpp -o ${FLATBUFFERS_GENERATED_DIR} --cpp-std c++17 --scoped-enums ${FLATBUFFERS_SCHEMAS}
9293
DEPENDS ${FLATBUFFERS_SCHEMAS}
9394
COMMENT "Generating FlatBuffers C++ headers from schemas"
9495
)
@@ -102,8 +103,6 @@ add_library(flatbuffers_interface INTERFACE)
102103
target_include_directories(flatbuffers_interface INTERFACE ${FLATBUFFERS_GENERATED_DIR})
103104
add_dependencies(flatbuffers_interface generate_flatbuffers_headers)
104105

105-
find_package(FlatBuffers CONFIG REQUIRED)
106-
107106
add_library(sparrow-ipc ${SPARROW_IPC_LIBRARY_TYPE} ${SPARROW_IPC_SRC} ${SPARROW_IPC_HEADERS})
108107
target_compile_definitions(sparrow-ipc PUBLIC ${SPARROW_IPC_COMPILE_DEFINITIONS})
109108

cmake/external_dependencies.cmake

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,52 +9,57 @@ else()
99
set(FIND_PACKAGE_OPTIONS QUIET)
1010
endif()
1111

12-
if(NOT FETCH_DEPENDENCIES_WITH_CMAKE STREQUAL "ON")
13-
find_package(sparrow CONFIG ${FIND_PACKAGE_OPTIONS})
14-
endif()
15-
16-
if(FETCH_DEPENDENCIES_WITH_CMAKE STREQUAL "ON" OR FETCH_DEPENDENCIES_WITH_CMAKE STREQUAL "MISSING")
17-
if(NOT sparrow_FOUND)
18-
# Fetching from `main` while waiting for a new tag
19-
# (https://github.com/man-group/sparrow/pull/463 needed)
20-
# TODO Fetch last version when available
21-
set(SPARROW_TAG main)
22-
message(STATUS "📦 Fetching sparrow ${SPARROW_TAG}")
23-
FetchContent_Declare(
24-
sparrow
25-
GIT_SHALLOW TRUE
26-
GIT_REPOSITORY https://github.com/man-group/sparrow.git
27-
GIT_TAG ${SPARROW_TAG}
28-
GIT_PROGRESS TRUE
29-
SYSTEM
30-
EXCLUDE_FROM_ALL)
31-
FetchContent_MakeAvailable(sparrow)
32-
message(STATUS "\t✅ Fetched sparrow ${SPARROW_TAG}")
33-
else()
34-
message(STATUS "📦 sparrow found here: ${sparrow_DIR}")
35-
endif()
36-
endif()
37-
38-
if(SPARROW_IPC_BUILD_TESTS)
12+
function(find_package_or_fetch)
13+
set(options)
14+
set(oneValueArgs PACKAGE_NAME VERSION GIT_REPOSITORY TAG)
15+
set(multiValueArgs)
16+
cmake_parse_arguments(PARSE_ARGV 0 arg
17+
"${options}" "${oneValueArgs}" "${multiValueArgs}"
18+
)
3919
if(NOT FETCH_DEPENDENCIES_WITH_CMAKE STREQUAL "ON")
40-
find_package(doctest CONFIG ${FIND_PACKAGE_OPTIONS})
20+
find_package(${arg_PACKAGE_NAME} ${FIND_PACKAGE_OPTIONS})
4121
endif()
4222
if(FETCH_DEPENDENCIES_WITH_CMAKE STREQUAL "ON" OR FETCH_DEPENDENCIES_WITH_CMAKE STREQUAL "MISSING")
43-
if(NOT doctest_FOUND)
44-
set(DOCTEST_VERSION "v2.4.12")
45-
message(STATUS "📦 Fetching doctest ${DOCTEST_VERSION}")
23+
if(NOT ${arg_PACKAGE_NAME}_FOUND)
24+
message(STATUS "📦 Fetching ${arg_PACKAGE_NAME}")
4625
FetchContent_Declare(
47-
doctest
26+
${arg_PACKAGE_NAME}
4827
GIT_SHALLOW TRUE
49-
GIT_REPOSITORY https://github.com/doctest/doctest.git
50-
GIT_TAG ${DOCTEST_VERSION}
28+
GIT_REPOSITORY ${arg_GIT_REPOSITORY}
29+
GIT_TAG ${arg_TAG}
5130
GIT_PROGRESS TRUE
5231
SYSTEM
5332
EXCLUDE_FROM_ALL)
54-
FetchContent_MakeAvailable(doctest)
55-
message(STATUS "\t✅ Fetched doctest ${DOCTEST_VERSION}")
33+
FetchContent_MakeAvailable(${arg_PACKAGE_NAME})
34+
message(STATUS "\t✅ Fetched ${arg_PACKAGE_NAME}")
5635
else()
57-
message(STATUS "📦 doctest found here: ${doctest_DIR}")
36+
message(STATUS "📦 ${arg_PACKAGE_NAME} found here: ${arg_PACKAGE_NAME}_DIR")
5837
endif()
5938
endif()
60-
endif()
39+
endfunction()
40+
41+
find_package_or_fetch(
42+
PACKAGE_NAME sparrow
43+
VERSION 1.0.0
44+
GIT_REPOSITORY https://github.com/man-group/sparrow.git
45+
TAG 1.0.0
46+
)
47+
48+
set(FLATBUFFERS_BUILD_TESTS OFF)
49+
find_package_or_fetch(
50+
PACKAGE_NAME FlatBuffers
51+
VERSION v25.2.10
52+
GIT_REPOSITORY https://github.com/google/flatbuffers.git
53+
TAG v25.2.10
54+
)
55+
add_library(flatbuffers::flatbuffers ALIAS flatbuffers)
56+
unset(FLATBUFFERS_BUILD_TESTS CACHE)
57+
58+
if(SPARROW_IPC_BUILD_TESTS)
59+
find_package_or_fetch(
60+
PACKAGE_NAME doctest
61+
VERSION v2.4.12
62+
GIT_REPOSITORY https://github.com/doctest/doctest.git
63+
TAG v2.4.12
64+
)
65+
endif()

environment-dev-external-deps.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

environment-dev.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ channels:
44
dependencies:
55
# Build dependencies
66
- cmake
7-
- make
87
- ninja
98
- cxx-compiler
10-
# TODO remove to environment-dev-external-deps.yml after handling fetch
119
# Libraries dependencies
1210
- flatbuffers
11+
- sparrow

0 commit comments

Comments
 (0)