Skip to content

Commit

Permalink
Fix the ROOT reading problem
Browse files Browse the repository at this point in the history
Reading ROOT data from the file requires the library to be shared. Thus,
change all libraries to shared libraries but with static link to
libstdc++.
  • Loading branch information
YanzhaoW committed Nov 18, 2024
1 parent 97d13c5 commit aadc1fc
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 38 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ jobs:
matrix:
os: [ debian-bullseye, fedora-41 ]
root: [ "with-root", "no-root" ]
include:
- os: debian-bullseye
static-libstdcxx: ON
- os: fedora-41
static-libstdcxx: OFF
name: ${{ matrix.os }}-${{ matrix.root }}
env:
CMAKE_GENERATOR: Ninja
Expand Down Expand Up @@ -77,7 +72,7 @@ jobs:
source $PARENT_DIR/miniconda3/bin/activate
conda activate srs
mkdir ${PARENT_DIR}/srs-install
cmake --preset static -DCMAKE_INSTALL_PREFIX=${PARENT_DIR}/srs-install -DBUILD_STATIC_STDCXX=${{ matrix.static-libstdcxx }} -DNO_ROOT=$DISABLE_ROOT
cmake --preset static -DCMAKE_INSTALL_PREFIX=${PARENT_DIR}/srs-install -DNO_ROOT=$DISABLE_ROOT
cmake --build ./build --target install -- -j2
cd ${{ env.PARENT_DIR }}
tar czf "srs-${{ matrix.os}}-x86-64-${{ env.TAG_NAME }}-${{ matrix.root }}.tar.gz" srs-install
Expand Down
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 3.28)

include(${CMAKE_SOURCE_DIR}/cmake/option_settings.cmake)
set(ENV{CMAKE_ENABLE_TEST} ${ENABLE_TEST})

