forked from heremaps/here-data-sdk-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
105 lines (88 loc) · 3.81 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Copyright (C) 2019-2021 HERE Europe B.V.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
# License-Filename: LICENSE
cmake_minimum_required(VERSION 3.9)
# Build the sdk targets
project(olp-cpp-sdk VERSION 1.16.0)
# Add preprocessor definitions for the SDK version and platform name
add_definitions(-DOLP_SDK_VERSION_STRING=\"${olp-cpp-sdk_VERSION}\")
add_definitions(-DOLP_SDK_VERSION_MAJOR=${olp-cpp-sdk_VERSION_MAJOR})
add_definitions(-DOLP_SDK_VERSION_MINOR=${olp-cpp-sdk_VERSION_MINOR})
add_definitions(-DOLP_SDK_VERSION_PATCH=${olp-cpp-sdk_VERSION_PATCH})
if (APPLE AND IOS)
# To distinguish iOS platform from other Darwin platforms
add_definitions(-DOLP_SDK_PLATFORM_NAME=\"iOS\")
else()
add_definitions(-DOLP_SDK_PLATFORM_NAME=\"${CMAKE_SYSTEM_NAME}\")
endif()
# Options
option(OLP_SDK_ENABLE_TESTING "Flag to enable/disable building unit and integration tests" ON)
option(OLP_SDK_BUILD_DOC "Build SDK documentation" OFF)
option(OLP_SDK_NO_EXCEPTION "Disable exception handling" OFF)
option(OLP_SDK_BOOST_THROW_EXCEPTION_EXTERNAL "The boost::throw_exception() is defined externally" OFF)
option(OLP_SDK_BUILD_EXTERNAL_DEPS "Download and build external dependencies" ON)
option(OLP_SDK_BUILD_EXAMPLES "Enable examples targets" OFF)
option(OLP_SDK_MSVC_PARALLEL_BUILD_ENABLE "Enable parallel build on MSVC" ON)
option(OLP_SDK_DISABLE_DEBUG_LOGGING "Disable debug and trace level logging" OFF)
option(OLP_SDK_ENABLE_DEFAULT_CACHE "Enable default cache implementation based on LevelDB" ON)
option(OLP_SDK_ENABLE_DEFAULT_CACHE_LMDB "Enable default cache implementation based on LMDB" OFF)
option(OLP_SDK_ENABLE_ANDROID_CURL "Enable curl based network layer for Android" OFF)
# C++ standard version. Minimum supported version is 11.
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Set no exception
if (OLP_SDK_NO_EXCEPTION)
set(CMAKE_CXX_FLAGS "-fno-exceptions ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-fno-exceptions ${CMAKE_C_FLAGS}")
endif()
if (MSVC AND OLP_SDK_MSVC_PARALLEL_BUILD_ENABLE)
add_compile_options(/MP)
message(STATUS "MSVC - Using parallel compilation (/MP)")
endif (MSVC AND OLP_SDK_MSVC_PARALLEL_BUILD_ENABLE)
# Add cmake dir to search list
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# Save root sdk folder path
get_filename_component(OLP_CPP_SDK_ROOT "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE)
# Include common scripts
include(common)
# Include code coverage variables
include(coverage)
if (OLP_SDK_BUILD_EXTERNAL_DEPS)
# Add third-party dependencies
set(EXTERNAL_BINARY_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install)
add_subdirectory(external)
list(APPEND CMAKE_PREFIX_PATH ${EXTERNAL_BINARY_INSTALL_DIR})
list(APPEND CMAKE_FIND_ROOT_PATH "${EXTERNAL_BINARY_INSTALL_DIR}/")
endif()
# Add the sdks
add_sdks()
# Add docs
add_subdirectory(docs)
if(OLP_SDK_ENABLE_TESTING)
add_subdirectory(tests/custom-params)
# Add tests
add_subdirectory(tests/common)
add_subdirectory(tests/functional)
add_subdirectory(tests/functional/network)
add_subdirectory(tests/integration)
add_subdirectory(tests/performance)
endif()
# Add example
if(OLP_SDK_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
# Add uninstall script
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_MODULE_PATH}/uninstall.cmake")