CMakeLists.txt 5.85 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")
Justin Carpentier's avatar
Justin Carpentier committed
11
SET(PROJECT_USE_CMAKE_EXPORT TRUE)
12
SET(PROJECT_CUSTOM_HEADER_EXTENSION "hpp")
13

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

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

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

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

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

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

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

43
44
45
# ----------------------------------------------------
# --- OPTIONS  ---------------------------------------
# ----------------------------------------------------
46
47
48
49
OPTION(INSTALL_DOCUMENTATION "Generate and install the documentation" FALSE)
OPTION(BUILD_UNIT_TESTS "Build the unitary tests" OFF)

IF(BUILD_UNIT_TESTS)
50
  SET(BUILD_TESTING ON)
51
ELSE(BUILD_UNIT_TESTS)
52
  SET(BUILD_TESTING OFF) 
53
ENDIF(BUILD_UNIT_TESTS)
54

55
56
57
FINDPYTHON()
FIND_NUMPY()

Nicolas Mansard's avatar
Nicolas Mansard committed
58
# ----------------------------------------------------
59
# --- DEPENDENCIES -----------------------------------
Nicolas Mansard's avatar
Nicolas Mansard committed
60
# ----------------------------------------------------
61
ADD_REQUIRED_DEPENDENCY("eigen3 >= 3.0.5")
jcarpent's avatar
jcarpent committed
62

63
SET(BOOST_COMPONENTS python)
Nicolas Mansard's avatar
Nicolas Mansard committed
64
SEARCH_FOR_BOOST()
jcarpent's avatar
jcarpent committed
65

Nicolas Mansard's avatar
Nicolas Mansard committed
66
67
68
# ----------------------------------------------------
# --- INCLUDE ----------------------------------------
# ----------------------------------------------------
jcarpent's avatar
jcarpent committed
69
SET(${PROJECT_NAME}_SOLVERS_HEADERS
jcarpent's avatar
jcarpent committed
70
71
72
73
74
75
76
77
  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
78
79
  )

80
SET(${PROJECT_NAME}_HEADERS
jcarpent's avatar
jcarpent committed
81
  ${${PROJECT_NAME}_SOLVERS_HEADERS}
jcarpent's avatar
jcarpent committed
82
83
  include/eigenpy/eigenpy.hpp
  include/eigenpy/exception.hpp
84
  include/eigenpy/expose.hpp
jcarpent's avatar
jcarpent committed
85
86
87
88
89
90
91
92
93
94
95
  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
96
  include/eigenpy/details/rvalue_from_python_data.hpp
97
  include/eigenpy/version.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
98
)
jcarpent's avatar
jcarpent committed
99

100
101
102
103
104
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)

105
INCLUDE_DIRECTORIES(${${PROJECT_NAME}_BINARY_DIR}/include)
jcarpent's avatar
jcarpent committed
106
INCLUDE_DIRECTORIES(${${PROJECT_NAME}_SOURCE_DIR}/include)
Nicolas Mansard's avatar
Nicolas Mansard committed
107
108
109
110

# ----------------------------------------------------
# --- TARGETS ----------------------------------------
# ----------------------------------------------------
jcarpent's avatar
jcarpent committed
111
SET(${PROJECT_NAME}_SOLVERS_SOURCES
jcarpent's avatar
jcarpent committed
112
  src/solvers/preconditioners.cpp
jcarpent's avatar
jcarpent committed
113
114
  src/solvers/solvers.cpp
  )
115

116
SET(${PROJECT_NAME}_SOURCES
jcarpent's avatar
jcarpent committed
117
  ${${PROJECT_NAME}_SOLVERS_SOURCES}
Nicolas Mansard's avatar
Nicolas Mansard committed
118
  src/exception.cpp
119
  src/eigenpy.cpp
Nicolas Mansard's avatar
Nicolas Mansard committed
120
121
  src/angle-axis.cpp
  src/quaternion.cpp
122
  src/geometry-conversion.cpp
123
  src/version.cpp
124
)
Nicolas Mansard's avatar
Nicolas Mansard committed
125

126
ADD_LIBRARY(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS})
Justin Carpentier's avatar
Justin Carpentier committed
127
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} SYSTEM PUBLIC ${Boost_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIRS})
128
129
130
131
132
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()
133

Justin Carpentier's avatar
Justin Carpentier committed
134
TARGET_LINK_BOOST_PYTHON(${PROJECT_NAME} PUBLIC)
135
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} eigen3)
seanyen's avatar
seanyen committed
136
INSTALL(TARGETS ${PROJECT_NAME}
137
  EXPORT ${TARGETS_EXPORT_NAME}
138
  PUBLIC_HEADER
Wolfgang Merkt's avatar
Wolfgang Merkt committed
139
140
141
142
  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
143

jcarpent's avatar
jcarpent committed
144
145
146
ADD_HEADER_GROUP(${PROJECT_NAME}_HEADERS)
ADD_SOURCE_GROUP(${PROJECT_NAME}_SOURCES)

seanyen's avatar
seanyen committed
147
148
INCLUDE(GenerateExportHeader)
GENERATE_EXPORT_HEADER(${PROJECT_NAME} EXPORT_FILE_NAME eigenpy/${PROJECT_NAME}_export.h)
seanyen's avatar
seanyen committed
149
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
150
SET(PUBLIC_HEADER ${${PROJECT_NAME}_HEADERS})
seanyen's avatar
seanyen committed
151
152
153
154

INSTALL(FILES
  ${CMAKE_CURRENT_BINARY_DIR}/eigenpy/${PROJECT_NAME}_export.h
  DESTINATION include/eigenpy)
155
156
157
158

# 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)
Justin Carpentier's avatar
Justin Carpentier committed
159
160

# Install package for ROS
161
162
install(FILES package.xml DESTINATION share/eigenpy)

Nicolas Mansard's avatar
Nicolas Mansard committed
163
# ----------------------------------------------------
164
# --- PYTHON LIBRARY ---------------------------------
jcarpent's avatar
jcarpent committed
165
# ----------------------------------------------------
166
ADD_SUBDIRECTORY(python)
Nicolas Mansard's avatar
Nicolas Mansard committed
167

168
# ----------------------------------------------------
169
# --- UNIT TEST --------------------------------------
170
# ----------------------------------------------------
171
ADD_SUBDIRECTORY(unittest)
172

173
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
174
175
PKG_CONFIG_APPEND_CFLAGS("-I${PYTHON_INCLUDE_DIRS}")
PKG_CONFIG_APPEND_CFLAGS("-I${NUMPY_INCLUDE_DIRS}")
176
PKG_CONFIG_APPEND_BOOST_LIBS(${BOOST_COMPONENTS})