project(
srs
VERSION 0.1.1
Expand All @@ -8,7 +11,6 @@ project(
include(${CMAKE_SOURCE_DIR}/cmake/install_config.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/install_packages.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/project_config.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/option_settings.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/check_compilers.cmake)

set(CMAKE_CXX_STANDARD 23)
Expand All @@ -23,5 +25,4 @@ endif()
add_subdirectory(frontend)
add_subdirectory(backend)
add_subdirectory(test)

include(${CMAKE_SOURCE_DIR}/cmake/install_targets.cmake)
add_subdirectory(examples)
5 changes: 4 additions & 1 deletion backend/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# some operating systems don't have static libstdc++.a library
if(BUILD_STATIC AND BUILD_STATIC_STDCXX)
if(BUILD_STATIC)
set(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++")
set(CMAKE_SHARED_LINKER_FLAGS "-static-libstdc++")
endif()

find_package(Boost REQUIRED CONFIG COMPONENTS thread)
Expand Down Expand Up @@ -39,3 +40,5 @@ add_subdirectory(srs)
add_executable(srs_control main.cpp)
target_link_libraries(srs_control PRIVATE srscpp spdlog::spdlog CLI11::CLI11 Boost::thread)
target_compile_definitions(srs_control PUBLIC SRS_PROJECT_VERSION="v${CMAKE_PROJECT_VERSION}")

include(${CMAKE_SOURCE_DIR}/cmake/install_targets.cmake)
7 changes: 1 addition & 6 deletions backend/srs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
if(BUILD_STATIC)
add_library(srscpp STATIC)
target_compile_options(srscpp PRIVATE "-static")
else()
add_library(srscpp SHARED)
endif()
add_library(srscpp SHARED)
target_sources(srscpp PRIVATE Application.cpp)

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
Expand Down
26 changes: 26 additions & 0 deletions backend/srs/converters/DataConvertOptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <algorithm>
#include <array>
#include <cstdint>
#include <string_view>

namespace srs
{
Expand All @@ -16,6 +17,26 @@ namespace srs
proto_frame
};

constexpr auto convert_option_to_string(DataConvertOptions option) -> std::string_view
{
using enum DataConvertOptions;
switch (option)
{
case none:
return std::string_view{ "none" };
case raw:
return std::string_view{ "raw" };
case raw_frame:
return std::string_view{ "raw_frame" };
case structure:
return std::string_view{ "structure" };
case proto:
return std::string_view{ "proto" };
case proto_frame:
return std::string_view{ "proto_frame" };
}
}

struct ConvertOptionRelation
{
constexpr ConvertOptionRelation(DataConvertOptions option, DataConvertOptions next_option)
Expand Down Expand Up @@ -48,6 +69,11 @@ namespace srs

constexpr auto convert_option_has_dependency(DataConvertOptions dependee, DataConvertOptions depender) -> bool
{
if (dependee == depender)
{
return true;
}

return std::ranges::any_of(CONVERT_OPTION_RELATIONS,
[dependee, depender](ConvertOptionRelation relation) -> bool
{
Expand Down
10 changes: 3 additions & 7 deletions backend/srs/data/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
if(BUILD_STATIC)
add_library(srs_data STATIC)
else()
add_library(srs_data SHARED)
endif()
add_library(srs_data SHARED)

target_link_libraries(
srs_data
PUBLIC protobuf::libprotobuf fmt::fmt
PRIVATE Boost::thread)
PUBLIC $<BUILD_LOCAL_INTERFACE:protobuf::libprotobuf > $<BUILD_LOCAL_INTERFACE:fmt::fmt>
PRIVATE $<BUILD_LOCAL_INTERFACE:Boost::thread>)

target_sources(
srs_data
Expand Down
4 changes: 4 additions & 0 deletions backend/srs/utils/CommonFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ namespace srs

auto create_coro_future(auto& coro, auto&& pre_fut)
{
if (not pre_fut.valid())
{
throw std::runtime_error("Previous future is not valid!");
}
return pre_fut.then(
[&coro](std::remove_cvref_t<decltype(pre_fut)> fut)
{
Expand Down
12 changes: 6 additions & 6 deletions cmake/install_targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ set_target_properties(
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${PROJECT_VERSION})

if(NOT BUILD_STATIC)
install(
TARGETS srs_data
EXPORT srsTargets
FILE_SET HEADERS)
endif()
install(
TARGETS srs_data
EXPORT srsTargets
FILE_SET HEADERS)

install(
TARGETS srscpp
Expand All @@ -39,6 +37,8 @@ install(
NAMESPACE srs::
FILE srsConfig-targets.cmake)

install(IMPORTED_RUNTIME_ARTIFACTS TBB::tbb LIBRARY)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/srsConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/srsConfig-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/srs)
Expand Down
4 changes: 2 additions & 2 deletions cmake/option_settings.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
option(USE_ROOT "Force to use ROOT dependency." OFF)
option(NO_ROOT "Disable the usage of ROOT dependency." OFF)
option(BUILD_STATIC "Enable static of libaries." OFF)
option(BUILD_STATIC_STDCXX "Enable static link of libstdc++." ON)
option(BUILD_STATIC "Enable static linking of libstdc++." OFF)
option(ENABLE_TEST "Enable testing framework of the project." ON)
15 changes: 11 additions & 4 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from conan import ConanFile
from conan.tools.cmake import CMakeToolchain

Expand Down Expand Up @@ -39,8 +41,11 @@
"wave",
)

BOOST_OPTIONS = {f"without_{_name}": True for _name in BOOST_LIBS \
if _name not in ['thread', 'atomic', 'chrono', 'container', 'date_time', 'exception', 'system']}
BOOST_OPTIONS = {
f"without_{_name}": True
for _name in BOOST_LIBS
if _name not in ["thread", "atomic", "chrono", "container", "date_time", "exception", "system"]
}
BOOST_OPTIONS.update({"shared": False})


Expand All @@ -54,8 +59,10 @@ def requirements(self):
self.requires("spdlog/1.14.1")
self.requires("zpp_bits/4.4.24")
self.requires("fmt/11.0.1", override=True)
self.requires("protobuf/5.27.0", options = {"with_zlib": True, "fPIC": True, "shared": False, "lite": False})
self.requires("boost/1.86.0", options = BOOST_OPTIONS)
self.requires("protobuf/5.27.0", options={"with_zlib": True, "fPIC": True, "shared": False, "lite": False})
self.requires("boost/1.86.0", options=BOOST_OPTIONS)
if os.environ["CMAKE_ENABLE_TEST"] == "ON":
self.requires("catch2/3.7.1")

def generate(self):
tc = CMakeToolchain(self)
Expand Down
6 changes: 6 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/check_udp_message.py
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/srs_check_udp COPYONLY USE_SOURCE_PERMISSIONS)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/check_binpb_message.py
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/srs_check_binpb COPYONLY USE_SOURCE_PERMISSIONS)

File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/check_udp_message.py ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/srs_check_udp COPYONLY USE_SOURCE_PERMISSIONS)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/check_binpb_message.py ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/srs_check_binpb COPYONLY USE_SOURCE_PERMISSIONS)
if(ENABLE_TEST)
add_subdirectory(integration)
endif()
Empty file added test/integration/CMakeLists.txt
Empty file.

0 comments on commit aadc1fc

Please sign in to comment.