Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
adas-api/CMakeLists.txt
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
133 lines (105 sloc)
5.63 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.0) | |
set(CMAKE_CXX_STANDARD 17) | |
project(dbc_example C CXX) | |
# --- Fetch FTXUI -------------------------------------------------------------- | |
include(FetchContent) | |
set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE) | |
FetchContent_Declare(ftxui | |
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui | |
GIT_TAG v3.0.0 | |
) | |
FetchContent_GetProperties(ftxui) | |
if(NOT ftxui_POPULATED) | |
FetchContent_Populate(ftxui) | |
add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL) | |
endif() | |
# ------------------------------------------------------------------------------ | |
# location of source code files | |
include_directories( include ) | |
# tell cmake where to put the executables that it creates | |
file( MAKE_DIRECTORY bin ) | |
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY bin ) | |
# where to put the object files it creates | |
file( MAKE_DIRECTORY lib ) | |
SET( LIBRARY_OUTPUT_PATH lib ) | |
# autogenerate code from the DBC file | |
file( MAKE_DIRECTORY src_autogen ) | |
add_custom_command( OUTPUT src_autogen/candata.h src_autogen/candata.c | |
COMMAND python3 -m cantools generate_c_source ${CMAKE_CURRENT_SOURCE_DIR}/docs/candata.dbc -o src_autogen | |
MAIN_DEPENDENCY docs/candata.dbc | |
COMMENT "Autogenerate code from DBC file" ) | |
# create shared library of the autogenerated code from the DBC file | |
add_library( candata SHARED src_autogen/candata.c ) | |
target_include_directories( candata PUBLIC src_autogen ) | |
add_library( process_frame SHARED src/status/process_frame.cpp ) | |
target_include_directories( process_frame PUBLIC include ) | |
# input frames | |
add_library( brake_frame SHARED src/status/brake_frame.cpp ) | |
target_include_directories( brake_frame PUBLIC include ) | |
target_link_libraries( brake_frame PUBLIC candata ) | |
target_link_libraries( brake_frame PUBLIC process_frame ) | |
add_library( axle_torque_frame SHARED src/status/axle_torque_frame.cpp ) | |
target_include_directories( axle_torque_frame PUBLIC include ) | |
target_link_libraries( axle_torque_frame PUBLIC candata ) | |
target_link_libraries( axle_torque_frame PUBLIC process_frame ) | |
add_library( steering_frame SHARED src/status/steering_frame.cpp ) | |
target_include_directories( steering_frame PUBLIC include ) | |
target_link_libraries( steering_frame PRIVATE candata ) | |
target_link_libraries( steering_frame PUBLIC process_frame ) | |
add_library( status_frame SHARED src/status/status_frame.cpp ) | |
target_include_directories( status_frame PUBLIC include ) | |
target_link_libraries( status_frame PRIVATE candata ) | |
target_link_libraries( status_frame PUBLIC process_frame ) | |
add_library( wheel_counts_frame SHARED src/status/wheel_counts_frame.cpp ) | |
target_include_directories( wheel_counts_frame PUBLIC include ) | |
target_link_libraries( wheel_counts_frame PRIVATE candata ) | |
target_link_libraries( wheel_counts_frame PUBLIC process_frame ) | |
add_library( wheel_speeds_frame SHARED src/status/wheel_speeds_frame.cpp ) | |
target_include_directories( wheel_speeds_frame PUBLIC include ) | |
target_link_libraries( wheel_speeds_frame PRIVATE candata ) | |
target_link_libraries( wheel_speeds_frame PUBLIC process_frame ) | |
add_library( status_frames SHARED src/status_frames.cpp ) | |
target_include_directories( status_frames PUBLIC include ) | |
target_link_libraries( status_frames PUBLIC axle_torque_frame | |
#brake_frame | |
status_frame | |
steering_frame | |
wheel_counts_frame | |
wheel_speeds_frame ) | |
# output frames | |
add_library( control_frame SHARED src/control/control_frame.cpp ) | |
target_include_directories( control_frame PUBLIC include ) | |
add_library( axle_control_frame SHARED src/control/axle_control_frame.cpp ) | |
target_include_directories( axle_control_frame PUBLIC include ) | |
target_link_libraries( axle_control_frame PUBLIC control_frame axle_torque_frame ) | |
target_link_libraries( axle_control_frame PRIVATE candata ) | |
add_library( brake_control_frame SHARED src/control/brake_control_frame.cpp ) | |
target_include_directories( brake_control_frame PUBLIC include ) | |
target_link_libraries( brake_control_frame PUBLIC control_frame axle_torque_frame ) | |
target_link_libraries( brake_control_frame PRIVATE candata ) | |
add_library( status_control_frame SHARED src/control/status_control_frame.cpp ) | |
target_include_directories( status_control_frame PUBLIC include ) | |
target_link_libraries( status_control_frame PUBLIC control_frame steering_frame ) | |
target_link_libraries( status_control_frame PRIVATE candata ) | |
add_library( steering_control_frame SHARED src/control/steering_control_frame.cpp ) | |
target_include_directories( steering_control_frame PUBLIC include ) | |
target_link_libraries( steering_control_frame PUBLIC control_frame steering_frame ) | |
target_link_libraries( steering_control_frame PRIVATE candata ) | |
add_library( control_frames SHARED src/control_frames.cpp ) | |
target_include_directories( control_frames PUBLIC include ) | |
target_link_libraries( control_frames PUBLIC axle_control_frame | |
brake_control_frame | |
status_control_frame | |
steering_control_frame ) | |
# examples | |
add_executable( example_frame_reader src/example_frame_reader.cpp ) | |
target_link_libraries( example_frame_reader PRIVATE candata status_frames ) | |
add_executable( example_control src/example_control.cpp ) | |
target_link_libraries( example_control PRIVATE candata control_frames status_frames ) | |
# demo | |
add_executable( demo src/demo.cpp ) | |
target_link_libraries( demo | |
PRIVATE ftxui::screen | |
PRIVATE ftxui::dom | |
PRIVATE ftxui::component | |
PRIVATE candata status_frames control_frames ) |