CMakeLists.txt 7.3 KB
Newer Older
Nicolas Mansard's avatar
Nicolas Mansard committed
1
#
2
# Copyright (c) 2014-2019 CNRS
3
# Copyright (c) 2018-2020 INRIA
Nicolas Mansard's avatar
Nicolas Mansard committed
4
#
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
5

6
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
Nicolas Mansard's avatar
IVIGIT.    
Nicolas Mansard committed
7

8
9
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")
Justin Carpentier's avatar
Justin Carpentier committed
11
SET(PROJECT_USE_CMAKE_EXPORT TRUE)
12
SET(PROJECT_USE_KEYWORD_LINK_LIBRARIES TRUE)
13
SET(PROJECT_CUSTOM_HEADER_EXTENSION "hpp")
14

15
# Check if the submodule cmake have been initialized
16
IF(NOT EXISTS "${CMAKE_SOURCE_DIR}/cmake/base.cmake")
17
18
19
  MESSAGE(FATAL_ERROR "\nPlease run the following command first:\ngit submodule update --init\n")
ENDIF()

20
21
22
23
# Disable -Werror on Unix for now.
SET(CXX_DISABLE_WERROR True)
SET(CMAKE_VERBOSE_MAKEFILE True)

Nicolas Mansard's avatar
Nicolas Mansard committed
24
INCLUDE(cmake/base.cmake)
Justin Carpentier's avatar
Justin Carpentier committed
25
26
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX)
PROJECT(${PROJECT_NAME} ${PROJECT_ARGS})
27

Nicolas Mansard's avatar
Nicolas Mansard committed
28
29
INCLUDE(cmake/boost.cmake)
INCLUDE(cmake/python.cmake)
jcarpent's avatar
jcarpent committed
30
INCLUDE(cmake/ide.cmake)
31
INCLUDE(cmake/apple.cmake)
Nicolas Mansard's avatar
IVIGIT.    
Nicolas Mansard committed
32

