-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ad9620
commit 8303516
Showing
13 changed files
with
102 additions
and
137 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
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
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
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
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
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 |
---|---|---|
@@ -1,77 +1,67 @@ | ||
cmake_minimum_required (VERSION 3.5) | ||
project(CxxCanard) | ||
include(CTest) | ||
|
||
include(FetchContent) | ||
FetchContent_Declare( | ||
googletest | ||
GIT_REPOSITORY https://github.com/google/googletest.git | ||
GIT_TAG v1.13.0 | ||
) | ||
|
||
FetchContent_Declare( | ||
DSDL | ||
GIT_REPOSITORY https://github.com/DroneCAN/DSDL.git | ||
GIT_TAG master | ||
) | ||
|
||
FetchContent_Declare( | ||
dronecan_dsdlc | ||
GIT_REPOSITORY https://github.com/DroneCAN/dronecan_dsdlc.git | ||
GIT_TAG master | ||
) | ||
|
||
FetchContent_MakeAvailable(googletest DSDL dronecan_dsdlc) | ||
|
||
# execute process to generate libcanard headers using dronecan_dsdlc/dronecan_dsdlc.py | ||
execute_process(COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/dronecan_dsdlc/dronecan_dsdlc.py | ||
execute_process(COMMAND python3 ${dronecan_dsdlc_SOURCE_DIR}/dronecan_dsdlc.py | ||
-O ${CMAKE_CURRENT_BINARY_DIR}/dsdlc_generated | ||
DSDL/uavcan | ||
DSDL/dronecan | ||
DSDL/ardupilot | ||
DSDL/com | ||
${dsdl_SOURCE_DIR}/uavcan | ||
${dsdl_SOURCE_DIR}/dronecan | ||
${dsdl_SOURCE_DIR}/ardupilot | ||
${dsdl_SOURCE_DIR}/com | ||
) | ||
|
||
if (CANARD_ENABLE_CANFD) | ||
add_definitions(-DCANARD_ENABLE_CANFD=1) | ||
endif() | ||
|
||
# generate dsdl messages | ||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/dsdlc_generated/include) | ||
|
||
# add local directory to include path | ||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) | ||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../) | ||
|
||
# add libcanard source files | ||
file(GLOB LIBCANARD_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../../*.c) | ||
list(APPEND SRC_FILES ${LIBCANARD_SOURCES}) | ||
|
||
# glob all generated dsdlc files | ||
file(GLOB DSDL_GENERATED_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dsdlc_generated/src/*.c*) | ||
|
||
# append DSDL_GENERATED_SOURCES_C to SRC_FILES | ||
list(APPEND SRC_FILES ${DSDL_GENERATED_SOURCES}) | ||
|
||
add_compile_options(-Wall -m32 -g) | ||
add_link_options(-m32) | ||
|
||
add_subdirectory(googletest) | ||
|
||
enable_testing() | ||
|
||
set(SRC_FILES_TEST ${SRC_FILES} | ||
cxx_test_interface.cpp | ||
set(SRC_FILES_TEST cxx_test_interface.cpp | ||
test_cxx_wrappers.cpp) | ||
set(SRC_FILES_CANARD ${SRC_FILES} | ||
canard_interface.cpp | ||
set(SRC_FILES_CANARD canard_interface.cpp | ||
test_canard_interface.cpp) | ||
|
||
include_directories(googletest/googletest/include) | ||
# create test target | ||
add_executable(${PROJECT_NAME}_test_cf ${SRC_FILES} ${SRC_FILES_TEST}) | ||
add_executable(${PROJECT_NAME}_test_canard ${SRC_FILES} ${SRC_FILES_CANARD}) | ||
|
||
if (CANARD_ENABLE_COVERAGE) | ||
add_compile_options(-fprofile-arcs -ftest-coverage) | ||
add_link_options(-fprofile-arcs -ftest-coverage) | ||
endif() | ||
set(DSDL_SOURCE_CFLAGS "-Wno-gnu-empty-struct -Wno-implicit-int-conversion -Wno-unused-parameter -Wno-unused-const-variable -Wno-sign-conversion -Wno-missing-declarations -Wno-conversion -Wno-pedantic") | ||
|
||
# create test target | ||
add_executable(test_cf ${SRC_FILES_TEST}) | ||
add_executable(test_canard ${SRC_FILES_CANARD}) | ||
set_source_files_properties(${SRC_FILES} PROPERTIES COMPILE_FLAGS "${CANARD_C_FLAGS} ${DSDL_SOURCE_CFLAGS}") | ||
set_source_files_properties(${SRC_FILES_TEST} PROPERTIES COMPILE_FLAGS "${CANARD_CXX_FLAGS}") | ||
set_source_files_properties(${SRC_FILES_CANARD} PROPERTIES COMPILE_FLAGS "${CANARD_CXX_FLAGS}") | ||
|
||
target_link_libraries(test_cf GTest::gtest_main) | ||
include(GoogleTest) | ||
gtest_discover_tests(test_cf) | ||
if (CANARD_LINK_FLAGS) | ||
set_target_properties(${PROJECT_NAME}_test_cf PROPERTIES LINK_FLAGS "${CANARD_LINK_FLAGS}") | ||
set_target_properties(${PROJECT_NAME}_test_canard PROPERTIES LINK_FLAGS "${CANARD_LINK_FLAGS}") | ||
endif() | ||
|
||
target_link_libraries(test_canard GTest::gtest_main) | ||
target_link_libraries(${PROJECT_NAME}_test_cf GTest::gtest_main canard_tgt canard_private_tgt pthread) | ||
include(GoogleTest) | ||
gtest_discover_tests(test_canard) | ||
gtest_discover_tests(${PROJECT_NAME}_test_cf) | ||
|
||
if (CANARD_ENABLE_COVERAGE) | ||
add_custom_target(coverage | ||
COMMAND lcov --directory . --capture --output-file coverage.info | ||
COMMAND lcov --remove coverage.info '/usr/*' '*gtest*' '*tests/*' '*dsdlc_generated/*' --output-file coverage.info | ||
COMMAND lcov --list coverage.info | ||
COMMAND genhtml coverage.info --output-directory coverage | ||
COMMENT echo "Coverage report generated at ${CMAKE_BINARY_DIR}/coverage/index.html" | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) | ||
add_custom_command(TARGET coverage POST_BUILD COMMAND ;) | ||
endif() | ||
target_link_libraries(${PROJECT_NAME}_test_canard GTest::gtest_main canard_tgt canard_private_tgt pthread) | ||
include(GoogleTest) | ||
gtest_discover_tests(${PROJECT_NAME}_test_canard) |
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
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
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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.