Skip to content

Commit

Permalink
implement usage of external osi
Browse files Browse the repository at this point in the history
Signed-off-by: Timm Ruppert <[email protected]>
  • Loading branch information
TimmRuppert committed Dec 16, 2024
1 parent 8941fbe commit f760050
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
16 changes: 11 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,27 @@ 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 using internal or find_package.
if (USE_EXTERNAL_OSI)
message(FATAL_ERROR "Not implemented yet")
# if you use this library in your project, you need to add
# something lik list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/lib/open-simulation-interface)
# to your CMakeLists.txt to find 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

0 comments on commit f760050

Please sign in to comment.