1- cmake_minimum_required (VERSION 3.13 )
1+ cmake_minimum_required (VERSION 3.14 )
22
33project (libOpenDrive VERSION 0.6.0 DESCRIPTION ".xodr library" )
44
5- include (CTest )
65include (FetchContent )
76include (GNUInstallDirs )
87
8+ option (OPENDRIVE_BUILD_TESTS "Build OpenDrive tests" OFF )
9+
910find_package (pugixml QUIET CONFIG )
10- if (NOT pugixml_FOUND)
11- FetchContent_Declare (
12- pugixml
13- GIT_REPOSITORY https://github.com/zeux/pugixml.git
14- GIT_TAG v1.14
15- )
16- FetchContent_MakeAvailable (pugixml)
17- add_library (pugixml::pugixml ALIAS pugixml )
11+ if (NOT TARGET pugixml::pugixml)
12+ if (TARGET pugixml)
13+ add_library (pugixml::pugixml ALIAS pugixml )
14+ else ()
15+ FetchContent_Declare (
16+ pugixml
17+ GIT_REPOSITORY https://github.com/zeux/pugixml.git
18+ GIT_TAG v1.14
19+ )
20+ FetchContent_MakeAvailable (pugixml)
21+ add_library (pugixml::pugixml ALIAS pugixml )
22+ endif ()
1823endif ()
1924
2025set (SOURCES
@@ -40,9 +45,11 @@ set(SOURCES
4045)
4146
4247add_library (OpenDrive ${SOURCES} )
48+ add_library (OpenDrive::OpenDrive ALIAS OpenDrive )
4349set_target_properties (OpenDrive PROPERTIES
4450 CXX_STANDARD 17
4551 CXX_STANDARD_REQUIRED ON
52+ POSITION_INDEPENDENT_CODE ON
4653)
4754if (MSVC )
4855 target_compile_options (OpenDrive PRIVATE /W3 /EHsc )
@@ -60,6 +67,7 @@ target_include_directories(
6067)
6168
6269if (OPENDRIVE_BUILD_TESTS)
70+ include (CTest )
6371 FetchContent_Declare (
6472 Catch2
6573 GIT_REPOSITORY https://github.com/catchorg/Catch2.git
@@ -75,6 +83,7 @@ endif()
7583
7684install (
7785 TARGETS OpenDrive
86+ EXPORT OpenDriveTargets
7887 INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
7988 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
8089 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
0 commit comments