-
Notifications
You must be signed in to change notification settings - Fork 39
/
CMakeLists.txt
471 lines (419 loc) · 16.7 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
#
# Copyright (c) 2014-2019 CNRS Copyright (c) 2018-2023 INRIA
#
cmake_minimum_required(VERSION 3.10)
set(PROJECT_NAME eigenpy)
set(PROJECT_DESCRIPTION "Bindings between Numpy and Eigen using Boost.Python")
set(PROJECT_URL "http://github.com/stack-of-tasks/eigenpy")
set(PROJECT_USE_CMAKE_EXPORT TRUE)
set(PROJECT_USE_KEYWORD_LINK_LIBRARIES TRUE)
set(PROJECT_CUSTOM_HEADER_EXTENSION "hpp")
set(PROJECT_COMPATIBILITY_VERSION AnyNewerVersion)
# To enable jrl-cmakemodules compatibility with workspace we must define the two
# following lines
set(PROJECT_AUTO_RUN_FINALIZE FALSE)
set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR})
# Check if the submodule cmake have been initialized
set(JRL_CMAKE_MODULES "${CMAKE_CURRENT_LIST_DIR}/cmake")
if(EXISTS "${JRL_CMAKE_MODULES}/base.cmake")
message(STATUS "JRL cmakemodules found in 'cmake/' git submodule")
else()
find_package(jrl-cmakemodules QUIET CONFIG)
if(jrl-cmakemodules_FOUND)
get_property(
JRL_CMAKE_MODULES
TARGET jrl-cmakemodules::jrl-cmakemodules
PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "JRL cmakemodules found on system at ${JRL_CMAKE_MODULES}")
elseif(${CMAKE_VERSION} VERSION_LESS "3.14.0")
message(
FATAL_ERROR
"\nCan't find jrl-cmakemodules. Please either:\n"
" - use git submodule: 'git submodule update --init'\n"
" - or install https://github.com/jrl-umi3218/jrl-cmakemodules\n"
" - or upgrade your CMake version to >= 3.14 to allow automatic fetching\n"
)
else()
message(STATUS "JRL cmakemodules not found. Let's fetch it.")
include(FetchContent)
FetchContent_Declare(
"jrl-cmakemodules"
GIT_REPOSITORY "https://github.com/jrl-umi3218/jrl-cmakemodules.git")
FetchContent_MakeAvailable("jrl-cmakemodules")
FetchContent_GetProperties("jrl-cmakemodules" SOURCE_DIR JRL_CMAKE_MODULES)
endif()
endif()
function(set_standard_output_directory target)
set_target_properties(
${target}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
endfunction()
# Disable -Werror on Unix for now.
set(CXX_DISABLE_WERROR True)
set(CMAKE_VERBOSE_MAKEFILE True)
# ----------------------------------------------------
# --- OPTIONS ---------------------------------------
# Need to be set before including base.cmake
# ----------------------------------------------------
option(INSTALL_DOCUMENTATION "Generate and install the documentation" OFF)
option(SUFFIX_SO_VERSION "Suffix library name with its version" OFF)
option(BUILD_TESTING_SCIPY
"Build the SciPy tests (scipy should be installed on the machine)" ON)
# Use BoostConfig module distributed by boost library instead of using FindBoost
# module distributed by CMake
if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()
include("${JRL_CMAKE_MODULES}/base.cmake")
compute_project_args(PROJECT_ARGS LANGUAGES CXX)
project(${PROJECT_NAME} ${PROJECT_ARGS})
include("${JRL_CMAKE_MODULES}/boost.cmake")
include("${JRL_CMAKE_MODULES}/python.cmake")
include("${JRL_CMAKE_MODULES}/ide.cmake")
include("${JRL_CMAKE_MODULES}/apple.cmake")
option(GENERATE_PYTHON_STUBS
"Generate the Python stubs associated to the Python library" OFF)
option(BUILD_WITH_CHOLMOD_SUPPORT "Build EigenPy with the Cholmod support" OFF)
if(APPLE)
option(BUILD_WITH_ACCELERATE_SUPPORT
"Build EigenPy with the Accelerate support" OFF)
else(APPLE)
set(BUILD_WITH_ACCELERATE_SUPPORT FALSE)
endif(APPLE)
string(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
# If needed, fix CMake policy for APPLE systems
apply_default_apple_configuration()
check_minimal_cxx_standard(11 ENFORCE)
if(WIN32)
set(LINK copy_if_different)
else(WIN32)
set(LINK create_symlink)
endif(WIN32)
if(CMAKE_CROSSCOMPILING)
set(PYTHON_COMPONENTS Interpreter NumPy)
else()
set(PYTHON_COMPONENTS Interpreter Development.Module NumPy)
endif()
set(PYTHON_EXPORT_DEPENDENCY ON)
findpython(REQUIRED)
if(${NUMPY_VERSION} VERSION_LESS "1.16.0")
set(NUMPY_WITH_BROKEN_UFUNC_SUPPORT TRUE)
endif()
if(WIN32)
link_directories(${PYTHON_LIBRARY_DIRS})
# # Set default Windows build paths SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY
# ${PROJECT_BINARY_DIR}/Bin CACHE PATH "Single directory for all libraries")
# SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin CACHE PATH
# "Single directory for all executables") SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
# ${PROJECT_BINARY_DIR}/Bin CACHE PATH "Sing$le directory for all archives")
endif(WIN32)
# ----------------------------------------------------
# --- DEPENDENCIES -----------------------------------
# ----------------------------------------------------
add_project_dependency(Eigen3 REQUIRED PKG_CONFIG_REQUIRES "eigen3 >= 3.0.5")
set_boost_default_options()
export_boost_default_options()
find_package(Boost REQUIRED)
search_for_boost_python(REQUIRED)
if(BUILD_WITH_CHOLMOD_SUPPORT)
set(CMAKE_MODULE_PATH ${JRL_CMAKE_MODULES}/find-external/CHOLMOD
${CMAKE_MODULE_PATH})
add_project_dependency(CHOLMOD REQUIRED FIND_EXTERNAL "CHOLMOD")
message(
STATUS
"Build with CHOLDOD support (LGPL). See CHOLMOD/Doc/License.txt for further details."
)
add_definitions(-DEIGENPY_WITH_CHOLMOD_SUPPORT)
endif(BUILD_WITH_CHOLMOD_SUPPORT)
if(BUILD_WITH_ACCELERATE_SUPPORT)
if(NOT ${Eigen3_VERSION} VERSION_GREATER_EQUAL "3.4.90")
message(
FATAL_ERROR
"Your version of Eigen is too low. Should be at least 3.4.90. Current version is ${Eigen3_VERSION}."
)
endif()
set(CMAKE_MODULE_PATH ${JRL_CMAKE_MODULES}/find-external/Accelerate
${CMAKE_MODULE_PATH})
find_package(
Accelerate REQUIRED # FIND_EXTERNAL "Accelerate" # We don't export yet as
# there might be an issue on AMR64 platforms
)
message(STATUS "Build with Accelerate support framework.")
add_definitions(-DEIGENPY_WITH_ACCELERATE_SUPPORT)
endif(BUILD_WITH_ACCELERATE_SUPPORT)
# ----------------------------------------------------
# --- INCLUDE ----------------------------------------
# ----------------------------------------------------
set(${PROJECT_NAME}_UTILS_HEADERS
include/eigenpy/utils/scalar-name.hpp
include/eigenpy/utils/is-approx.hpp
include/eigenpy/utils/is-aligned.hpp
include/eigenpy/utils/traits.hpp
include/eigenpy/utils/python-compat.hpp
include/eigenpy/utils/empty-visitor.hpp)
set(${PROJECT_NAME}_SOLVERS_HEADERS
include/eigenpy/solvers/solvers.hpp
include/eigenpy/solvers/preconditioners.hpp
include/eigenpy/solvers/IterativeSolverBase.hpp
include/eigenpy/solvers/LeastSquaresConjugateGradient.hpp
include/eigenpy/solvers/ConjugateGradient.hpp
include/eigenpy/solvers/SparseSolverBase.hpp
include/eigenpy/solvers/BasicPreconditioners.hpp
include/eigenpy/solvers/BFGSPreconditioners.hpp)
set(${PROJECT_NAME}_EIGEN_HEADERS include/eigenpy/eigen/EigenBase.hpp)
set(${PROJECT_NAME}_DECOMPOSITIONS_SPARSE_CHOLMOD_HEADERS
include/eigenpy/decompositions/sparse/cholmod/CholmodBase.hpp
include/eigenpy/decompositions/sparse/cholmod/CholmodDecomposition.hpp
include/eigenpy/decompositions/sparse/cholmod/CholmodSimplicialLDLT.hpp
include/eigenpy/decompositions/sparse/cholmod/CholmodSimplicialLLT.hpp
include/eigenpy/decompositions/sparse/cholmod/CholmodSupernodalLLT.hpp)
set(${PROJECT_NAME}_DECOMPOSITIONS_SPARSE_ACCELERATE_HEADERS
include/eigenpy/decompositions/sparse/accelerate/accelerate.hpp)
set(${PROJECT_NAME}_DECOMPOSITIONS_SPARSE_HEADERS
include/eigenpy/decompositions/sparse/LLT.hpp
include/eigenpy/decompositions/sparse/LDLT.hpp
include/eigenpy/decompositions/sparse/SimplicialCholesky.hpp
include/eigenpy/decompositions/sparse/SparseSolverBase.hpp)
if(BUILD_WITH_CHOLMOD_SUPPORT)
list(APPEND ${PROJECT_NAME}_DECOMPOSITIONS_SPARSE_HEADERS
${${PROJECT_NAME}_DECOMPOSITIONS_SPARSE_CHOLMOD_HEADERS})
endif(BUILD_WITH_CHOLMOD_SUPPORT)
if(BUILD_WITH_ACCELERATE_SUPPORT)
list(APPEND ${PROJECT_NAME}_DECOMPOSITIONS_SPARSE_HEADERS
${${PROJECT_NAME}_DECOMPOSITIONS_SPARSE_ACCELERATE_HEADERS})
endif(BUILD_WITH_ACCELERATE_SUPPORT)
set(${PROJECT_NAME}_DECOMPOSITIONS_HEADERS
${${PROJECT_NAME}_DECOMPOSITIONS_SPARSE_HEADERS}
include/eigenpy/decompositions/decompositions.hpp
include/eigenpy/decompositions/EigenSolver.hpp
include/eigenpy/decompositions/PermutationMatrix.hpp
include/eigenpy/decompositions/LDLT.hpp
include/eigenpy/decompositions/LLT.hpp
include/eigenpy/decompositions/QR.hpp
include/eigenpy/decompositions/HouseholderQR.hpp
include/eigenpy/decompositions/ColPivHouseholderQR.hpp
include/eigenpy/decompositions/CompleteOrthogonalDecomposition.hpp
include/eigenpy/decompositions/FullPivHouseholderQR.hpp
include/eigenpy/decompositions/SelfAdjointEigenSolver.hpp
include/eigenpy/decompositions/minres.hpp)
set(${PROJECT_NAME}_HEADERS
${${PROJECT_NAME}_UTILS_HEADERS}
${${PROJECT_NAME}_SOLVERS_HEADERS}
${${PROJECT_NAME}_EIGEN_HEADERS}
${${PROJECT_NAME}_DECOMPOSITIONS_HEADERS}
include/eigenpy/alignment.hpp
include/eigenpy/computation-info.hpp
include/eigenpy/deprecation-policy.hpp
include/eigenpy/eigenpy.hpp
include/eigenpy/exception.hpp
include/eigenpy/scalar-conversion.hpp
include/eigenpy/expose.hpp
include/eigenpy/copyable.hpp
include/eigenpy/details.hpp
include/eigenpy/fwd.hpp
include/eigenpy/eigen-allocator.hpp
include/eigenpy/eigen-to-python.hpp
include/eigenpy/eigen-from-python.hpp
include/eigenpy/eigen-typedef.hpp
include/eigenpy/id.hpp
include/eigenpy/numpy-map.hpp
include/eigenpy/geometry.hpp
include/eigenpy/geometry-conversion.hpp
include/eigenpy/map.hpp
include/eigenpy/memory.hpp
include/eigenpy/numpy.hpp
include/eigenpy/numpy-allocator.hpp
include/eigenpy/numpy-type.hpp
include/eigenpy/registration.hpp
include/eigenpy/registration_class.hpp
include/eigenpy/angle-axis.hpp
include/eigenpy/quaternion.hpp
include/eigenpy/user-type.hpp
include/eigenpy/ufunc.hpp
include/eigenpy/register.hpp
include/eigenpy/std-array.hpp
include/eigenpy/std-map.hpp
include/eigenpy/std-pair.hpp
include/eigenpy/std-vector.hpp
include/eigenpy/optional.hpp
include/eigenpy/pickle-vector.hpp
include/eigenpy/stride.hpp
include/eigenpy/tensor/eigen-from-python.hpp
include/eigenpy/sparse/eigen-from-python.hpp
include/eigenpy/scipy-allocator.hpp
include/eigenpy/scipy-type.hpp
include/eigenpy/variant.hpp
include/eigenpy/std-unique-ptr.hpp
include/eigenpy/swig.hpp
include/eigenpy/type_info.hpp
include/eigenpy/version.hpp)
list(
APPEND
${PROJECT_NAME}_HEADERS
${${PROJECT_NAME}_BINARY_DIR}/include/${PROJECT_NAME}/config.hpp
${${PROJECT_NAME}_BINARY_DIR}/include/${PROJECT_NAME}/deprecated.hpp
${${PROJECT_NAME}_BINARY_DIR}/include/${PROJECT_NAME}/warning.hpp)
# ----------------------------------------------------
# --- TARGETS ----------------------------------------
# ----------------------------------------------------
set(${PROJECT_NAME}_SOLVERS_SOURCES src/solvers/preconditioners.cpp
src/solvers/solvers.cpp)
set(${PROJECT_NAME}_DECOMPOSITIONS_SOURCES
src/decompositions/decompositions.cpp
src/decompositions/eigen-solver.cpp
src/decompositions/llt-solver.cpp
src/decompositions/ldlt-solver.cpp
src/decompositions/minres-solver.cpp
src/decompositions/qr-solvers.cpp
src/decompositions/eigen-solver.cpp
src/decompositions/self-adjoint-eigen-solver.cpp
src/decompositions/permutation-matrix.cpp
src/decompositions/simplicial-llt-solver.cpp
src/decompositions/simplicial-ldlt-solver.cpp)
if(BUILD_WITH_CHOLMOD_SUPPORT)
list(APPEND ${PROJECT_NAME}_DECOMPOSITIONS_SOURCES
src/decompositions/cholmod.cpp)
endif(BUILD_WITH_CHOLMOD_SUPPORT)
if(BUILD_WITH_ACCELERATE_SUPPORT)
list(APPEND ${PROJECT_NAME}_DECOMPOSITIONS_SOURCES
src/decompositions/accelerate.cpp)
endif(BUILD_WITH_ACCELERATE_SUPPORT)
set(${PROJECT_NAME}_SOURCES
${${PROJECT_NAME}_SOLVERS_SOURCES}
${${PROJECT_NAME}_DECOMPOSITIONS_SOURCES}
src/exception.cpp
src/eigenpy.cpp
src/numpy.cpp
src/numpy-type.cpp
src/matrix-float.cpp
src/matrix-complex-float.cpp
src/matrix-complex-double.cpp
src/register.cpp
src/matrix-double.cpp
src/matrix-long-double.cpp
src/matrix-complex-long-double.cpp
src/matrix-bool.cpp
src/matrix-char.cpp
src/matrix-int8.cpp
src/matrix-uint8.cpp
src/matrix-int16.cpp
src/matrix-uint16.cpp
src/matrix-int32.cpp
src/matrix-uint32.cpp
src/matrix-windows-long.cpp
src/matrix-windows-ulong.cpp
src/matrix-mac-long.cpp
src/matrix-mac-ulong.cpp
src/matrix-int64.cpp
src/matrix-uint64.cpp
src/matrix-linux-long-long.cpp
src/matrix-linux-ulong-long.cpp
src/angle-axis.cpp
src/quaternion.cpp
src/geometry-conversion.cpp
src/scipy-type.cpp
src/std-vector.cpp
src/optional.cpp
src/type_info.cpp
src/version.cpp)
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS})
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
set_standard_output_directory(${PROJECT_NAME})
target_include_directories(
${PROJECT_NAME} SYSTEM
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
modernize_target_link_libraries(
${PROJECT_NAME}
SCOPE
PUBLIC
TARGETS
Eigen3::Eigen
INCLUDE_DIRS
${EIGEN3_INCLUDE_DIR})
modernize_target_link_libraries(
${PROJECT_NAME}
SCOPE
PUBLIC
TARGETS
Python${PYTHON_VERSION_MAJOR}::NumPy
INCLUDE_DIRS
${NUMPY_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIR})
# Links against CholMod
if(BUILD_WITH_CHOLMOD_SUPPORT)
modernize_target_link_libraries(${PROJECT_NAME} SCOPE PUBLIC TARGETS
CHOLMOD::CHOLMOD)
endif(BUILD_WITH_CHOLMOD_SUPPORT)
# Links against accelerate
if(BUILD_WITH_ACCELERATE_SUPPORT)
# modernize_target_link_libraries(${PROJECT_NAME} SCOPE PUBLIC TARGETS
# Accelerate)
target_link_libraries(${PROJECT_NAME} PRIVATE "-framework accelerate")
endif(BUILD_WITH_ACCELERATE_SUPPORT)
if(SUFFIX_SO_VERSION)
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
endif(SUFFIX_SO_VERSION)
if(NOT WIN32)
target_compile_options(
${PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj -MP>
"-Wno-conversion")
else()
target_compile_options(${PROJECT_NAME}
PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj -MP>)
target_compile_definitions(${PROJECT_NAME} PUBLIC "HAVE_SNPRINTF")
endif()
target_link_boost_python(${PROJECT_NAME} PUBLIC)
install(
TARGETS ${PROJECT_NAME}
EXPORT ${TARGETS_EXPORT_NAME}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
INCLUDES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
add_header_group(${PROJECT_NAME}_HEADERS)
add_source_group(${PROJECT_NAME}_SOURCES)
# Install package for ROS
install(FILES package.xml DESTINATION share/eigenpy)
# Allows Colcon to find non-Ament packages when using workspace underlays
file(
WRITE
${CMAKE_CURRENT_BINARY_DIR}/share/ament_index/resource_index/packages/${PROJECT_NAME}
"")
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/share/ament_index/resource_index/packages/${PROJECT_NAME}
DESTINATION share/ament_index/resource_index/packages)
file(
WRITE
${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/ament_prefix_path.dsv
"prepend-non-duplicate;AMENT_PREFIX_PATH;")
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/ament_prefix_path.dsv
DESTINATION share/${PROJECT_NAME}/hook)
file(WRITE
${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/python_path.dsv
"prepend-non-duplicate;PYTHONPATH;${PYTHON_SITELIB}")
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/python_path.dsv
DESTINATION share/${PROJECT_NAME}/hook)
# ----------------------------------------------------
# --- PYTHON LIBRARY ---------------------------------
# ----------------------------------------------------
add_subdirectory(python)
# ----------------------------------------------------
# --- UNIT TEST --------------------------------------
# ----------------------------------------------------
add_subdirectory(unittest)
pkg_config_append_libs(${PROJECT_NAME})
pkg_config_append_cflags("-I${PYTHON_INCLUDE_DIRS}")
pkg_config_append_cflags("-I${NUMPY_INCLUDE_DIRS}")
pkg_config_append_boost_libs(${BOOST_COMPONENTS})
setup_project_finalize()