CMakeLists.txt 5.27 KB
Newer Older
Nicolas Mansard's avatar
Nicolas Mansard committed
1
#
2
# Copyright (c) 2015-2017 LAAS-CNRS
jcarpent's avatar
jcarpent committed
3
4
5
6
7
8
9
10
11
12
13
14
#
# This file is part of eigenpy.
# eigenpy is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
# eigenpy is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.  You should
# have received a copy of the GNU Lesser General Public License along
# with eigenpy.  If not, see <http://www.gnu.org/licenses/>.
Nicolas Mansard's avatar
Nicolas Mansard committed
15
#
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
16

Nicolas Mansard's avatar
Nicolas Mansard committed
17
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
Nicolas Mansard's avatar
IVIGIT.    
Nicolas Mansard committed
18

Nicolas Mansard's avatar
Nicolas Mansard committed
19
20
21
INCLUDE(cmake/base.cmake)
INCLUDE(cmake/boost.cmake)
INCLUDE(cmake/python.cmake)
jcarpent's avatar
jcarpent committed
22
INCLUDE(cmake/ide.cmake)
Nicolas Mansard's avatar
IVIGIT.    
Nicolas Mansard committed
23

Nicolas Mansard's avatar
Nicolas Mansard committed
24
25
SET(PROJECT_NAME eigenpy)
SET(PROJECT_DESCRIPTION "Wrapping Eigen3 -- numpy")
26
SET(PROJECT_URL "http://github.com/stack-of-tasks/eigenpy")
jcarpent's avatar
jcarpent committed
27
OPTION(INSTALL_DOCUMENTATION "Generate and install the documentation" FALSE)
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
28

Nicolas Mansard's avatar
Nicolas Mansard committed
29
30
31
# Disable -Werror on Unix for now.
SET(CXX_DISABLE_WERROR True)
SET(CMAKE_VERBOSE_MAKEFILE True)
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
32

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

36
37
IF(APPLE)
  SET(CMAKE_MACOSX_RPATH TRUE)
jcarpent's avatar
jcarpent committed
38
39
40
41
42
43
44
45
46
  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")
47
48
ENDIF(APPLE)

49
50
51
52
53
54
IF(WIN32)
  SET(LINK copy_if_different)
ELSE(WIN32)
  SET(LINK create_symlink)
ENDIF(WIN32)

55
56
57
# ----------------------------------------------------
# --- OPTIONS  ---------------------------------------
# ----------------------------------------------------
jcarpent's avatar
jcarpent committed
58
OPTION (BUILD_UNIT_TESTS "Build the unitary tests" ON)
59

Nicolas Mansard's avatar
Nicolas Mansard committed
60
61
62
# ----------------------------------------------------
# --- DEPENDANCIES -----------------------------------
# ----------------------------------------------------
63
ADD_REQUIRED_DEPENDENCY("eigen3 >= 3.0.5")
jcarpent's avatar
jcarpent committed
64

Nicolas Mansard's avatar
Nicolas Mansard committed
65
66
SET(BOOST_COMPONENTS python)
SEARCH_FOR_BOOST()
jcarpent's avatar
jcarpent committed
67
# Add Boost path to include directories.
68
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIRS})
jcarpent's avatar
jcarpent committed
69
70

FINDPYTHON(2.7 EXACT REQUIRED)
71
INCLUDE_DIRECTORIES(SYSTEM ${PYTHON_INCLUDE_DIRS})
72
FIND_NUMPY()
73
INCLUDE_DIRECTORIES(SYSTEM ${NUMPY_INCLUDE_DIRS})
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
74

Nicolas Mansard's avatar
Nicolas Mansard committed
75
76
77
# ----------------------------------------------------
# --- INCLUDE ----------------------------------------
# ----------------------------------------------------
jcarpent's avatar
jcarpent committed
78
79
SET(${PROJECT_NAME}_SOLVERS_HEADERS
  solvers/solvers.hpp
jcarpent's avatar
jcarpent committed
80
  solvers/preconditioners.hpp
jcarpent's avatar
jcarpent committed
81
82
83
84
  solvers/IterativeSolverBase.hpp
  solvers/LeastSquaresConjugateGradient.hpp
  solvers/ConjugateGradient.hpp
  solvers/SparseSolverBase.hpp
jcarpent's avatar
jcarpent committed
85
86
  solvers/BasicPreconditioners.hpp
  solvers/BFGSPreconditioners.hpp
jcarpent's avatar
jcarpent committed
87
88
  )

