-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
158 lines (138 loc) · 5.2 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
cmake_minimum_required(VERSION 3.17.0)
project(arrus LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
# Version
set(PROJECT_VERSION 0.10.5)
set(ARRUS_PROJECT_VERSION "${PROJECT_VERSION}")
string(TIMESTAMP CURRENT_YEAR "%Y")
################################################################################
# Modules
################################################################################
set(CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/cmake"
${CMAKE_BINARY_DIR} # Includes cmake scripts generated by conan package
${CMAKE_MODULE_PATH})
################################################################################
# Global options and settings
################################################################################
set(ARRUS_ROOT_DIR ${CMAKE_SOURCE_DIR})
set(ARRUS_DOCS_INSTALL_DIR docs)
set(ARRUS_MATLAB_INSTALL_DIR matlab)
set(ARRUS_PYTHON_INSTALL_DIR python)
set(Us4_LIB_DIR ${Us4_ROOT_DIR}/lib64)
option(ARRUS_BUILD_PY "Build python API." OFF)
set(ARRUS_PY_VERSION "3.8" CACHE STRING "Python version for which the ARRUS package should be built.")
option(ARRUS_BUILD_MATLAB "Build MATLAB API." OFF)
option(ARRUS_BUILD_DOCS "Build documentation." OFF)
option(ARRUS_RUN_TESTS "Run all tests builded packages." OFF)
option(ARRUS_EMBED_DEPS "Embed dependencies (like us4r dlls) into the output package." OFF)
option(ARRUS_APPEND_VERSION_SUFFIX_DATE "Append current timestamp to the ARRUS_PROJECT_VERSION." OFF)
option(ARRUS_CUDA "Build with CUDA GPU support" ON)
if(ARRUS_APPEND_VERSION_SUFFIX_DATE)
string(TIMESTAMP ARRUS_PROJECT_VERSION_SUFFIX "%Y%m%d")
set(ARRUS_PROJECT_VERSION "${PROJECT_VERSION}-dev${ARRUS_PROJECT_VERSION_SUFFIX}")
endif()
# Determining host platform.
if(MSVC)
set(ARRUS_BUILD_PLATFORM windows)
elseif(UNIX AND NOT APPLE)
set(ARRUS_BUILD_PLATFORM linux)
else()
message(FATAL_ERROR "Unsupported platform.")
endif()
# Determine CUDA version.
if(ARRUS_CUDA)
find_package(CUDAToolkit REQUIRED)
message("Using CUDA ${CUDAToolkit_VERSION}")
endif()
# Common C++ compile options
if("${ARRUS_BUILD_PLATFORM}" STREQUAL "windows")
# permissive- is required by range-v3/0.5.0
set(ARRUS_CPP_COMMON_COMPILE_OPTIONS /permissive- /EHsc)
set(ARRUS_CPP_STRICT_COMPILE_OPTIONS "/W4 /WX")
set(ARRUS_CPP_COMMON_COMPILE_DEFINITIONS
_WIN32
# warnings occurs in boost bimap implementation headers
_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING
_CRT_SECURE_NO_WARNINGS)
else("${ARRUS_BUILD_PLATFORM}" STREQUAL "linux")
set(ARRUS_CPP_COMMON_COMPILE_OPTIONS "")
set(ARRUS_CPP_STRICT_COMPILE_OPTIONS "-Wall -Wextra -pedantic -Werror")
set(ARRUS_CPP_COMMON_COMPILE_DEFINITIONS
ARRUS_LINUX
_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING)
endif()
# installation directories
set(ARRUS_BIN_INSTALL_DIR bin)
set(ARRUS_LIB_INSTALL_DIR lib64)
set(ARRUS_INCLUDE_INSTALL_DIR include)
set(ARRUS_DOCS_INSTALL_DIR docs)
################################################################################
# Common dependencies
################################################################################
find_package(Us4 0.11.5 EXACT REQUIRED US4OEM HV256 DBARLite DBARLitePcie)
find_package(Boost REQUIRED)
set(Boost_USE_STATIC_LIBS ON)
find_package(Protobuf REQUIRED)
# Use project root to search for .proto files.
set(Protobuf_IMPORT_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
find_package(fmt REQUIRED)
find_package(Microsoft.GSL REQUIRED)
find_package(Eigen3 REQUIRED)
# OS specific dependencies.
if("${ARRUS_BUILD_PLATFORM}" STREQUAL "windows")
set(ARRUS_OS_DEPS "")
else("${ARRUS_BUILD_PLATFORM}" STREQUAL "linux")
set(ARRUS_OS_DEPS "")
endif()
################################################################################
# Sub-projects
################################################################################
if(ARRUS_RUN_TESTS)
include(tests)
enable_testing()
endif()
add_subdirectory(arrus/core)
if(ARRUS_BUILD_PY)
add_subdirectory(api/python)
endif()
if(ARRUS_BUILD_MATLAB)
add_subdirectory(api/matlab)
endif()
if(ARRUS_BUILD_DOCS)
add_subdirectory(docs)
endif()
add_subdirectory(installer)
################################################################################
# General docs
################################################################################
configure_file(VERSION.rst.in VERSION.rst)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/VERSION.rst
DESTINATION .
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE
DESTINATION .
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/THIRD_PARTY_LICENSES
DESTINATION .
)
################################################################################
# Embed external dependencies
################################################################################
if("${ARRUS_BUILD_PLATFORM}" STREQUAL "linux")
set(CMAKE_SKIP_RPATH TRUE)
endif()
if(ARRUS_EMBED_DEPS)
# TODO Remove transitive dependency on boost (embed deps directly).
message("Us4r API ROOT DIR: ${Us4_ROOT_DIR}")
# Sanitize provided path.
string(REPLACE "\\" "/" Us4_ROOT_DIR_SANITIZED ${Us4_ROOT_DIR})
install(
DIRECTORY
${Us4_ROOT_DIR_SANITIZED}/lib64/
DESTINATION
${ARRUS_LIB_INSTALL_DIR})
endif()