git-subtree-dir: libs/CommService git-subtree-split: 7ccc0fce88bbc5969df060058cf0fb57abe3bcf9
141 lines
4.3 KiB
CMake
141 lines
4.3 KiB
CMake
cmake_minimum_required (VERSION 3.1 FATAL_ERROR)
|
|
project (libbattle-com++ VERSION 0.1.0 LANGUAGES CXX C)
|
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
|
include(defaultOptions)
|
|
|
|
# export compile commands to json file to be used by atom c++ ide (clangd)
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
|
|
|
|
IF(NOT TARGET Catch2)
|
|
add_subdirectory(libs/Catch2 EXCLUDE_FROM_ALL)
|
|
include(libs/Catch2/contrib/Catch.cmake)
|
|
ENDIF()
|
|
|
|
find_package(Threads)
|
|
|
|
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
|
|
|
|
# generate project specific configuration file
|
|
configure_file(${PROJECT_SOURCE_DIR}/src/config.hpp.in ${PROJECT_SOURCE_DIR}/src/config.hpp @ONLY)
|
|
|
|
#generate global endianess config file
|
|
configure_file(${PROJECT_SOURCE_DIR}/include/BC/endianess.hpp.in ${PROJECT_SOURCE_DIR}/include/BC/endianess.hpp @ONLY)
|
|
|
|
|
|
add_library(bc STATIC
|
|
include/BC/BC.hpp
|
|
include/BC/Message.hpp
|
|
include/BC/receiveable.hpp
|
|
include/BC/transmittable.hpp
|
|
include/BC/BasicService.hpp
|
|
include/BC/SimpleServiceUDP.hpp
|
|
include/BC/Payloads/HotPlugJoin.hpp
|
|
include/BC/Payloads/HotPlugLeave.hpp
|
|
include/BC/Payloads/Ping.hpp
|
|
include/BC/Payloads/Pong.hpp
|
|
include/BC/BasicMessageQueue.hpp
|
|
include/BC/BasicQueueReceiver.hpp
|
|
src/convert/stringConvert.cpp
|
|
src/Message.cpp
|
|
src/BasicService.cpp
|
|
src/SimpleServiceUDP.cpp
|
|
src/config.hpp
|
|
src/Payloads/HotPlugJoin.cpp
|
|
src/Payloads/HotPlugLeave.cpp
|
|
src/Payloads/Ping.cpp
|
|
src/Payloads/Pong.cpp
|
|
src/BasicMessageQueue.cpp
|
|
src/BasicQueueReceiver.cpp
|
|
)
|
|
|
|
target_link_libraries(bc ${CMAKE_THREAD_LIBS_INIT})
|
|
IF (MINGW)
|
|
target_link_libraries(bc -static-libstdc++ -static-libgcc -static ws2_32 winpthread -dynamic)
|
|
ENDIF()
|
|
|
|
target_include_directories(bc PUBLIC
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
$<INSTALL_INTERFACE:include>
|
|
PRIVATE src
|
|
libs/CRCpp/inc
|
|
)
|
|
|
|
add_executable(bccli
|
|
bccli/main.cpp
|
|
bccli/testservice/testservice.hpp
|
|
bccli/testservice/testservice.cpp
|
|
bccli/ping/ping.hpp
|
|
bccli/ping/ping.cpp
|
|
)
|
|
target_link_libraries(bccli bc)
|
|
|
|
target_include_directories(bccli
|
|
PRIVATE bccli
|
|
libs/CLI11/include
|
|
src
|
|
)
|
|
|
|
|
|
IF(CMAKE_BUILD_TYPE MATCHES DEBUG)
|
|
target_compile_options(bc PUBLIC -Wall -g -O0 -fPIC)
|
|
target_compile_options(bccli PUBLIC -Wall -g -O0)
|
|
ELSE()
|
|
IF(CMAKE_BUILD_TYPE MATCHES COVERAGE)
|
|
target_compile_options(bc PUBLIC -g -O0 --coverage -fprofile-arcs -ftest-coverage -fPIC)
|
|
set_target_properties(bc PROPERTIES LINK_FLAGS "-fprofile-arcs")
|
|
target_compile_options(bccli PUBLIC -g -O0 --coverage -fprofile-arcs -ftest-coverage)
|
|
set_target_properties(bccli PROPERTIES LINK_FLAGS "-fprofile-arcs")
|
|
ELSE()
|
|
target_compile_options(bc PUBLIC -O4 -fPIC)
|
|
target_compile_options(bccli PUBLIC -O4)
|
|
ENDIF()
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
# Everything TEST related
|
|
#
|
|
option(TEST_LIBBATTLE_COM "Turn running of libbattle-com specific tests off" ON)
|
|
|
|
IF (${TEST_LIBBATTLE_COM})
|
|
|
|
add_my_test(TEST test_simple_conversion
|
|
SOURCES tests/test_simple_conversion.cpp
|
|
LIBS bc
|
|
)
|
|
|
|
add_my_test(TEST test_simple_service_udp
|
|
SOURCES tests/test_simple_service_udp.cpp
|
|
LIBS bc
|
|
)
|
|
|
|
add_executable(test_basic_queue_receiver tests/test_basic_queue_receiver.cpp)
|
|
target_link_libraries(test_basic_queue_receiver Catch2::Catch2 bc)
|
|
catch_discover_tests(test_basic_queue_receiver)
|
|
|
|
add_executable(test_basic_message_queue tests/test_basic_message_queue.cpp)
|
|
target_link_libraries(test_basic_message_queue Catch2::Catch2 bc)
|
|
catch_discover_tests(test_basic_message_queue)
|
|
|
|
|
|
get_property(_mytests GLOBAL PROPERTY _mytests)
|
|
FOREACH( _test ${_mytests})
|
|
target_include_directories(${_test} PRIVATE src )
|
|
|
|
IF(CMAKE_BUILD_TYPE MATCHES DEBUG)
|
|
target_compile_options(${_test} PUBLIC -Wall -g -O0)
|
|
ELSE()
|
|
IF(CMAKE_BUILD_TYPE MATCHES COVERAGE)
|
|
target_compile_options(${_test} PUBLIC -g -O0 --coverage -fprofile-arcs -ftest-coverage)
|
|
set_target_properties(${_test} PROPERTIES LINK_FLAGS "-fprofile-arcs")
|
|
ELSE()
|
|
target_compile_options(${_test} PUBLIC -O4)
|
|
ENDIF()
|
|
ENDIF()
|
|
ENDFOREACH()
|
|
|
|
ENDIF()
|