-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
165 lines (132 loc) · 3.89 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
158
159
160
161
162
163
164
165
cmake_minimum_required(VERSION 3.15)
project(scopi)
# Flags
# ===========
# 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)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic ")
set(CMAKE_CXX_STANDARD 17)
message(STATUS "CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set(SCOPI_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
# Versionning
# ===========
include(version)
set_version()
# Options
# =======
OPTION(SCOPI_USE_TBB "enable TBB" OFF)
OPTION(SCOPI_USE_OPENMP "enable OpenMP" OFF)
OPTION(SCOPI_USE_MOSEK "enable Mosek" OFF)
OPTION(SCOPI_USE_SCS "enable SCS" OFF)
OPTION(BUILD_EXAMPLES "scopi examples" OFF)
OPTION(BUILD_TESTS "scopi test suite" OFF)
if(SCOPI_USE_TBB AND SCOPI_USE_OPENMP)
message(
FATAL
"SCOPI_USE_TBB and SCOPI_USE_OPENMP cannot both be active at once"
)
endif()
# Dependencies
# ============
if(SCOPI_USE_TBB)
set(XTENSOR_USE_TBB 1)
endif()
find_package(xtensor REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(fmt REQUIRED)
find_package(CLI11 REQUIRED)
find_package(plog REQUIRED)
find_package(nanoflann REQUIRED)
# section needed to use xtensor-blas
# see https://xtensor-blas.readthedocs.io/en/latest/performance.html
add_definitions(-DHAVE_CBLAS=1)
if(WIN32)
find_package(OpenBLAS REQUIRED)
set(BLAS_LIBRARIES ${CMAKE_INSTALL_PREFIX}${OpenBLAS_LIBRARIES})
else()
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
endif()
message(STATUS "BLAS VENDOR: " ${BLA_VENDOR})
message(STATUS "BLAS LIBRARIES: " ${BLAS_LIBRARIES})
# end of xtensor-blas section
if(SCOPI_USE_TBB)
find_package(TBB REQUIRED)
endif()
if(SCOPI_USE_OPENMP)
find_package(OpenMP REQUIRED)
endif()
if(SCOPI_USE_MOSEK)
find_package(MOSEK REQUIRED)
if(APPLE)
set(MOSEK_FUSION_LIBRARY "" CACHE FILEPATH "MOSEK FUSION LIBRARY")
endif(APPLE)
endif()
if(SCOPI_USE_SCS)
find_package(scs REQUIRED)
endif()
# Package
# =======
set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE)
set(SCOPI_SRC
src/vap/vap_fixed.cpp
src/vap/vap_fpd.cpp
src/vap/vap_projection.cpp
src/minpack.cpp
src/params.cpp
src/quaternion.cpp
src/utils.cpp
)
add_library(scopi ${SCOPI_SRC})
target_include_directories(scopi PUBLIC
$<BUILD_INTERFACE:${SCOPI_INCLUDE_DIR}>
$<INSTALL_INTERFACE:include>)
target_link_libraries(scopi PUBLIC xtensor
nlohmann_json::nlohmann_json
fmt::fmt
CLI11::CLI11
plog::plog
nanoflann::nanoflann
${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
# set_target_properties(scopi PROPERTIES
# PUBLIC_HEADER "${SCOPI_HEADERS}"
# # COMPILE_DEFINITIONS "SCOPI_EXPORTS"
# PREFIX ""
# VERSION ${${PROJECT_NAME}_VERSION}
# SOVERSION ${VERSION_MAJOR}
# OUTPUT_NAME "libscopi")
if(SCOPI_USE_TBB)
target_link_libraries(scopi PUBLIC TBB::tbb)
target_compile_definitions(scopi PUBLIC SCOPI_USE_TBB)
endif()
if(SCOPI_USE_OPENMP)
target_link_libraries(scopi PUBLIC OpenMP::OpenMP_CXX)
target_compile_definitions(scopi PUBLIC SCOPI_USE_OPENMP)
endif()
if(SCOPI_USE_MOSEK)
include_directories(SYSTEM ${MOSEK_INCLUDE_DIR})
target_link_libraries(scopi LINK_PUBLIC ${MOSEK_LIBRARIES})
target_include_directories(scopi PUBLIC ${MOSEK_INCLUDE_DIR})
target_compile_definitions(scopi PUBLIC SCOPI_USE_MOSEK)
endif()
if(SCOPI_USE_SCS)
include_directories(SYSTEM ${scs_INCLUDE_DIR})
target_link_libraries(scopi PUBLIC ${scs_LIBRARIES})
target_include_directories(scopi PUBLIC ${scs_INCLUDE_DIR})
target_compile_definitions(scopi PUBLIC SCOPI_USE_SCS)
endif()
if(BUILD_EXAMPLES)
add_subdirectory(demos)
else()
add_subdirectory(demos EXCLUDE_FROM_ALL)
endif()
if(BUILD_TESTS)
add_subdirectory(test)
endif()
# Installation
# ============
include(installation)
install_project()