You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
185 lines
6.3 KiB
CMake
185 lines
6.3 KiB
CMake
|
|
cmake_minimum_required(VERSION 3.20)
|
|
|
|
project("system")
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
set(PROGRAM_VERSION "v1.0.0")
|
|
|
|
set(fastcdr_DIR "/opt/fastdds/v3.2.2/lib/cmake/fastcdr")
|
|
set(fastdds_DIR "/opt/fastdds/v3.2.2/share/fastdds/cmake")
|
|
set(foonathan_memory_DIR "/opt/foonathan_memory/lib/foonathan_memory/cmake")
|
|
set(PahoMqttCpp_DIR "/opt/pahomqtt/v1.5.3/lib/cmake/PahoMqttCpp")
|
|
|
|
# Find requirements
|
|
find_package(fastcdr REQUIRED)
|
|
find_package(fastdds 3 REQUIRED)
|
|
find_package(PahoMqttCpp REQUIRED)
|
|
|
|
# Set CMAKE_BUILD_TYPE to Release by default.
|
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
message(STATUS "Setting build type to 'Release' as none was specified.")
|
|
set(CMAKE_BUILD_TYPE Release CACHE STRING
|
|
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
|
|
FORCE)
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
|
endif()
|
|
|
|
include_directories(common)
|
|
include_directories(lib)
|
|
|
|
message(STATUS "Configuring System...")
|
|
add_library(System_lib lib/WeighingDDSTypeTypeObjectSupport.cxx lib/WeighingDDSTypePubSubTypes.cxx)
|
|
target_link_libraries(System_lib fastcdr fastdds)
|
|
|
|
# Demo Application.
|
|
# set(PROGRAM_MODULE "Demo")
|
|
# add_executable(Demo
|
|
# demo/main.cxx
|
|
# demo/Publisher.cxx
|
|
# demo/Subscriber.cxx
|
|
# )
|
|
# target_compile_definitions(Demo PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}")
|
|
# target_include_directories(Demo PRIVATE demo)
|
|
# target_link_libraries(Demo fastcdr fastdds
|
|
# System_lib
|
|
# )
|
|
|
|
# Core Application.
|
|
set(PROGRAM_MODULE "Core")
|
|
add_executable(Core
|
|
core/main.cxx
|
|
core/Publisher.cxx
|
|
core/Subscriber.cxx
|
|
core/msg.hpp
|
|
lib/WeighingDDSType.hpp
|
|
)
|
|
target_compile_definitions(Core PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}")
|
|
target_include_directories(Core PRIVATE core)
|
|
target_link_libraries(Core fastcdr fastdds
|
|
System_lib
|
|
)
|
|
|
|
# GateCtrl Application.
|
|
set(PROGRAM_MODULE "GateCtrl")
|
|
add_executable(GateCtrl
|
|
gatectrl/main.cxx
|
|
gatectrl/Publisher.cxx
|
|
gatectrl/Subscriber.cxx
|
|
gatectrl/MsgHandler.cxx
|
|
common/CanMsgHandler.cxx
|
|
)
|
|
target_compile_definitions(GateCtrl PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}")
|
|
target_include_directories(GateCtrl PRIVATE gatectrl)
|
|
target_link_libraries(GateCtrl fastcdr fastdds
|
|
System_lib
|
|
)
|
|
|
|
# IoCtrl Application.
|
|
# set(PROGRAM_MODULE "IoCtrl")
|
|
# add_executable(IoCtrl
|
|
# ioctrl/main.cxx
|
|
# ioctrl/Publisher.cxx
|
|
# ioctrl/Subscriber.cxx
|
|
# ioctrl/MsgHandler.cxx
|
|
# common/CanMsgHandler.cxx
|
|
# )
|
|
# target_compile_definitions(IoCtrl PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}")
|
|
# target_include_directories(IoCtrl PRIVATE ioctrl)
|
|
# target_link_libraries(IoCtrl fastcdr fastdds
|
|
# System_lib
|
|
# )
|
|
|
|
# HttpServer Application.
|
|
set(PROGRAM_MODULE "HttpServer")
|
|
add_executable(HttpServer
|
|
httpserver/main.cxx
|
|
httpserver/Publisher.cxx
|
|
httpserver/Subscriber.cxx
|
|
httpserver/httpserver.cxx
|
|
)
|
|
target_compile_definitions(HttpServer PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}")
|
|
target_include_directories(HttpServer PRIVATE httpserver)
|
|
target_link_libraries(HttpServer fastcdr fastdds
|
|
System_lib
|
|
)
|
|
|
|
# Led Application.
|
|
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib)
|
|
set(PROGRAM_MODULE "Led")
|
|
add_executable(Led
|
|
led/main.cxx
|
|
led/Subscriber.cxx
|
|
)
|
|
target_compile_definitions(Led PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}")
|
|
target_include_directories(Led PRIVATE led)
|
|
target_link_libraries(Led fastcdr fastdds
|
|
System_lib fun
|
|
)
|
|
|
|
# Print Application.
|
|
set(PROGRAM_MODULE "Print")
|
|
add_executable(Print
|
|
print/main.cxx
|
|
print/Publisher.cxx
|
|
print/Subscriber.cxx
|
|
print/MsgHandler.cxx
|
|
common/SerialMsgHandler.cxx
|
|
lib/strcode.cpp
|
|
print/MsgHandler.hpp
|
|
)
|
|
target_compile_definitions(Print PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}")
|
|
target_include_directories(Print PRIVATE print)
|
|
target_link_libraries(Print fastcdr fastdds
|
|
System_lib
|
|
)
|
|
|
|
# ReadCard Application.
|
|
set(PROGRAM_MODULE "ReadCard")
|
|
add_executable(ReadCard
|
|
readcard/main.cxx
|
|
readcard/Publisher.cxx
|
|
readcard/Subscriber.cxx
|
|
readcard/MsgHandler.cxx
|
|
readcard/Publisher.hpp
|
|
readcard/msg.hpp
|
|
common/SerialMsgHandler.cxx
|
|
readcard/MsgHandler.hpp
|
|
)
|
|
target_compile_definitions(ReadCard PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}")
|
|
target_include_directories(ReadCard PRIVATE readcard)
|
|
target_link_libraries(ReadCard fastcdr fastdds
|
|
System_lib
|
|
)
|
|
|
|
# Weigh Application.
|
|
set(PROGRAM_MODULE "Weigh")
|
|
add_executable(Weigh
|
|
weigh/main.cxx
|
|
weigh/Publisher.cxx
|
|
weigh/Subscriber.cxx
|
|
weigh/MsgHandler.cxx
|
|
weigh/WeightStabilityDetector.cxx
|
|
common/SerialMsgHandler.cxx
|
|
common/SerialMsgHandler.hpp
|
|
)
|
|
target_compile_definitions(Weigh PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}")
|
|
target_include_directories(Weigh PRIVATE weigh)
|
|
target_link_libraries(Weigh fastcdr fastdds
|
|
System_lib
|
|
)
|
|
|
|
# MqttDds Application.
|
|
set(PROGRAM_MODULE "MqttDds")
|
|
add_executable(MqttDds
|
|
mqttdds/main.cxx
|
|
mqttdds/Publisher.cxx
|
|
mqttdds/Subscriber.cxx
|
|
)
|
|
target_compile_definitions(MqttDds PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}")
|
|
target_include_directories(MqttDds PRIVATE mqttdds)
|
|
target_link_libraries(MqttDds fastcdr fastdds
|
|
System_lib PahoMqttCpp::paho-mqttpp3
|
|
)
|