1919 set (CMAKE_CXX_FLAGS_RELEASE "-O3" )
2020endif ()
2121
22- include (CTest )
2322include (FetchContent )
2423include (GNUInstallDirs )
2524
@@ -30,13 +29,17 @@ FetchContent_Declare(
3029)
3130FetchContent_MakeAvailable (pugixml)
3231
33- FetchContent_Declare (
34- Catch2
35- GIT_REPOSITORY https://github.com/catchorg/Catch2.git
36- GIT_TAG v3.4.0
37- )
38- FetchContent_MakeAvailable (Catch2)
39- include (Catch )
32+ # Only include testing dependencies if BUILD_TESTING is ON and BUILD_SHARED_LIBS is OFF
33+ if (BUILD_TESTING AND NOT BUILD_SHARED_LIBS )
34+ include (CTest )
35+ FetchContent_Declare (
36+ Catch2
37+ GIT_REPOSITORY https://github.com/catchorg/Catch2.git
38+ GIT_TAG v3.4.0
39+ )
40+ FetchContent_MakeAvailable (Catch2)
41+ include (Catch )
42+ endif ()
4043
4144set (SOURCES
4245 src/Geometries/Arc.cpp
@@ -70,9 +73,12 @@ target_include_directories(
7073 $<BUILD_INTERFACE :${pugixml_SOURCE_DIR} /src >
7174)
7275
73- add_executable (tests tests/test.cpp )
74- target_link_libraries (tests PRIVATE OpenDrive Catch2::Catch2WithMain )
75- catch_discover_tests (tests WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} /tests )
76+ # Only build tests if BUILD_TESTING is ON and BUILD_SHARED_LIBS is OFF
77+ if (BUILD_TESTING AND NOT BUILD_SHARED_LIBS )
78+ add_executable (tests tests/test.cpp )
79+ target_link_libraries (tests PRIVATE OpenDrive Catch2::Catch2WithMain )
80+ catch_discover_tests (tests WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} /tests )
81+ endif ()
7682
7783install (
7884 TARGETS OpenDrive
@@ -89,4 +95,4 @@ install(
8995)
9096install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} /include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
9197install (TARGETS OpenDrive EXPORT OpenDriveConfig)
92- install (EXPORT OpenDriveConfig NAMESPACE OpenDrive:: DESTINATION cmake)
98+ install (EXPORT OpenDriveConfig NAMESPACE OpenDrive:: DESTINATION cmake)
0 commit comments