Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
cache-downloads: true

- name: Configure using CMake
run: cmake -G Ninja -Bbuild -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DSPARROW_IPC_BUILD_DOCS=ON
run: cmake -G Ninja -Bbuild -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DSPARROW_IPC_BUILD_DOCS=ON

- name: Build docs target
run: cmake --build build --target docs
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
cmake -G Ninja \
-Bbuild \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX% \
-DCMAKE_PREFIX_PATH=%CONDA_PREFIX% \
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
-DSPARROW_IPC_BUILD_SHARED=${{ matrix.build_shared }} \
-DSPARROW_IPC_BUILD_TESTS=ON

Expand All @@ -50,6 +50,10 @@ jobs:
working-directory: build
run: cmake --build . --target run_tests_with_junit_report

- name: Install
working-directory: build
run: cmake --install .

linux_build_fetch_from_source:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -80,3 +84,7 @@ jobs:
- name: Run tests
working-directory: build
run: cmake --build . --target run_tests_with_junit_report

- name: Install
working-directory: build
run: sudo cmake --install .
12 changes: 10 additions & 2 deletions .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ jobs:
cmake -G Ninja \
-Bbuild \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX% \
-DCMAKE_PREFIX_PATH=%CONDA_PREFIX% \
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
-DSPARROW_IPC_BUILD_SHARED=${{ matrix.build_shared }} \
-DSPARROW_IPC_BUILD_TESTS=ON

Expand All @@ -55,6 +55,10 @@ jobs:
working-directory: build
run: cmake --build . --target run_tests_with_junit_report

- name: Install
working-directory: build
run: cmake --install .

osx_build_fetch_from_source:
runs-on: macos-latest
strategy:
Expand Down Expand Up @@ -90,3 +94,7 @@ jobs:
- name: Run tests
working-directory: build
run: cmake --build . --target run_tests_with_junit_report

- name: Install
working-directory: build
run: sudo cmake --install .
8 changes: 8 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ jobs:
run: |
cmake --build . --config ${{ matrix.build_type }} --target run_tests_with_junit_report

- name: Install
working-directory: build
run: cmake --install . --config ${{ matrix.build_type }}

windows_build_fetch_from_source:
runs-on: windows-latest
strategy:
Expand Down Expand Up @@ -86,6 +90,10 @@ jobs:
working-directory: build
run: cmake --build . --config ${{ matrix.build_type }} --target run_tests_with_junit_report

- name: Install
working-directory: build
run: cmake --install . --config ${{ matrix.build_type }}

- name: Tests coverage
if: matrix.build_type == 'Debug'
working-directory: build
Expand Down
88 changes: 82 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,24 @@ if(ACTIVATE_LINTER)
include(clang-tidy)
endif()

# Versionning
# ===========
# Versioning
# ==========
file(STRINGS "${SPARROW_IPC_INCLUDE_DIR}/sparrow_ipc/config/sparrow_ipc_version.hpp" sparrow_ipc_version_defines
REGEX "constexpr int SPARROW_IPC_VERSION_(MAJOR|MINOR|PATCH)")

foreach(ver ${sparrow_ipc_version_defines})
if(ver MATCHES "constexpr int SPARROW_VERSION_(MAJOR|MINOR|PATCH) = ([0-9]+);$")
if(ver MATCHES "constexpr int SPARROW_IPC_VERSION_(MAJOR|MINOR|PATCH) = ([0-9]+);$")
set(PROJECT_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "")
endif()
endforeach()

set(CMAKE_PROJECT_VERSION
${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})

message(STATUS "Building sparrow_ipc v${CMAKE_PROJECT_VERSION}")
message(STATUS "Building sparrow-ipc v${CMAKE_PROJECT_VERSION}")

# Binary version
# See the following URL for explanations about the binary versionning
# See the following URL for more info on the binary versioning
# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html#Updating-version-info
file(STRINGS "${SPARROW_IPC_INCLUDE_DIR}/sparrow_ipc/config/sparrow_ipc_version.hpp" sparrow_ipc_version_defines
REGEX "constexpr int SPARROW_IPC_BINARY_(CURRENT|REVISION|AGE)")
Expand All @@ -60,7 +60,7 @@ endforeach()
set(SPARROW_IPC_BINARY_VERSION
${SPARROW_IPC_BINARY_CURRENT}.${SPARROW_IPC_BINARY_REVISION}.${SPARROW_IPC_BINARY_AGE})

message(STATUS "sparrow_ipc binary version: v${SPARROW_IPC_BINARY_VERSION}")
message(STATUS "sparrow-ipc binary version: v${SPARROW_IPC_BINARY_VERSION}")

