CMakeLists.txt 5.29 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
11
12
# Check if the submodule cmake have been initialized
IF(NOT EXISTS "${PROJECT_SOURCE_DIR}/cmake/base.cmake")
  MESSAGE(FATAL_ERROR "\nPlease run the following command first:\ngit submodule update --init\n")
ENDIF()

Nicolas Mansard's avatar
Nicolas Mansard committed
13
14
15
INCLUDE(cmake/base.cmake)
INCLUDE(cmake/boost.cmake)
INCLUDE(cmake/python.cmake)
jcarpent's avatar
jcarpent committed
16
INCLUDE(cmake/ide.cmake)
Nicolas Mansard's avatar
IVIGIT.    
Nicolas Mansard committed
17

Nicolas Mansard's avatar
Nicolas Mansard committed
18
SET(PROJECT_NAME eigenpy)
19
SET(PROJECT_DESCRIPTION "Bindings between Numpy and Eigen using Boost.Python")
20
SET(PROJECT_URL "http://github.com/stack-of-tasks/eigenpy")
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
21

Nicolas Mansard's avatar
Nicolas Mansard committed
22
23
24
# Disable -Werror on Unix for now.
SET(CXX_DISABLE_WERROR True)
SET(CMAKE_VERBOSE_MAKEFILE True)
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
25

Nicolas Mansard's avatar
Nicolas Mansard committed
26
SETUP_PROJECT()
27
STRING(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
Nicolas Mansard's avatar
Nicolas Mansard committed
28

29
30
IF(APPLE)
  SET(CMAKE_MACOSX_RPATH TRUE)
jcarpent's avatar
jcarpent committed
31
32
33
34
35
36
37
38
39
  SET(CMAKE_SKIP_BUILD_RPATH FALSE)
  SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

  #SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
  LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
  IF("${isSystemDir}" STREQUAL "-1")
     SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
  ENDIF("${isSystemDir}" STREQUAL "-1")
40
41
ENDIF(APPLE)

42
43
44
45
46
47
IF(WIN32)
  SET(LINK copy_if_different)
ELSE(WIN32)
  SET(LINK create_symlink)
ENDIF(WIN32)

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

IF(BUILD_UNIT_TESTS)
55
  SET(BUILD_TESTING ON)
56
ELSE(BUILD_UNIT_TESTS)
57
  SET(BUILD_TESTING OFF) 
58
ENDIF(BUILD_UNIT_TESTS)
59

60
61
62
63
64
65
FINDPYTHON()

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

Nicolas Mansard's avatar
Nicolas Mansard committed
66
67
68
# ----------------------------------------------------
# --- DEPENDANCIES -----------------------------------
# ----------------------------------------------------
69
ADD_REQUIRED_DEPENDENCY("eigen3 >= 3.0.5")
jcarpent's avatar
jcarpent committed
70

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

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

90
SET(${PROJECT_NAME}_HEADERS
jcarpent's avatar
jcarpent committed
91
  ${${PROJECT_NAME}_SOLVERS_HEADERS}
jcarpent's avatar
jcarpent committed
92
93
  include/eigenpy/eigenpy.hpp
  include/eigenpy/exception.hpp
94
  include/eigenpy/expose.hpp
jcarpent's avatar
jcarpent committed
95
96
97
98
99
100
101
102
103
104
105
  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
Nicolas Mansard's avatar
Nicolas Mansard committed
106
)
jcarpent's avatar
jcarpent committed
107

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

seanyen's avatar
seanyen committed
111
112
LINK_DIRECTORIES(${PYTHON_LIBRARY_DIRS})

Nicolas Mansard's avatar
Nicolas Mansard committed
113
114
115
# ----------------------------------------------------
# --- TARGETS ----------------------------------------
# ----------------------------------------------------
jcarpent's avatar
jcarpent committed
116
SET(${PROJECT_NAME}_SOLVERS_SOURCES
jcarpent's avatar
jcarpent committed
117
  src/solvers/preconditioners.cpp
jcarpent's avatar
jcarpent committed
118
119
  src/solvers/solvers.cpp
  )
120

121
SET(${PROJECT_NAME}_SOURCES
jcarpent's avatar
jcarpent committed
122
  ${${PROJECT_NAME}_SOLVERS_SOURCES}
Nicolas Mansard's avatar
Nicolas Mansard committed
123
  src/exception.cpp
124
  src/eigenpy.cpp
Nicolas Mansard's avatar
Nicolas Mansard committed
125
126
  src/angle-axis.cpp
  src/quaternion.cpp
127
  src/geometry-conversion.cpp
128
)
Nicolas Mansard's avatar
Nicolas Mansard committed
129

130
ADD_LIBRARY(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS})
131
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}${PYTHON_SOABI}")
132

133
TARGET_LINK_BOOST_PYTHON(${PROJECT_NAME})
134
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} eigen3)
seanyen's avatar
seanyen committed
135
136
137
138
INSTALL(TARGETS ${PROJECT_NAME}
  LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
  ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
  RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
Nicolas Mansard's avatar
Nicolas Mansard committed
139

jcarpent's avatar
jcarpent committed
140
141
142
ADD_HEADER_GROUP(${PROJECT_NAME}_HEADERS)
ADD_SOURCE_GROUP(${PROJECT_NAME}_SOURCES)

seanyen's avatar
seanyen committed
143
144
INCLUDE(GenerateExportHeader)
GENERATE_EXPORT_HEADER(${PROJECT_NAME} EXPORT_FILE_NAME eigenpy/${PROJECT_NAME}_export.h)
seanyen's avatar
seanyen committed
145
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
seanyen's avatar
seanyen committed
146
147
148
149

INSTALL(FILES
  ${CMAKE_CURRENT_BINARY_DIR}/eigenpy/${PROJECT_NAME}_export.h
  DESTINATION include/eigenpy)
Nicolas Mansard's avatar
Nicolas Mansard committed
150
# ----------------------------------------------------
151
# --- PYTHON LIBRARY ---------------------------------
jcarpent's avatar
jcarpent committed
152
# ----------------------------------------------------
153
ADD_SUBDIRECTORY(python)
Nicolas Mansard's avatar
Nicolas Mansard committed
154

155
# ----------------------------------------------------
156
# --- UNIT TEST --------------------------------------
157
# ----------------------------------------------------
158
ADD_SUBDIRECTORY(unittest)
159

160
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
161
162
PKG_CONFIG_APPEND_CFLAGS("-I${PYTHON_INCLUDE_DIRS}")
PKG_CONFIG_APPEND_CFLAGS("-I${NUMPY_INCLUDE_DIRS}")
163
PKG_CONFIG_APPEND_BOOST_LIBS(${BOOST_COMPONENTS})
Nicolas Mansard's avatar
Nicolas Mansard committed
164
165

SETUP_PROJECT_FINALIZE()