Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Timm Ruppert <[email protected]>
  • Loading branch information
TimmRuppert committed Nov 14, 2024
1 parent 565e7c0 commit 79a5733
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 23 deletions.
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand All @@ -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)
8 changes: 3 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion src/tracefile/writer/MCAPTraceFileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>& files, const google::protobuf::FileDescriptor* file_descriptor) {
for (int i = 0; i < file_descriptor->dependency_count(); ++i) {
Expand Down
12 changes: 3 additions & 9 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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

0 comments on commit 79a5733

Please sign in to comment.