forked from JensKlimke/odrparser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
58 lines (41 loc) · 1.42 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
cmake_minimum_required(VERSION 3.10)
# based on https://cliutils.gitlab.io/modern-cmake/
# define project
project(ODRParser
VERSION 1.0.0
DESCRIPTION "A very simple OpenDRIVE parser"
LANGUAGES CXX)
# c++ version
set(CMAKE_CXX_STANDARD 14)
# add ./cmake to CMAKE_MODULE_PATH
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# unset testing for libs
option(BUILD_TESTS "Sets or unsets the option to generate the test target" OFF)
option(BUILD_GTEST "Sets or unsets the option to build gtest manually (do not set if gtest is installed)" OFF)
# add source directory
add_subdirectory(src)
## add tinyxml2
set(BUILD_TESTING off CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS off CACHE BOOL "" FORCE)
# load tinyxml2
add_subdirectory(lib/tinyxml2 EXCLUDE_FROM_ALL)
### GTEST
if ((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) AND BUILD_TESTS)
# enable testing and load library
enable_testing()
# switch (build or use installed lib)
if (BUILD_GTEST)
# add subdirectory
add_subdirectory(googletest EXCLUDE_FROM_ALL)
set(GTEST_BOTH_LIBRARIES gtest_main)
include_directories(./googletest/googletest/include)
else()
# find gtest
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
endif()
# load macros for test
include(AddGoogleTest)
# add test sources
add_subdirectory(tests)
endif ()