Files
whisper-com/CMakeLists.txt
2023-02-15 11:15:28 +01:00

151 lines
3.3 KiB
CMake
Executable File

cmake_minimum_required (VERSION 3.1 FATAL_ERROR)
project (whisper-com VERSION 0.1.0 LANGUAGES CXX C)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
include(defaultOptions)
IF(NOT TARGET Catch2)
add_subdirectory(libs/Catch2 EXCLUDE_FROM_ALL)
include(libs/Catch2/contrib/Catch.cmake)
ENDIF()
add_compile_definitions(LOGURU_WITH_STREAMS SQLITE_THREADSAFE=2)
IF(NOT TARGET loguru)
add_subdirectory(libs/loguru EXCLUDE_FROM_ALL)
ENDIF()
IF(NOT TARGET libzmq)
set(ZMQ_BUILD_TESTS OFF CACHE INTERNAL "")
add_subdirectory(libs/libzmq)
ENDIF()
IF(NOT TARGET cppzmq)
set(CPPZMQ_BUILD_TESTS OFF CACHE INTERNAL "")
add_subdirectory(libs/cppzmq EXCLUDE_FROM_ALL)
ENDIF()
set(protobuf_BUILD_TESTS OFF CACHE INTERNAL "")
set(protobuf_BUILD_EXAMPLES OFF CACHE INTERNAL "")
add_subdirectory(libs/protobuf )
include(protobuf)
protobuf_generate_cpp(PROTO_PATH include/WHISPER/Messages/Protos/ CPP_PATH include/WHISPER/Messages/Protos HPP_PATH include/WHISPER/Messages/Protos)
if(protobuf_VERBOSE)
message(STATUS "Using Protocol Buffers ${protobuf_VERSION}")
endif()
add_library(whisper-com STATIC
include/WHISPER/whisper.hpp
src/WHISPER/whisper.cpp
include/WHISPER/InternalUDPService.hpp
src/WHISPER/InternalUDPService.cpp
include/WHISPER/InternalUDPListener.hpp
src/WHISPER/InternalUDPListener.cpp
include/WHISPER/InternalUDPSender.hpp
src/WHISPER/InternalUDPSender.cpp
include/WHISPER/localClients.hpp
src/WHISPER/localClients.cpp
include/WHISPER/threadSafeQueue.hpp
src/WHISPER/threadSafeQueue.cpp
include/WHISPER/Messages/Message.hpp
src/WHISPER/Messages/Message.cpp
include/WHISPER/Messages/Join.hpp
src/WHISPER/Messages/Join.cpp
include/WHISPER/Messages/Leave.hpp
src/WHISPER/Messages/Leave.cpp
include/WHISPER/Messages/Ping.hpp
src/WHISPER/Messages/Ping.cpp
include/WHISPER/Messages/Pong.hpp
src/WHISPER/Messages/Pong.cpp
include/WHISPER/Messages/stringData.hpp
src/WHISPER/Messages/stringData.cpp
include/WHISPER/Messages/Protos/message.pb.cc
include/WHISPER/Messages/Protos/join.pb.cc
include/WHISPER/Messages/Protos/leave.pb.cc
include/WHISPER/Messages/Protos/ping.pb.cc
include/WHISPER/Messages/Protos/pong.pb.cc
include/WHISPER/Messages/Protos/stringData.pb.cc
)
target_link_libraries(whisper-com
loguru
cppzmq
libzmq
libprotobuf
)
add_dependencies(whisper-com protoc)
target_include_directories(whisper-com PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
src)
add_executable(main
src/main.cpp
)
add_dependencies(main protoc)
target_link_libraries(main
whisper-com
loguru
)
add_executable(mainRcv
src/mainRecv.cpp
)
target_link_libraries(mainRcv
loguru
whisper-com
)
#
# Everything TEST related
#
option(TEST_WHISPER_COMMUNICATION_LIBRARY "Turn running of application template specific tests off" ON)
IF (${TEST_WHISPER_COMMUNICATION_LIBRARY})
add_executable(test_test tests/test_test.cpp)
target_link_libraries(test_test Catch2::Catch2 whisper-com loguru)
catch_discover_tests(test_test)
add_executable(test_InternalUDPListener tests/test_InternalUDPListener.cpp)
target_link_libraries(test_InternalUDPListener Catch2::Catch2 whisper-com loguru)
catch_discover_tests(test_InternalUDPListener)
ENDIF()