CMakeLists.txt 4.8 KB
Newer Older
Nicolas Mansard's avatar
Nicolas Mansard committed
1
#
jcarpent's avatar
jcarpent committed
2
3
4
5
6
7
8
9
10
11
12
13
14
# Copyright (c) 2015 LAAS-CNRS
#
# 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)
Nicolas Mansard's avatar
IVIGIT.    
Nicolas Mansard committed
22

Nicolas Mansard's avatar
Nicolas Mansard committed
23
24
SET(PROJECT_NAME eigenpy)
SET(PROJECT_DESCRIPTION "Wrapping Eigen3 -- numpy")
25
SET(PROJECT_URL "http://github.com/stack-of-tasks/eigenpy")
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
26

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

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

34
35
36
37
IF(APPLE)
  SET(CMAKE_MACOSX_RPATH TRUE)
ENDIF(APPLE)

38
39
40
41
42
43
44
45
46
# ----------------------------------------------------
# --- OPTIONS  ---------------------------------------
# ----------------------------------------------------
OPTION (EIGEN_NUMPY_ALIGNED "Directly aligned data between Numpy and Eigen" OFF)

IF(EIGEN_NUMPY_ALIGNED)
  ADD_DEFINITIONS(-DEIGENPY_ALIGNED)
ENDIF(EIGEN_NUMPY_ALIGNED)

Nicolas Mansard's avatar
Nicolas Mansard committed
47
48
49
# ----------------------------------------------------
# --- DEPENDANCIES -----------------------------------
# ----------------------------------------------------
50
ADD_REQUIRED_DEPENDENCY("eigen3 >= 3.0.5")
Nicolas Mansard's avatar
Nicolas Mansard committed
51
52
53
54
SET(BOOST_COMPONENTS python)
SEARCH_FOR_BOOST()
set(Python_ADDITIONAL_VERSIONS 2.7)
FINDPYTHON()
55
FIND_NUMPY()
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
56

Nicolas Mansard's avatar
Nicolas Mansard committed
57
58
59
60
61
# ----------------------------------------------------
# --- INCLUDE ----------------------------------------
# ----------------------------------------------------
SET(${PROJECT_NAME}_HEADERS
  src/eigenpy.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
62
  src/exception.hpp
63
64
  src/details.hpp
  src/fwd.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
65
66
  src/map.hpp
  src/geometry.hpp
67
  src/memory.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
68
69
  src/angle-axis.hpp
  src/quaternion.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
70
71
)
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/eigenpy")
Nicolas Mansard's avatar
Nicolas Mansard committed
72
INCLUDE_DIRECTORIES(${${PROJECT_NAME}_BINARY_DIR}/include/eigenpy)
Nicolas Mansard's avatar
Nicolas Mansard committed
73
74
75
76
77
78
79
80
81
82
83
84
85
86

FOREACH(header ${${PROJECT_NAME}_HEADERS})
  GET_FILENAME_COMPONENT(headerName ${header} NAME)
  IF(WIN32)
    execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
                    ${${PROJECT_NAME}_SOURCE_DIR}/${header}
                    ${${PROJECT_NAME}_BINARY_DIR}/include/${PROJECT_NAME}/)
  ELSE(WIN32)
    execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
                    ${${PROJECT_NAME}_SOURCE_DIR}/${header}
                    ${${PROJECT_NAME}_BINARY_DIR}/include/${PROJECT_NAME}/${headerName})
  ENDIF(WIN32)
  INSTALL(FILES ${${PROJECT_NAME}_SOURCE_DIR}/${header}
	  DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}
Nicolas Mansard's avatar
Nicolas Mansard committed
87
          PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
Nicolas Mansard's avatar
Nicolas Mansard committed
88
89
90
91
92
ENDFOREACH(header)

# ----------------------------------------------------
# --- TARGETS ----------------------------------------
# ----------------------------------------------------
93
94
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIRS})
# Add Boost path to include directories.
95
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
Nicolas Mansard's avatar
Nicolas Mansard committed
96

97
SET(${PROJECT_NAME}_SOURCES
Nicolas Mansard's avatar
Nicolas Mansard committed
98
  src/exception.cpp
99
100
  src/eigenpy.cpp
  src/details.cpp
Nicolas Mansard's avatar
Nicolas Mansard committed
101
102
  src/angle-axis.cpp
  src/quaternion.cpp
103
)
Nicolas Mansard's avatar
Nicolas Mansard committed
104

105
106
107
108
109
110
111
# With Darwin system, the library needs to be static for a complete exposion of eigen structure under Python
IF(APPLE)
  ADD_LIBRARY(${PROJECT_NAME} ${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS})
ELSE(APPLE)
  ADD_LIBRARY(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS})
ENDIF(APPLE)

112
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
113
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} eigen3)
114
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
Nicolas Mansard's avatar
Nicolas Mansard committed
115
116
117
118
119

# ----------------------------------------------------
# --- UNIT TEST --------------------------------------
# ----------------------------------------------------
ADD_LIBRARY(matrix SHARED unittest/matrix.cpp)
120
TARGET_LINK_LIBRARIES(matrix ${Boost_LIBRARIES} ${PROJECT_NAME})
Nicolas Mansard's avatar
Nicolas Mansard committed
121
122
123
SET_TARGET_PROPERTIES(matrix PROPERTIES PREFIX "")

ADD_LIBRARY(geometry SHARED unittest/geometry.cpp)
124
TARGET_LINK_LIBRARIES(geometry ${Boost_LIBRARIES} ${PROJECT_NAME})
Nicolas Mansard's avatar
Nicolas Mansard committed
125
126
SET_TARGET_PROPERTIES(geometry PROPERTIES PREFIX "")

127
128
129
IF(EIGEN_NUMPY_ALIGNED)
  PKG_CONFIG_APPEND_CFLAGS("-DEIGENPY_ALIGNED")
ENDIF(EIGEN_NUMPY_ALIGNED)
Nicolas Mansard's avatar
Nicolas Mansard committed
130
PKG_CONFIG_APPEND_CFLAGS("-I${PYTHON_INCLUDE_DIRS}")
131
PKG_CONFIG_APPEND_CFLAGS("-I${NUMPY_INCLUDE_DIRS}")
132
133
134
PKG_CONFIG_APPEND_LIBS("boost_python")
PKG_CONFIG_APPEND_LIBS_RAW(${PYTHON_LIBRARIES})
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
Nicolas Mansard's avatar
Nicolas Mansard committed
135
136

SETUP_PROJECT_FINALIZE()