From 79a57335e66ecf9148f8c3dafc624b13a715d5bc Mon Sep 17 00:00:00 2001 From: Timm Ruppert Date: Thu, 14 Nov 2024 11:07:32 +0100 Subject: [PATCH] cleanup Signed-off-by: Timm Ruppert --- CMakeLists.txt | 16 ++++++++-------- src/CMakeLists.txt | 8 +++----- src/tracefile/writer/MCAPTraceFileWriter.cpp | 2 +- tests/CMakeLists.txt | 12 +++--------- 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cec3d8f..6296300 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ option(LINK_WITH_SHARED_OSI "Link utils with shared OSI library instead of stati # Locate open_simulation_interface using find_package or custom path. if (USE_EXTERNAL_OSI) message(FATAL_ERROR "Not implemented yet") -else() +else () # Download and use our own open_simulation_interface package. include(FetchContent) FetchContent_Declare( @@ -27,19 +27,19 @@ else() ) FetchContent_MakeAvailable(open_simulation_interface) set(OSI_INCLUDE_DIR ${open_simulation_interface_BINARY_DIR}) -endif() +endif () # option to enable coverage reporting option(CODE_COVERAGE "Enable coverage reporting" OFF) -if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") +if (CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") add_compile_options(--coverage -O0 -g) add_link_options(--coverage) message(WARNING "Added coverage options") -endif() +endif () # build doxygen documentation find_package(Doxygen) -if(DOXYGEN_FOUND AND PROJECT_IS_TOP_LEVEL) +if (DOXYGEN_FOUND AND PROJECT_IS_TOP_LEVEL) message(STATUS "Doxygen found, generating API documentation") # set input and output files set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in) @@ -55,11 +55,11 @@ if(DOXYGEN_FOUND AND PROJECT_IS_TOP_LEVEL) COMMENT "Generating API documentation with Doxygen" VERBATIM ) -endif(DOXYGEN_FOUND AND PROJECT_IS_TOP_LEVEL) +endif (DOXYGEN_FOUND AND PROJECT_IS_TOP_LEVEL) add_subdirectory(src) -if(PROJECT_IS_TOP_LEVEL) +if (PROJECT_IS_TOP_LEVEL) enable_testing() add_subdirectory(tests) -endif() +endif () add_subdirectory(examples) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2816e94..75ea039 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,18 +24,16 @@ target_include_directories(OSIUtilities PUBLIC ${PROJECT_SOURCE_DIR}/include) # Link against OSI made available by parent CMakeLists.txt -if(LINK_WITH_SHARED_OSI) +if (LINK_WITH_SHARED_OSI) target_link_libraries(OSIUtilities PRIVATE open_simulation_interface) -else() +else () target_link_libraries(OSIUtilities PRIVATE open_simulation_interface_pic) include_directories(${OSI_INCLUDE_DIR}) -endif() +endif () # get mcap and its dependencies -# todo change logic and cleanup find_package(PkgConfig REQUIRED) pkg_check_modules(lz4 REQUIRED IMPORTED_TARGET liblz4) pkg_check_modules(zstd REQUIRED libzstd) target_link_libraries(OSIUtilities PRIVATE ${lz4_LIBRARIES} ${zstd_LIBRARIES}) - target_include_directories(OSIUtilities PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../lib/mcap/cpp/mcap/include) \ No newline at end of file diff --git a/src/tracefile/writer/MCAPTraceFileWriter.cpp b/src/tracefile/writer/MCAPTraceFileWriter.cpp index 6ec14bf..c361098 100644 --- a/src/tracefile/writer/MCAPTraceFileWriter.cpp +++ b/src/tracefile/writer/MCAPTraceFileWriter.cpp @@ -21,7 +21,7 @@ namespace { // helper functions from https://github.com/foxglove/mcap/blob/4ec37c5a5d0115bceaca428b1e8a0e3e5aae20cf/website/docs/guides/cpp/protobuf.md?plain=1#L198 -// TODO: might want to change to the approach used here https://github.com/foxglove/mcap/blob/main/cpp/examples/protobuf/writer.cpp + // Recursively adds all `fd` dependencies to `fd_set`. void fdSetInternal(google::protobuf::FileDescriptorSet& fd_set, std::unordered_set& files, const google::protobuf::FileDescriptor* file_descriptor) { for (int i = 0; i < file_descriptor->dependency_count(); ++i) { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f1e84b8..55f1bc1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -11,9 +11,6 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) include(GoogleTest) - - - file(GLOB_RECURSE test_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) file(GLOB_RECURSE src_sources ${CMAKE_CURRENT_SOURCE_DIR}/../src/*.cpp) @@ -25,15 +22,14 @@ add_executable( target_link_libraries(unit_tests PRIVATE GTest::gtest_main) # Link against OSI made available by parent CMakeLists.txt -if(LINK_WITH_SHARED_OSI) +if (LINK_WITH_SHARED_OSI) target_link_libraries(unit_tests PRIVATE open_simulation_interface) -else() +else () target_link_libraries(unit_tests PRIVATE open_simulation_interface_pic) include_directories(${OSI_INCLUDE_DIR}) -endif() +endif () # get mcap and its dependencies -# todo change logic and cleanup find_package(PkgConfig REQUIRED) pkg_check_modules(lz4 REQUIRED IMPORTED_TARGET liblz4) pkg_check_modules(zstd REQUIRED libzstd) @@ -42,6 +38,4 @@ target_include_directories(unit_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib # include public headers of the library target_include_directories(unit_tests PRIVATE ${PROJECT_SOURCE_DIR}/include) - - gtest_discover_tests(unit_tests) # Register the tests to gtest \ No newline at end of file