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

Nicolas Mansard's avatar
Nicolas Mansard committed
6
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
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")
11
SET(PROJECT_CUSTOM_HEADER_EXTENSION "hpp")
12

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

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

Nicolas Mansard's avatar
Nicolas Mansard committed
22
INCLUDE(cmake/base.cmake)
23
24
IF(CMAKE_VERSION VERSION_GREATER "3.0.0")
  CMAKE_POLICY(SET CMP0048 NEW)
25
26
27
28
29
  IF(CMAKE_VERSION VERSION_GREATER "3.9.0")
    PROJECT(${PROJECT_NAME} VERSION ${PROJECT_VERSION_FULL} LANGUAGES CXX DESCRIPTION ${PROJECT_DESCRIPTION})
  ELSE(CMAKE_VERSION VERSION_GREATER "3.9.0")
    PROJECT(${PROJECT_NAME} VERSION ${PROJECT_VERSION_FULL} LANGUAGES CXX)
  ENDIF(CMAKE_VERSION VERSION_GREATER "3.9.0")
30
31
32
ELSE(CMAKE_VERSION VERSION_GREATER "3.0.0")
  PROJECT(${PROJECT_NAME} CXX)
ENDIF(CMAKE_VERSION VERSION_GREATER "3.0.0")
33

Nicolas Mansard's avatar
Nicolas Mansard committed
34
35
INCLUDE(cmake/boost.cmake)
INCLUDE(cmake/python.cmake)
jcarpent's avatar
jcarpent committed
36
INCLUDE(cmake/ide.cmake)
37
INCLUDE(cmake/apple.cmake)
Nicolas Mansard's avatar
IVIGIT.    
Nicolas Mansard committed
38

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

41
42
# If needed, fix CMake policy for APPLE systems
APPLY_DEFAULT_APPLE_CONFIGURATION()
43

44
45
46
47
48
49
IF(WIN32)
  SET(LINK copy_if_different)
ELSE(WIN32)
  SET(LINK create_symlink)
ENDIF(WIN32)

50
51
52
# ----------------------------------------------------
# --- OPTIONS  ---------------------------------------
# ----------------------------------------------------
53
54
55
56
OPTION(INSTALL_DOCUMENTATION "Generate and install the documentation" FALSE)
OPTION(BUILD_UNIT_TESTS "Build the unitary tests" OFF)

IF(BUILD_UNIT_TESTS)
57
  SET(BUILD_TESTING ON)
58
ELSE(BUILD_UNIT_TESTS)
59
  SET(BUILD_TESTING OFF) 
60
ENDIF(BUILD_UNIT_TESTS)
61

62
63
64
65
66
67
FINDPYTHON()

INCLUDE_DIRECTORIES(SYSTEM ${PYTHON_INCLUDE_DIRS})
FIND_NUMPY()
INCLUDE_DIRECTORIES(SYSTEM ${NUMPY_INCLUDE_DIRS})

Nicolas Mansard's avatar
Nicolas Mansard committed
68
# ----------------------------------------------------
69
# --- DEPENDENCIES -----------------------------------
Nicolas Mansard's avatar
Nicolas Mansard committed
70
# ----------------------------------------------------
71
ADD_REQUIRED_DEPENDENCY("eigen3 >= 3.0.5")
jcarpent's avatar
jcarpent committed
72

73
SET(BOOST_COMPONENTS python)
Nicolas Mansard's avatar
Nicolas Mansard committed
74
SEARCH_FOR_BOOST()
jcarpent's avatar
jcarpent committed
75
# Add Boost path to include directories.
76
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIRS})
jcarpent's avatar
jcarpent committed
77

Nicolas Mansard's avatar
Nicolas Mansard committed
78
79
80
# ----------------------------------------------------
# --- INCLUDE ----------------------------------------
# ----------------------------------------------------
jcarpent's avatar
jcarpent committed
81
SET(${PROJECT_NAME}_SOLVERS_HEADERS
jcarpent's avatar
jcarpent committed
82
83
84
85
86
87
88
89
  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
90
91
  )

92
SET(${PROJECT_NAME}_HEADERS
jcarpent's avatar
jcarpent committed
93
  ${${PROJECT_NAME}_SOLVERS_HEADERS}
jcarpent's avatar
jcarpent committed
94
95
  include/eigenpy/eigenpy.hpp
  include/eigenpy/exception.hpp
96
  include/eigenpy/expose.hpp
jcarpent's avatar
jcarpent committed
97
98
99
100
101
102
103
104
105
106
107
  include/eigenpy/details.hpp
  include/eigenpy/fwd.hpp
  include/eigenpy/map.hpp
  include/eigenpy/geometry.hpp
  include/eigenpy/geometry-conversion.hpp
  include/eigenpy/memory.hpp
  include/eigenpy/registration.hpp
  include/eigenpy/angle-axis.hpp
  include/eigenpy/quaternion.hpp
  include/eigenpy/stride.hpp
  include/eigenpy/ref.hpp
108
  include/eigenpy/details/rvalue_from_python_data.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
109
)
jcarpent's avatar
jcarpent committed
110

