Skip to content

Commit

Permalink
implement usage of external osi (#12)
Browse files Browse the repository at this point in the history
* implement usage of external osi

Signed-off-by: Timm Ruppert <[email protected]>

* typos and cosmetics

Signed-off-by: Timm Ruppert <[email protected]>

---------

Signed-off-by: Timm Ruppert <[email protected]>
  • Loading branch information
TimmRuppert authored Dec 20, 2024
1 parent 0117e7b commit 33685c8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.16)
project(osi-utilities)
project(asam-osi-utilities)

# Som features (e.g. mcap) require at least C++17
# Some features (e.g. mcap) require at least C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Generate compile_commands.json for clang based tools
Expand All @@ -14,21 +14,26 @@ include_directories(${PROJECT_SOURCE_DIR}/include)
option(USE_EXTERNAL_OSI "Use an external version of open_simulation_interface" OFF)
option(LINK_WITH_SHARED_OSI "Link utils with shared OSI library instead of statically linking" OFF)

# Locate open_simulation_interface using find_package or custom path.
# Locate open_simulation_interface
if (USE_EXTERNAL_OSI)
message(FATAL_ERROR "Not implemented yet")
# if you use this library in your own project, you need to add
# something like list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/lib/open-simulation-interface)
# to your CMakeLists.txt so that we can fine the open_simulation_interface package.
find_package(open_simulation_interface QUIET REQUIRED)
message(STATUS "Using external OSI, provided by ${open_simulation_interface_DIR}")
else ()
# Download and use our own open_simulation_interface package.
include(FetchContent)
message(STATUS "Using internal OSI, downloading open_simulation_interface...")
FetchContent_Declare(
open_simulation_interface
GIT_REPOSITORY https://github.com/OpenSimulationInterface/open-simulation-interface.git
GIT_TAG v3.7.0
)
FetchContent_MakeAvailable(open_simulation_interface)
set(OSI_INCLUDE_DIR ${open_simulation_interface_BINARY_DIR})
endif ()


# option to enable coverage reporting
option(CODE_COVERAGE "Enable coverage reporting" OFF)
if (CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
Expand Down
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ if (LINK_WITH_SHARED_OSI)
target_link_libraries(OSIUtilities PRIVATE open_simulation_interface)
else ()
target_link_libraries(OSIUtilities PRIVATE open_simulation_interface_pic)
include_directories(${OSI_INCLUDE_DIR})
endif ()
include_directories(${open_simulation_interface_BINARY_DIR})


# get mcap and its dependencies
find_package(PkgConfig REQUIRED)
Expand Down
4 changes: 3 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ add_executable(
${src_sources}
)
target_link_libraries(unit_tests PRIVATE GTest::gtest_main)

# see src/CMakeLists.txt
target_compile_definitions(unit_tests PRIVATE OSI_TRACE_FILE_SPEC_VERSION="3.7.1")

Expand All @@ -28,8 +29,9 @@ if (LINK_WITH_SHARED_OSI)
target_link_libraries(unit_tests PRIVATE open_simulation_interface)
else ()
target_link_libraries(unit_tests PRIVATE open_simulation_interface_pic)
include_directories(${OSI_INCLUDE_DIR})
endif ()
include_directories(${open_simulation_interface_BINARY_DIR})


# get mcap and its dependencies
find_package(PkgConfig REQUIRED)
Expand Down

0 comments on commit 33685c8

Please sign in to comment.