Skip to content

cmake target for testing

In the openSCENARIO Engine we use find_package(Mantle_API) and

target_link_libraries(${PROJECT_NAME} PUBLIC openscenario_api::shared 
                                             antlr4_runtime::shared 
                                             Yase::agnostic_behavior_tree 
                                             units::units 
                                             MantleAPI::MantleAPI) # OKAY

For testing, this does not work as Mantle does not make the Test include directory available.

Right now, I need to do:

target_include_directories(
  ${PROJECT_NAME}Test
  PRIVATE gen
          src
          tests
          ${MantleAPI_INCLUDE_DIR}/../test # AWKWARD
          $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>)

I'd like to do

target_link_libraries(
  ${PROJECT_NAME}Test
  PRIVATE ${PROJECT_NAME}
          MantleAPI::Testing # COOL
          GTest::gmock_main
          pthread
)