111
112
113
114
115
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)

116
INCLUDE_DIRECTORIES(${${PROJECT_NAME}_BINARY_DIR}/include)
jcarpent's avatar
jcarpent committed
117
INCLUDE_DIRECTORIES(${${PROJECT_NAME}_SOURCE_DIR}/include)
Nicolas Mansard's avatar
Nicolas Mansard committed
118

seanyen's avatar
seanyen committed
119
120
LINK_DIRECTORIES(${PYTHON_LIBRARY_DIRS})

Nicolas Mansard's avatar
Nicolas Mansard committed
121
122
123
# ----------------------------------------------------
# --- TARGETS ----------------------------------------
# ----------------------------------------------------
jcarpent's avatar
jcarpent committed
124
SET(${PROJECT_NAME}_SOLVERS_SOURCES
jcarpent's avatar
jcarpent committed
125
  src/solvers/preconditioners.cpp
jcarpent's avatar
jcarpent committed
126
127
  src/solvers/solvers.cpp
  )
128

129
SET(${PROJECT_NAME}_SOURCES
jcarpent's avatar
jcarpent committed
130
  ${${PROJECT_NAME}_SOLVERS_SOURCES}
Nicolas Mansard's avatar
Nicolas Mansard committed
131
  src/exception.cpp
132
  src/eigenpy.cpp
Nicolas Mansard's avatar
Nicolas Mansard committed
133
134
  src/angle-axis.cpp
  src/quaternion.cpp
135
  src/geometry-conversion.cpp
136
)
Nicolas Mansard's avatar
Nicolas Mansard committed
137

138
ADD_LIBRARY(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS})
139
140
141
142
143
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()
144

145
TARGET_LINK_BOOST_PYTHON(${PROJECT_NAME})
146
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} eigen3)
seanyen's avatar
seanyen committed
147
INSTALL(TARGETS ${PROJECT_NAME}
148
  EXPORT ${TARGETS_EXPORT_NAME}
149
  PUBLIC_HEADER
Wolfgang Merkt's avatar
Wolfgang Merkt committed
150
151
152
153
  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
154

jcarpent's avatar
jcarpent committed
155
156
157
ADD_HEADER_GROUP(${PROJECT_NAME}_HEADERS)
ADD_SOURCE_GROUP(${PROJECT_NAME}_SOURCES)

seanyen's avatar
seanyen committed
158
159
INCLUDE(GenerateExportHeader)
GENERATE_EXPORT_HEADER(${PROJECT_NAME} EXPORT_FILE_NAME eigenpy/${PROJECT_NAME}_export.h)
seanyen's avatar
seanyen committed
160
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
161
SET(PUBLIC_HEADER ${${PROJECT_NAME}_HEADERS})
seanyen's avatar
seanyen committed
162
163
164
165

INSTALL(FILES
  ${CMAKE_CURRENT_BINARY_DIR}/eigenpy/${PROJECT_NAME}_export.h
  DESTINATION include/eigenpy)
166
167
168
169
170
171

# This is a temporary work-around to fix MoveIt until jrl-cmakemodules
# can correctly create non-target CMake configs
install(FILES eigenpyConfig.cmake DESTINATION share/eigenpy/cmake)
install(FILES package.xml DESTINATION share/eigenpy)

Nicolas Mansard's avatar
Nicolas Mansard committed
172
# ----------------------------------------------------
173
# --- PYTHON LIBRARY ---------------------------------
jcarpent's avatar
jcarpent committed
174
# ----------------------------------------------------
175
ADD_SUBDIRECTORY(python)
Nicolas Mansard's avatar
Nicolas Mansard committed
176

177
# ----------------------------------------------------
178
# --- UNIT TEST --------------------------------------
179
# ----------------------------------------------------
180
ADD_SUBDIRECTORY(unittest)
181

182
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
183
184
PKG_CONFIG_APPEND_CFLAGS("-I${PYTHON_INCLUDE_DIRS}")
PKG_CONFIG_APPEND_CFLAGS("-I${NUMPY_INCLUDE_DIRS}")
185
PKG_CONFIG_APPEND_BOOST_LIBS(${BOOST_COMPONENTS})