From f760050629bb50aff86d760254edff36cdeff347 Mon Sep 17 00:00:00 2001 From: Timm Ruppert Date: Mon, 16 Dec 2024 15:40:50 +0100 Subject: [PATCH] implement usage of external osi Signed-off-by: Timm Ruppert --- CMakeLists.txt | 16 +++++++++++----- src/CMakeLists.txt | 3 ++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6296300..59ab92d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fd14d7c..5f2ec8b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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)