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.
171 lines (133 sloc)
7.11 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) | |
# add_compile_options(-Wall -Wextra -pedantic -g) | |
project(adas_api C CXX) | |
if( TUI ) | |
# --- 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_MakeAvailable(ftxui) | |
# ------------------------------------------------------------------------------ | |
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 ${CMAKE_CURRENT_LIST_DIR}/src_autogen/candata.h ${CMAKE_CURRENT_LIST_DIR}/src_autogen/candata.c | |
COMMAND python3 -m cantools generate_c_source | |
--use-float | |
${CMAKE_CURRENT_LIST_DIR}/docs/candata.dbc | |
-o ${CMAKE_CURRENT_LIST_DIR}/src_autogen | |
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/ | |
MAIN_DEPENDENCY ${CMAKE_CURRENT_LIST_DIR}/docs/candata.dbc | |
COMMENT "Autogenerate code from DBC file" ) | |
add_custom_command( OUTPUT ${CMAKE_CURRENT_LIST_DIR}/include/candata.h | |
COMMAND ${CMAKE_COMMAND} -E copy | |
${CMAKE_CURRENT_LIST_DIR}/src_autogen/candata.h | |
${CMAKE_CURRENT_LIST_DIR}/include/candata.h ) | |
# create shared library of the autogenerated code from the DBC file | |
add_library( candata SHARED ${CMAKE_CURRENT_LIST_DIR}/src_autogen/candata.c | |
${CMAKE_CURRENT_LIST_DIR}/include/candata.h ) | |
# input frames | |
add_library( process_frame SHARED src/status/process_frame.cpp ) | |
target_include_directories( process_frame PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include ) | |
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 ) | |
add_library( adas SHARED src/adas.cpp ) | |
target_include_directories( adas PUBLIC include ) | |
target_link_libraries( adas PUBLIC control_frames status_frames ) | |
add_library( simple_adas SHARED src/simple_adas.cpp ) | |
target_include_directories( simple_adas PUBLIC include ) | |
target_link_libraries( simple_adas PUBLIC adas ) | |
# 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 ) | |
add_executable( example_straight_line src/example_straight_line.cpp ) | |
target_link_libraries( example_straight_line PUBLIC simple_adas ) | |
#add_executable( example_threaded src/example_threaded.cpp ) | |
#target_link_libraries( example_threaded PUBLIC simple_adas ) | |
add_executable( example_wiggle src/example_wiggle.cpp ) | |
target_link_libraries( example_wiggle PUBLIC simple_adas ) | |
add_executable( example_calibration src/example_calibration.cpp ) | |
target_link_libraries( example_calibration PUBLIC simple_adas ) | |
#add_executable( accel src/accel.cpp ) | |
#target_link_libraries( accel PUBLIC simple_adas ) | |
# demo | |
if( TUI ) | |
add_library( demo_ui STATIC src/demo_ui.cpp ) | |
target_include_directories( demo_ui PRIVATE include ) | |
target_link_libraries( demo_ui | |
PUBLIC ftxui::screen | |
PUBLIC ftxui::dom | |
PUBLIC ftxui::component | |
PUBLIC candata adas ) | |
add_executable( demo src/demo.cpp ) | |
target_link_libraries( demo demo_ui ) | |
endif() |