# Build options
# =============
Expand Down Expand Up @@ -101,6 +101,7 @@ set(SPARROW_IPC_HEADERS
${SPARROW_IPC_INCLUDE_DIR}/sparrow_ipc/arrow_interface/arrow_schema.hpp
${SPARROW_IPC_INCLUDE_DIR}/sparrow_ipc/arrow_interface/arrow_schema/private_data.hpp
${SPARROW_IPC_INCLUDE_DIR}/sparrow_ipc/config/config.hpp
${SPARROW_IPC_INCLUDE_DIR}/sparrow_ipc/config/sparrow_ipc_version.hpp
${SPARROW_IPC_INCLUDE_DIR}/sparrow_ipc/deserialize_variable_size_binary_array.hpp
${SPARROW_IPC_INCLUDE_DIR}/sparrow_ipc/deserialize_fixedsizebinary_array.hpp
${SPARROW_IPC_INCLUDE_DIR}/sparrow_ipc/deserialize_primitive_array.hpp
Expand Down Expand Up @@ -200,8 +201,26 @@ target_compile_definitions(sparrow-ipc
${SPARROW_IPC_COMPILE_DEFINITIONS})

if(UNIX)
# CMake does not compute the version number of so files as libtool
# does on Linux. Strictly speaking, we should exclude FreeBSD and
# Apple from this, but that would require having different version
# numbers depending on the platform. We prefer to follow the
# libtool pattern everywhere.
math(EXPR SPARROW_IPC_BINARY_COMPATIBLE "${SPARROW_IPC_BINARY_CURRENT} - ${SPARROW_IPC_BINARY_AGE}")
set_target_properties(
sparrow-ipc
PROPERTIES
VERSION "${SPARROW_IPC_BINARY_COMPATIBLE}.${SPARROW_IPC_BINARY_REVISION}.${SPARROW_IPC_BINARY_AGE}"
SOVERSION ${SPARROW_IPC_BINARY_COMPATIBLE}
)
target_compile_options(sparrow-ipc PRIVATE "-fvisibility=hidden")
else()
set_target_properties(
sparrow-ipc
PROPERTIES
VERSION ${SPARROW_IPC_BINARY_VERSION}
SOVERSION ${SPARROW_IPC_BINARY_CURRENT}
)
target_compile_definitions(sparrow-ipc PRIVATE SPARROW_IPC_EXPORTS)
endif()

Expand Down Expand Up @@ -235,3 +254,60 @@ if(SPARROW_IPC_BUILD_DOCS)
message(STATUS "📚 Create docs targets")
add_subdirectory(docs)
endif()

# Installation
# ============
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

# Install CMake configuration files
set(SPARROW_IPC_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}" CACHE
STRING "install path for sparrow-ipcConfig.cmake")

configure_package_config_file(cmake/${PROJECT_NAME}Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${SPARROW_IPC_CMAKECONFIG_INSTALL_DIR})

write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${CMAKE_PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${SPARROW_IPC_CMAKECONFIG_INSTALL_DIR})

# Install target
set(SPARROW_IPC_EXPORTED_TARGETS sparrow-ipc)
if (TARGET flatbuffers)
get_target_property(is_imported flatbuffers IMPORTED)
if(NOT is_imported)
# This means `flatbuffers` was fetched using FetchContent
# We need to export `flatbuffers` target explicitly
list(APPEND SPARROW_IPC_EXPORTED_TARGETS flatbuffers)
if(TARGET ProjectConfig)
# This is an internal target from the flatbuffers build system
# that also needs to be exported
list(APPEND SPARROW_IPC_EXPORTED_TARGETS ProjectConfig)
endif()
endif()
endif()

install(TARGETS ${SPARROW_IPC_EXPORTED_TARGETS}
EXPORT ${PROJECT_NAME}-targets)

install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE sparrow-ipc::
DESTINATION ${SPARROW_IPC_CMAKECONFIG_INSTALL_DIR})

# Makes the project importable from the build directory
export(EXPORT ${PROJECT_NAME}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
NAMESPACE sparrow-ipc::)

# Install headers
install(DIRECTORY ${SPARROW_IPC_INCLUDE_DIR}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PATTERN ".clang-*" EXCLUDE
PATTERN "README.md" EXCLUDE)
Comment on lines +312 to +313
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well this is mirroring what's on sparrow and seems legit, don't we need it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I thought you were talking about the exclude pattern but if you were referring to the headers install, yes we need it.

2 changes: 1 addition & 1 deletion cmake/sparrow-ipcConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# sparrow-ipc_FOUND - true if sparrow-ipc found on the system
# sparrow-ipc_INCLUDE_DIRS - the directory containing sparrow-ipc headers
# sparrow-ipc_LIBRARY - empty
# sparrow-ipc_LIBRARY - the location of the sparrow-ipc library (or empty if not applicable)

@PACKAGE_INIT@

Expand Down
1 change: 1 addition & 0 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies:
- cxx-compiler
# Libraries dependencies
- flatbuffers
- nlohmann_json
- sparrow-devel >=1.1.2
- doctest
# Documentation dependencies
Expand Down
2 changes: 2 additions & 0 deletions include/sparrow_ipc/config/sparrow_ipc_version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ namespace sparrow_ipc
constexpr int SPARROW_IPC_BINARY_CURRENT = 1;
constexpr int SPARROW_IPC_BINARY_REVISION = 0;
constexpr int SPARROW_IPC_BINARY_AGE = 0;

static_assert(SPARROW_IPC_BINARY_AGE <= SPARROW_IPC_BINARY_CURRENT, "SPARROW_IPC_BINARY_AGE cannot be greater than SPARROW_IPC_BINARY_CURRENT");
}
18 changes: 17 additions & 1 deletion tests/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN

#include <string>

#include "doctest/doctest.h"

//TODO check version?
#include "sparrow_ipc/config/sparrow_ipc_version.hpp"

TEST_CASE("versions exist and are readable")
{
using namespace sparrow_ipc;
[[maybe_unused]] const std::string printable_version = std::string("sparrow-ipc version: ")
+ std::to_string(SPARROW_IPC_VERSION_MAJOR) + "."
+ std::to_string(SPARROW_IPC_VERSION_MINOR) + "."
+ std::to_string(SPARROW_IPC_VERSION_PATCH);

[[maybe_unused]] const std::string printable_binary_version = std::string("sparrow-ipc binary version: ")
+ std::to_string(SPARROW_IPC_BINARY_CURRENT) + "."
+ std::to_string(SPARROW_IPC_BINARY_REVISION) + "."
+ std::to_string(SPARROW_IPC_BINARY_AGE);
}
Loading