Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CMakeLists.txt.user | ||
CMakeCache.txt | ||
CMakeFiles | ||
CMakeScripts | ||
Testing | ||
Makefile | ||
cmake_install.cmake | ||
install_manifest.txt | ||
compile_commands.json | ||
CTestTestfile.cmake | ||
_deps | ||
|
||
bin/ | ||
src_autogen/ | ||
lib/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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( can src/can.c ) | ||
target_link_libraries( can_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 ) |