33
STRING(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
Nicolas Mansard's avatar
Nicolas Mansard committed
34

35
36
# If needed, fix CMake policy for APPLE systems
APPLY_DEFAULT_APPLE_CONFIGURATION()
37

38
39
40
41
42
43
IF(WIN32)
  SET(LINK copy_if_different)
ELSE(WIN32)
  SET(LINK create_symlink)
ENDIF(WIN32)

44
45
46
# ----------------------------------------------------
# --- OPTIONS  ---------------------------------------
# ----------------------------------------------------
47
OPTION(INSTALL_DOCUMENTATION "Generate and install the documentation" FALSE)
Guilhem Saurel's avatar
Guilhem Saurel committed
48
OPTION(SUFFIX_SO_VERSION "Suffix library name with its version" OFF)
49

50
51
52
53
54
55
IF(DEFINED BUILD_UNIT_TESTS)
  MESSAGE(AUTHOR_WARNING "BUILD_UNIT_TESTS is deprecated. Use BUILD_TESTING instead.\
    If you are manually building Pinocchio from source in an existing build folder,\
    we suggest that you delete your build folder and make a new one.")
  SET(BUILD_TESTING ${BUILD_UNIT_TESTS})
ENDIF(DEFINED BUILD_UNIT_TESTS)
56

57
58
59
FINDPYTHON()
FIND_NUMPY()

Justin Carpentier's avatar
Justin Carpentier committed
60
61
62
63
IF(WIN32)
  LINK_DIRECTORIES(${PYTHON_LIBRARY_DIRS})
ENDIF(WIN32)

Nicolas Mansard's avatar
Nicolas Mansard committed
64
# ----------------------------------------------------
65
# --- DEPENDENCIES -----------------------------------
Nicolas Mansard's avatar
Nicolas Mansard committed
66
# ----------------------------------------------------
67
ADD_PROJECT_DEPENDENCY(Eigen3 REQUIRED PKG_CONFIG_REQUIRES "eigen3 >= 3.0.5")
jcarpent's avatar
jcarpent committed
68

69
70
71
SET_BOOST_DEFAULT_OPTIONS()
EXPORT_BOOST_DEFAULT_OPTIONS()
FIND_PACKAGE(Boost REQUIRED)
72
SEARCH_FOR_BOOST_PYTHON()
jcarpent's avatar
jcarpent committed
73

Nicolas Mansard's avatar
Nicolas Mansard committed
74
75
76
# ----------------------------------------------------
# --- INCLUDE ----------------------------------------
# ----------------------------------------------------
77
78
SET(${PROJECT_NAME}_UTILS_HEADERS
  include/eigenpy/utils/scalar-name.hpp
79
  include/eigenpy/utils/is-approx.hpp
80
  include/eigenpy/utils/is-aligned.hpp
81
82
  )

jcarpent's avatar
jcarpent committed
83
SET(${PROJECT_NAME}_SOLVERS_HEADERS
jcarpent's avatar
jcarpent committed
84
85
86
87
88
89
90
91
  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
jcarpent's avatar
jcarpent committed
92
93
  )

94
95
SET(${PROJECT_NAME}_DECOMPOSITIONS_HEADERS
  include/eigenpy/decompositions/decompositions.hpp
96
  include/eigenpy/decompositions/EigenSolver.hpp
97
  include/eigenpy/decompositions/LDLT.hpp
Justin Carpentier's avatar
Justin Carpentier committed
98
  include/eigenpy/decompositions/LLT.hpp
99
  include/eigenpy/decompositions/SelfAdjointEigenSolver.hpp
100
101
  )

102
SET(${PROJECT_NAME}_HEADERS
103
  ${${PROJECT_NAME}_UTILS_HEADERS}
jcarpent's avatar
jcarpent committed
104
  ${${PROJECT_NAME}_SOLVERS_HEADERS}
105
  ${${PROJECT_NAME}_DECOMPOSITIONS_HEADERS}
106
  include/eigenpy/computation-info.hpp
jcarpent's avatar
jcarpent committed
107
108
  include/eigenpy/eigenpy.hpp
  include/eigenpy/exception.hpp
109
  include/eigenpy/scalar-conversion.hpp
110
  include/eigenpy/expose.hpp
jcarpent's avatar
jcarpent committed
111
112
  include/eigenpy/details.hpp
  include/eigenpy/fwd.hpp
113
  include/eigenpy/eigen-allocator.hpp
114
  include/eigenpy/eigen-to-python.hpp
115
  include/eigenpy/eigen-from-python.hpp
116
  include/eigenpy/eigen-typedef.hpp
Justin Carpentier's avatar
Justin Carpentier committed
117
  include/eigenpy/numpy-map.hpp
jcarpent's avatar
jcarpent committed
118
119
120
  include/eigenpy/geometry.hpp
  include/eigenpy/geometry-conversion.hpp
  include/eigenpy/memory.hpp
121
  include/eigenpy/numpy.hpp
Justin Carpentier's avatar
Justin Carpentier committed
122
123
  include/eigenpy/numpy-allocator.hpp
  include/eigenpy/numpy-type.hpp
jcarpent's avatar
jcarpent committed
124
125
126
  include/eigenpy/registration.hpp
  include/eigenpy/angle-axis.hpp
  include/eigenpy/quaternion.hpp
127
  include/eigenpy/user-type.hpp
128
  include/eigenpy/ufunc.hpp
Justin Carpentier's avatar
Justin Carpentier committed
129
  include/eigenpy/register.hpp
jcarpent's avatar
jcarpent committed
130
  include/eigenpy/stride.hpp
131
  include/eigenpy/version.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
132
)
jcarpent's avatar
jcarpent committed
133

134
135
136
137
138
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)

Nicolas Mansard's avatar
Nicolas Mansard committed
139
140
141
# ----------------------------------------------------
# --- TARGETS ----------------------------------------
# ----------------------------------------------------
jcarpent's avatar
jcarpent committed
142
SET(${PROJECT_NAME}_SOLVERS_SOURCES
jcarpent's avatar
jcarpent committed
143
  src/solvers/preconditioners.cpp
jcarpent's avatar
jcarpent committed
144
145
  src/solvers/solvers.cpp
  )
146

147
148
149
150
SET(${PROJECT_NAME}_DECOMPOSITIONS_SOURCES
  src/decompositions/decompositions.cpp
  )
  
