-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
81 lines (64 loc) · 2.73 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
# Copyright (C) Point One Navigation - All Rights Reserved
cmake_minimum_required(VERSION 3.6)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
# Option definitions.
option(BUILD_SHARED_LIBS "Build shared libraries instead of static libraries."
ON)
option(POLARIS_BUILD_EXAMPLES "Build example applications." ON)
# Backwards compatibility. BUILD_EXAMPLES is deprecated and may be removed in a
# future release.
if (DEFINED BUILD_EXAMPLES AND BUILD_EXAMPLES)
set(POLARIS_BUILD_EXAMPLES ${BUILD_EXAMPLES})
endif()
# Set toolchain parameters before calling project().
set(CMAKE_CXX_STANDARD 11)
# Define the project and setup the compiler toolchain.
project(p1_polaris_client)
# Set compilation flags.
if (MSVC)
add_compile_options(/W4 /WX)
else()
add_compile_options(-Wall -Werror -Wno-unused-variable)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")
endif()
################################################################################
# Check for dependencies.
################################################################################
# Find gflags.
option(GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION TRUE)
find_package(Gflags REQUIRED)
include_directories(${GFLAGS_INCLUDE_DIRS})
# Find glog (requires gflags).
option(GLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION TRUE)
find_package(Glog REQUIRED)
include_directories(${GLOG_INCLUDE_DIRS})
################################################################################
# Library Definitions
################################################################################
# Add the C library, used by the C++ library.
add_subdirectory(c)
# Polaris client C++ library - all messages and supporting code.
add_library(polaris_cpp_client
src/point_one/polaris/polaris_client.cc
src/point_one/polaris/polaris_interface.cc)
target_include_directories(polaris_client PUBLIC ${PROJECT_SOURCE_DIR}/src)
if (MSVC)
target_compile_definitions(polaris_cpp_client PRIVATE BUILDING_DLL)
endif()
if (POLARIS_ENABLE_TLS)
target_compile_definitions(polaris_cpp_client PUBLIC POLARIS_USE_TLS=1)
endif()
target_link_libraries(polaris_cpp_client PUBLIC polaris_client)
target_link_libraries(polaris_cpp_client PUBLIC ${GLOG_LIBRARIES})
target_link_libraries(polaris_cpp_client PUBLIC ${GFLAGS_LIBRARIES})
# Install targets.
install(TARGETS polaris_cpp_client
LIBRARY DESTINATION lib)
install(DIRECTORY src/point_one DESTINATION include
FILES_MATCHING PATTERN "*.h")
################################################################################
# Example Applications
################################################################################
if (POLARIS_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()