-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCMakeLists.txt
123 lines (102 loc) · 3.22 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# @file CMakeLists.txt
#
# Top level build instructions.
#
#
# Make sure there is a reasonable version of CMAKE installed.
#
cmake_minimum_required(VERSION 3.1)
set(CPACK_PACKAGE_VERSION "6.1.0")
if (${CMAKE_VERSION} VERSION_LESS "3.12")
project(LibMultiSense
LANGUAGES C CXX
VERSION ${CPACK_PACKAGE_VERSION})
else()
project(LibMultiSense
LANGUAGES C CXX
HOMEPAGE_URL https://carnegierobotics.com
DESCRIPTION "The CRL Multisense Interface Library"
VERSION ${CPACK_PACKAGE_VERSION})
endif ()
include (CheckCXXSourceCompiles)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
string (REGEX REPLACE "/W3" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string (REGEX REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
add_compile_options(/WX)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS)
else()
add_compile_options(-Wall -Wextra -Werror -Wpedantic -Wno-variadic-macros)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
#
# Fix warnings with __VA__OPT__ when we port to c++2a
# https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
#
add_compile_options(-Wno-gnu-zero-variadic-macro-arguments)
endif()
option (MULTISENSE_BUILD_UTILITIES "Build MultiSense utility applications. Defaults to ON for backwards compatibility." ON)
option (BUILD_SHARED_LIBS "Build LibMultiSense as a shared library. Defaults to ON." ON)
option (BUILD_TESTS "Build LibMultiSense GTests. Defaults to OFF." OFF)
if (BUILD_TESTS)
enable_testing()
endif()
#
# We want to build "Release" by default
#
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Selecting default build type: Release")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (default: Release)" FORCE)
endif ()
#
# Check if the compiler supports constexpr
#
check_cxx_source_compiles (
"int main() { constexpr int x = 0; }"
HAVE_CONSTEXPR
)
if (HAVE_CONSTEXPR)
add_definitions(-DCRL_HAVE_CONSTEXPR)
endif ()
#
# For Backwards compatablity with other ROS builds
#
if (BASE_DIRECTORY)
else()
set(BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set(SOURCE_DIRECTORY )
endif()
#
# Use full RPATH
#
set (CMAKE_SKIP_BUILD_RPATH FALSE)
set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set (CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#
# Dispatch to subordinate CMakeList.txt files.
#
add_subdirectory(source)
#
# Generate pc file, for pkgconfig compatibility
#
if (NOT ${CMAKE_VERSION} VERSION_LESS "3.12")
file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/LibMultiSense.pc CONTENT
"prefix=\"${CMAKE_INSTALL_PREFIX}\"
exec_prefix=\"\${prefix}\"
libdir=\"\${prefix}/lib\"
includedir=\"\${prefix}/include\"
Name: ${PROJECT_NAME}
Description: ${CMAKE_PROJECT_DESCRIPTION}
URL: ${CMAKE_PROJECT_HOMEPAGE_URL}
Version: ${PROJECT_VERSION}
Cflags: -I$<JOIN:\"\${includedir}\";$<TARGET_PROPERTY:MultiSense,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>, -I>
Libs: -L\"\${libdir}\" -lMultiSense
")
install(FILES ${CMAKE_BINARY_DIR}/LibMultiSense.pc DESTINATION lib/pkgconfig COMPONENT development)
endif ()
#
# Add cpack
#
if(CMAKE_ENABLE_CPACK)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/cpack.cmake)
endif()