diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..54eb3b0 --- /dev/null +++ b/.gitignore @@ -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/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7274d00 --- /dev/null +++ b/CMakeLists.txt @@ -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 ) \ No newline at end of file