2023-07-25 16:35:12 +02:00
|
|
|
cmake_minimum_required (VERSION 3.25 FATAL_ERROR)
|
|
|
|
project (whisperCom VERSION 0.0.1 LANGUAGES CXX C)
|
|
|
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Options for compiling whisperCom
|
|
|
|
#
|
|
|
|
option(TEST_WHISPERCOM "Turn running of whisperCom specific tests on/off. Default: on" ON)
|
|
|
|
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
|
|
|
|
|
|
|
|
#
|
|
|
|
# some stuff required inclusion
|
|
|
|
#
|
|
|
|
include(doxygen)
|
|
|
|
include(compdb)
|
|
|
|
include(protobuf)
|
|
|
|
|
|
|
|
IF(${TEST_WHISPERCOM})
|
|
|
|
include(CTest)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
#
|
|
|
|
# enable building documentation
|
|
|
|
#
|
|
|
|
build_docs(PROCESS_DOXYFILE DOXYFILE_PATH "docs/Doxyfile.in" )
|
|
|
|
|
|
|
|
#
|
|
|
|
# External required projects
|
|
|
|
#
|
|
|
|
IF(NOT TARGET Catch2 AND ${TEST_WHISPERCOM})
|
|
|
|
add_subdirectory(libs/Catch2 EXCLUDE_FROM_ALL)
|
|
|
|
include(libs/Catch2/extras/Catch.cmake)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
IF(NOT TARGET loguru)
|
|
|
|
add_library(loguru STATIC libs/loguru/loguru.cpp libs/loguru/loguru.hpp)
|
|
|
|
target_include_directories(loguru PUBLIC libs/loguru)
|
|
|
|
target_compile_options(loguru PUBLIC -DLOGURU_WITH_STREAMS=1)
|
|
|
|
set_property(TARGET loguru PROPERTY POSITION_INDEPENDENT_CODE 1)
|
|
|
|
target_link_libraries(loguru PUBLIC dl)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
IF(NOT TARGET libzmq)
|
|
|
|
set(BUILD_STATIC ON CACHE BOOL "enable building zmq as static library")
|
|
|
|
set(ENABLE_DRAFTS ON CACHE BOOL "enable zmq drafts")
|
|
|
|
set(ENABLE_RADIX_TREE ON CACHE BOOL "enable ENABLE_RADIX_TREE drafts")
|
2023-09-04 11:51:42 +02:00
|
|
|
set(ENABLE_WS OFF CACHE BOOL "enable websocket support")
|
|
|
|
set(WITH_OPENPGM OFF CACHE BOOL "enable pgm protocol")
|
2023-07-25 16:35:12 +02:00
|
|
|
set(WITH_LIBSODIUM ON CACHE BOOL "enable static libsodium support")
|
|
|
|
set(WITH_LIBSODIUM_STATIC ON CACHE BOOL "enable static libsodium support")
|
|
|
|
set(ENABLE_CURVE ON CACHE BOOL "enable curve cryptography in libsodium support")
|
|
|
|
set(ZMQ_BUILD_TESTS OFF CACHE BOOL "disable zmq tests")
|
|
|
|
set(OPENPGM_PKGCONFIG_NAME openpgm-5.3)
|
|
|
|
add_subdirectory(libs/libzmq EXCLUDE_FROM_ALL)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
IF(NOT TARGET cppzmq-static)
|
|
|
|
set(CPPZMQ_BUILD_TESTS OFF CACHE BOOL "disbale cppzmq tests")
|
|
|
|
add_subdirectory(libs/cppzmq EXCLUDE_FROM_ALL)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
IF(NOT TARGET protobuf)
|
|
|
|
SET(protobuf_BUILD_TESTS OFF CACHE BOOL "disable protobuf tests")
|
|
|
|
SET(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "disable shared libraries")
|
|
|
|
#SET(WITH_PROTOC ON CACHE BOOL "enable building of protoc")
|
|
|
|
add_subdirectory(libs/protobuf EXCLUDE_FROM_ALL)
|
2023-08-31 11:07:31 +02:00
|
|
|
set(PROTOC ${CMAKE_CURRENT_BINARY_DIR}/libs/protobuf/protoc CACHE INTERNAL "" )
|
|
|
|
set(PROTO_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}/libs/protobuf/src CACHE INTERNAL "" )
|
2023-07-25 16:35:12 +02:00
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
# we are building with c++20
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS ON)
|
|
|
|
|
|
|
|
protobuf_generate_cpp(PROTO_PATH proto CPP_PATH proto HPP_PATH proto)
|
|
|
|
|
|
|
|
SET(WHISPERCOM_SOURCES
|
|
|
|
proto/RouterMessage.pb.cc
|
|
|
|
proto/Message.pb.cc
|
|
|
|
proto/TestMessage.pb.cc
|
|
|
|
include/WhisperCom/Router.hpp
|
|
|
|
src/WhisperCom/Router.cpp
|
|
|
|
include/WhisperCom/Service.hpp
|
|
|
|
src/WhisperCom/Service.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(whisperCom STATIC ${WHISPERCOM_SOURCES})
|
|
|
|
target_link_libraries(whisperCom loguru cppzmq-static protobuf::libprotobuf ${CMAKE_THREAD_LIBS_INIT} )
|
|
|
|
target_include_directories(whisperCom
|
|
|
|
PUBLIC
|
|
|
|
include
|
|
|
|
proto
|
|
|
|
PRIVATE
|
|
|
|
src
|
|
|
|
)
|
|
|
|
add_dependencies(whisperCom protoc)
|
|
|
|
|
|
|
|
add_executable(wctest src/main.cpp)
|
|
|
|
target_link_libraries(wctest whisperCom)
|
|
|
|
|
|
|
|
add_executable(wcListener src/Listener.cpp)
|
2023-07-26 11:46:18 +02:00
|
|
|
target_link_libraries(wcListener whisperCom)
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Everything TEST related
|
|
|
|
#
|
|
|
|
IF (${TEST_WHISPERCOM})
|
|
|
|
|
|
|
|
add_executable(test_Service tests/test_Service.cpp)
|
|
|
|
target_link_libraries(test_Service Catch2::Catch2WithMain whisperCom loguru)
|
|
|
|
catch_discover_tests(test_Service)
|
|
|
|
|
|
|
|
ENDIF()
|