151
SET(${PROJECT_NAME}_SOURCES
jcarpent's avatar
jcarpent committed
152
  ${${PROJECT_NAME}_SOLVERS_SOURCES}
153
  ${${PROJECT_NAME}_DECOMPOSITIONS_SOURCES}
Nicolas Mansard's avatar
Nicolas Mansard committed
154
  src/exception.cpp
155
  src/eigenpy.cpp
156
  src/numpy.cpp
157
  src/numpy-type.cpp
158
159
160
  src/matrix-float.cpp
  src/matrix-complex-float.cpp
  src/matrix-complex-double.cpp
Justin Carpentier's avatar
Justin Carpentier committed
161
  src/register.cpp
162
163
164
165
166
  src/matrix-double.cpp
  src/matrix-long-double.cpp
  src/matrix-complex-long-double.cpp
  src/matrix-int.cpp
  src/matrix-long.cpp
Nicolas Mansard's avatar
Nicolas Mansard committed
167
168
  src/angle-axis.cpp
  src/quaternion.cpp
169
  src/geometry-conversion.cpp
170
  src/version.cpp
171
)
Nicolas Mansard's avatar
Nicolas Mansard committed
172

173
ADD_LIBRARY(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS})
174
175
176
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} 
  SYSTEM PUBLIC 
  ${Boost_INCLUDE_DIRS} 
Guilhem Saurel's avatar
Guilhem Saurel committed
177
  ${EIGEN3_INCLUDE_DIR}
178
179
  ${PYTHON_INCLUDE_DIRS} 
  ${NUMPY_INCLUDE_DIRS}
180
181
  $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
  $<INSTALL_INTERFACE:include>)
182

Guilhem Saurel's avatar
Guilhem Saurel committed
183
184
185
186
IF(SUFFIX_SO_VERSION)
  SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
ENDIF(SUFFIX_SO_VERSION)

187
188
189
190
191
IF(NOT WIN32)
  TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj> "-Wno-conversion")
ELSE()
  TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj>)
ENDIF()
192

193
194
195
196
197
198
IF(Boost_VERSION GREATER 107299)
  # Silence a warning about a deprecated use of boost bind by boost python
  # at least fo boost 1.73 to 1.75
  ADD_DEFINITIONS(-DBOOST_BIND_GLOBAL_PLACEHOLDERS)
ENDIF()

Justin Carpentier's avatar
Justin Carpentier committed
199
TARGET_LINK_BOOST_PYTHON(${PROJECT_NAME} PUBLIC)
seanyen's avatar
seanyen committed
200
INSTALL(TARGETS ${PROJECT_NAME}
201
  EXPORT ${TARGETS_EXPORT_NAME}
202
  PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}
Wolfgang Merkt's avatar
Wolfgang Merkt committed
203
204
205
206
  INCLUDES DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}
  LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
  ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
  RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
Nicolas Mansard's avatar
Nicolas Mansard committed
207

jcarpent's avatar
jcarpent committed
208
209
210
ADD_HEADER_GROUP(${PROJECT_NAME}_HEADERS)
ADD_SOURCE_GROUP(${PROJECT_NAME}_SOURCES)

Justin Carpentier's avatar
Justin Carpentier committed
211
# Install package for ROS
212
213
install(FILES package.xml DESTINATION share/eigenpy)

Nicolas Mansard's avatar
Nicolas Mansard committed
214
# ----------------------------------------------------
215
# --- PYTHON LIBRARY ---------------------------------
jcarpent's avatar
jcarpent committed
216
# ----------------------------------------------------
217
ADD_SUBDIRECTORY(python)
Nicolas Mansard's avatar
Nicolas Mansard committed
218

219
# ----------------------------------------------------
220
# --- UNIT TEST --------------------------------------
221
# ----------------------------------------------------
222
ADD_SUBDIRECTORY(unittest)
223

224
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
225
226
PKG_CONFIG_APPEND_CFLAGS("-I${PYTHON_INCLUDE_DIRS}")
PKG_CONFIG_APPEND_CFLAGS("-I${NUMPY_INCLUDE_DIRS}")
227
PKG_CONFIG_APPEND_BOOST_LIBS(${BOOST_COMPONENTS})