62 lines
1.9 KiB
CMake
62 lines
1.9 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
|
|
project(line_laser_modbus_cpp
|
|
VERSION 1.0.0
|
|
LANGUAGES CXX)
|
|
|
|
option(LINE_LASER_BUILD_TESTS "Build unit tests" ON)
|
|
option(LINE_LASER_BUILD_APPS "Build host/device demo applications" ON)
|
|
|
|
if(MSVC)
|
|
add_compile_options(/utf-8)
|
|
endif()
|
|
|
|
add_library(line_laser_modbus
|
|
src/protocol.cpp
|
|
src/host.cpp
|
|
src/device.cpp
|
|
src/motion_adapter.cpp)
|
|
|
|
target_include_directories(line_laser_modbus
|
|
PUBLIC
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
|
|
target_compile_features(line_laser_modbus PUBLIC cxx_std_17)
|
|
|
|
if(MSVC)
|
|
target_compile_options(line_laser_modbus PRIVATE /W4 /permissive- /utf-8)
|
|
else()
|
|
target_compile_options(line_laser_modbus PRIVATE -Wall -Wextra -Wpedantic)
|
|
endif()
|
|
|
|
if(LINE_LASER_BUILD_APPS)
|
|
add_executable(host_demo apps/host_demo.cpp)
|
|
target_link_libraries(host_demo PRIVATE line_laser_modbus)
|
|
|
|
add_executable(device_demo apps/device_demo.cpp)
|
|
target_link_libraries(device_demo PRIVATE line_laser_modbus)
|
|
|
|
add_executable(adapter_demo apps/adapter_demo.cpp)
|
|
target_link_libraries(adapter_demo PRIVATE line_laser_modbus)
|
|
endif()
|
|
|
|
if(LINE_LASER_BUILD_TESTS)
|
|
enable_testing()
|
|
|
|
add_executable(protocol_tests tests/protocol_tests.cpp)
|
|
target_link_libraries(protocol_tests PRIVATE line_laser_modbus)
|
|
add_test(NAME protocol_tests COMMAND protocol_tests)
|
|
|
|
add_executable(host_tests tests/host_tests.cpp)
|
|
target_link_libraries(host_tests PRIVATE line_laser_modbus)
|
|
add_test(NAME host_tests COMMAND host_tests)
|
|
|
|
add_executable(device_tests tests/device_tests.cpp)
|
|
target_link_libraries(device_tests PRIVATE line_laser_modbus)
|
|
add_test(NAME device_tests COMMAND device_tests)
|
|
|
|
add_executable(adapter_tests tests/adapter_tests.cpp)
|
|
target_link_libraries(adapter_tests PRIVATE line_laser_modbus)
|
|
add_test(NAME adapter_tests COMMAND adapter_tests)
|
|
endif()
|