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?
can_demo/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.
37 lines (26 sloc)
1.12 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) | |
# 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/data.h src_autogen/data.c | |
COMMAND python3 -m cantools generate_c_source data.dbc -o src_autogen | |
MAIN_DEPENDENCY data.dbc | |
COMMENT "Autogenerate code from DBC file" ) | |
# create shared library of the autogenerated code from the DBC file | |
add_library( data SHARED src_autogen/data.c ) | |
target_include_directories( data PUBLIC src_autogen ) | |
add_executable( demo_dbc src/demo_dbc.cpp ) | |
target_link_libraries( demo_dbc PRIVATE data ) | |
add_executable( demo src/demo.cpp ) | |
add_executable( demo_raw_decode src/demo_raw_decode.cpp ) | |
add_executable( demo_send src/demo_send.cpp ) | |
add_executable( demo_send_c src/demo_send.c ) |