89
SET(HEADERS
jcarpent's avatar
jcarpent committed
90
  ${${PROJECT_NAME}_SOLVERS_HEADERS}
91
92
93
94
95
96
97
98
99
100
  eigenpy.hpp
  exception.hpp
  details.hpp
  fwd.hpp
  map.hpp
  geometry.hpp
  memory.hpp
  registration.hpp
  angle-axis.hpp
  quaternion.hpp
101
  ref.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
102
)
jcarpent's avatar
jcarpent committed
103

Nicolas Mansard's avatar
Nicolas Mansard committed
104
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/eigenpy")
105
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/eigenpy/solvers")
Nicolas Mansard's avatar
Nicolas Mansard committed
106
INCLUDE_DIRECTORIES(${${PROJECT_NAME}_BINARY_DIR}/include/eigenpy)
Nicolas Mansard's avatar
Nicolas Mansard committed
107

108
SET(${PROJECT_NAME}_HEADERS)
109
FOREACH(header ${HEADERS})
Nicolas Mansard's avatar
Nicolas Mansard committed
110
  GET_FILENAME_COMPONENT(headerName ${header} NAME)
111
112
113
114
115
116
117
118
  GET_FILENAME_COMPONENT(headerPath ${header} PATH)
  EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E ${LINK}
    ${${PROJECT_NAME}_SOURCE_DIR}/src/${header}
    ${${PROJECT_NAME}_BINARY_DIR}/include/${PROJECT_NAME}/${header})
  INSTALL(FILES ${${PROJECT_NAME}_SOURCE_DIR}/src/${header}
    DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}/${headerPath}
          PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE)
  LIST(APPEND ${PROJECT_NAME}_HEADERS src/${header})
Nicolas Mansard's avatar
Nicolas Mansard committed
119
120
121
122
123
ENDFOREACH(header)

# ----------------------------------------------------
# --- 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
SET(${PROJECT_NAME}_SOURCES
jcarpent's avatar
jcarpent committed
129
  ${${PROJECT_NAME}_SOLVERS_SOURCES}
Nicolas Mansard's avatar
Nicolas Mansard committed
130
  src/exception.cpp
131
  src/eigenpy.cpp
Nicolas Mansard's avatar
Nicolas Mansard committed
132
133
  src/angle-axis.cpp
  src/quaternion.cpp
134
)
Nicolas Mansard's avatar
Nicolas Mansard committed
135

136
ADD_LIBRARY(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS})
137

138
TARGET_LINK_BOOST_PYTHON(${PROJECT_NAME})
139
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} eigen3)
140
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
Nicolas Mansard's avatar
Nicolas Mansard committed
141

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

Nicolas Mansard's avatar
Nicolas Mansard committed
145
# ----------------------------------------------------
146
# --- PYTHON LIBRARY ---------------------------------
jcarpent's avatar
jcarpent committed
147
# ----------------------------------------------------
148
ADD_SUBDIRECTORY(python)
Nicolas Mansard's avatar
Nicolas Mansard committed
149

150
# ----------------------------------------------------
151
# --- UNIT TEST --------------------------------------
152
# ----------------------------------------------------
153
ADD_SUBDIRECTORY(unittest)
154

155
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
156
157
PKG_CONFIG_APPEND_CFLAGS("-isystem ${PYTHON_INCLUDE_DIRS}")
PKG_CONFIG_APPEND_CFLAGS("-isystem ${NUMPY_INCLUDE_DIRS}")
158
PKG_CONFIG_APPEND_BOOST_LIBS(${BOOST_COMPONENTS})
Nicolas Mansard's avatar
Nicolas Mansard committed
159
160

SETUP_PROJECT_FINALIZE()