From 59b04ad6e87cecbc6e804cfad0121fd8e554f3de Mon Sep 17 00:00:00 2001 From: Bechir Braham Date: Tue, 9 Apr 2024 15:45:01 +0200 Subject: [PATCH] add boost library --- CMakeLists.txt | 27 ++++++++++++++++++++++++--- aare-environment.yml | 1 + examples/CMakeLists.txt | 7 +++---- examples/restream_example.cpp | 24 ++++++++++++++++++++---- 4 files changed, 48 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 14ed946..90b40ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,8 @@ option(AARE_FETCH_PYBIND11 "Use FetchContent to download pybind11" ON) option(AARE_FETCH_CATCH "Use FetchContent to download catch2" ON) option(AARE_FETCH_JSON "Use FetchContent to download nlohmann::json" ON) option(AARE_FETCH_ZMQ "Use FetchContent to download libzmq" ON) +option(AARE_FETCH_BOOST "Use FetchContent to download boost" ON) + #Convenience option to use system libraries option(AARE_SYSTEM_LIBRARIES "Use system libraries" OFF) @@ -37,6 +39,8 @@ if(AARE_SYSTEM_LIBRARIES) set(AARE_FETCH_CATCH OFF CACHE BOOL "Disabled FetchContent for catch2" FORCE) set(AARE_FETCH_JSON OFF CACHE BOOL "Disabled FetchContent for nlohmann::json" FORCE) set(AARE_FETCH_ZMQ OFF CACHE BOOL "Disabled FetchContent for libzmq" FORCE) + set(AARE_FETCH_BOOST OFF CACHE BOOL "Disabled FetchContent for boost" FORCE) + endif() @@ -72,9 +76,26 @@ if (AARE_FETCH_FMT) ) FetchContent_MakeAvailable(fmt) else() - find_package(fmt 6 REQUIRED) + find_package(fmt 6 REQUIRED) endif() + +if (AARE_FETCH_BOOST) + set(BOOST_INCLUDE_LIBRARIES program_options) + set(BOOST_ENABLE_CMAKE ON) + FetchContent_Declare( + Boost + GIT_REPOSITORY https://github.com/boostorg/boost.git + GIT_TAG boost-1.80.0 + ) + FetchContent_MakeAvailable(Boost) +else() + + find_package(Boost 1.80 REQUIRED COMPONENTS program_options) +endif() + + + add_library(aare_compiler_flags INTERFACE) target_compile_features(aare_compiler_flags INTERFACE cxx_std_17) @@ -88,7 +109,7 @@ else() INTERFACE -Og -ggdb3 - -D_GLIBCXX_DEBUG + # -D_GLIBCXX_DEBUG # causes errors with boost -D_GLIBCXX_DEBUG_PEDANTIC ) @@ -153,7 +174,7 @@ add_subdirectory(network_io) #Overall target to link to when using the library add_library(aare INTERFACE) -target_link_libraries(aare INTERFACE core file_io utils network_io) +target_link_libraries(aare INTERFACE core file_io utils network_io ${Boost_LIBRARIES}) target_include_directories(aare INTERFACE $ $ diff --git a/aare-environment.yml b/aare-environment.yml index b8112e2..71a0df3 100644 --- a/aare-environment.yml +++ b/aare-environment.yml @@ -8,3 +8,4 @@ dependencies: - nlohmann_json # should be removed - catch2 - zeromq + - boost-cpp diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index dfe6150..6442f4d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,14 +1,13 @@ -set(EXAMPLE_LIST "json_example;logger_example;numpy_read_example;multiport_example;raw_example;") -set(EXAMPLE_LIST "${EXAMPLE_LIST};mythen_example;numpy_write_example;zmq_receiver_example;zmq_sender_example;") +set(EXAMPLE_LIST "json_example;logger_example;numpy_read_example;multiport_example;raw_example;restream_example") +set(EXAMPLE_LIST "${EXAMPLE_LIST};mythen_example;numpy_write_example;zmq_receiver_example;zmq_sender_example;") foreach(example ${EXAMPLE_LIST}) add_executable(${example} ${example}.cpp) target_link_libraries(${example} PUBLIC aare PRIVATE aare_compiler_flags) - - endforeach() +message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}") diff --git a/examples/restream_example.cpp b/examples/restream_example.cpp index 00c0276..a5a31fd 100644 --- a/examples/restream_example.cpp +++ b/examples/restream_example.cpp @@ -1,10 +1,26 @@ +#include +#include +#include +#include +#include +#include + #include "aare/network_io/ZmqSocketSender.hpp" -#include "aare/ + +#include + using namespace aare; using namespace std; +namespace po = boost::program_options; -int main(){ - - +int main(int argc, char **argv) { + po::options_description desc("Allowed options"); + desc.add_options() + ("help", "produce help message") + // ("input,i", po::value(), "input file"); + ("port,p", po::value(), "port number"); + // ("loop,l", "loop over the file"); + // po::positional_options_description pd; + // pd.add("input,i", 1); } \ No newline at end of file