CMakeLists.txt 5.17 KB
Newer Older
Nicolas Mansard's avatar
Nicolas Mansard committed
1
#
jcarpent's avatar
jcarpent committed
2
# Copyright (c) 2015-2016 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)
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
IF(APPLE)
  SET(CMAKE_MACOSX_RPATH TRUE)
jcarpent's avatar
jcarpent committed
36
37
38
39
40
41
42
43
44
  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")
45
46
ENDIF(APPLE)

47
48
49
50
51
52
53
54
55
# ----------------------------------------------------
# --- 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
56
57
58
# ----------------------------------------------------
# --- DEPENDANCIES -----------------------------------
# ----------------------------------------------------
59
ADD_REQUIRED_DEPENDENCY("eigen3 >= 3.0.5")
Nicolas Mansard's avatar
Nicolas Mansard committed
60
61
62
63
SET(BOOST_COMPONENTS python)
SEARCH_FOR_BOOST()
set(Python_ADDITIONAL_VERSIONS 2.7)
FINDPYTHON()
64
FIND_NUMPY()
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
65

Nicolas Mansard's avatar
Nicolas Mansard committed
66
67
68
69
70
# ----------------------------------------------------
# --- INCLUDE ----------------------------------------
# ----------------------------------------------------
SET(${PROJECT_NAME}_HEADERS
  src/eigenpy.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
71
  src/exception.hpp
72
73
  src/details.hpp
  src/fwd.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
74
75
  src/map.hpp
  src/geometry.hpp
76
  src/memory.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
77
78
  src/angle-axis.hpp
  src/quaternion.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
79
80
)
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/eigenpy")
Nicolas Mansard's avatar
Nicolas Mansard committed
81
INCLUDE_DIRECTORIES(${${PROJECT_NAME}_BINARY_DIR}/include/eigenpy)
Nicolas Mansard's avatar
Nicolas Mansard committed
82
83
84
85
86
87
88
89
90
91
92
93
94
95

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
96
          PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
Nicolas Mansard's avatar
Nicolas Mansard committed
97
98
99
100
101
ENDFOREACH(header)

# ----------------------------------------------------
# --- TARGETS ----------------------------------------
# ----------------------------------------------------
102
103
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIRS})
# Add Boost path to include directories.
104
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
Nicolas Mansard's avatar
Nicolas Mansard committed
105

106
SET(${PROJECT_NAME}_SOURCES
Nicolas Mansard's avatar
Nicolas Mansard committed
107
  src/exception.cpp
108
109
  src/eigenpy.cpp
  src/details.cpp
Nicolas Mansard's avatar
Nicolas Mansard committed
110
111
  src/angle-axis.cpp
  src/quaternion.cpp
112
)
Nicolas Mansard's avatar
Nicolas Mansard committed
113

114
115
116
117
118
119
120
# 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)

121
TARGET_LINK_BOOST_PYTHON(${PROJECT_NAME})
122
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} eigen3)
123
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
Nicolas Mansard's avatar
Nicolas Mansard committed
124
125
126
127
128

# ----------------------------------------------------
# --- UNIT TEST --------------------------------------
# ----------------------------------------------------
ADD_LIBRARY(matrix SHARED unittest/matrix.cpp)
129
130
TARGET_LINK_LIBRARIES(matrix ${PROJECT_NAME})
TARGET_LINK_BOOST_PYTHON(matrix)
Nicolas Mansard's avatar
Nicolas Mansard committed
131
132
133
SET_TARGET_PROPERTIES(matrix PROPERTIES PREFIX "")

ADD_LIBRARY(geometry SHARED unittest/geometry.cpp)
134
135
TARGET_LINK_LIBRARIES(geometry ${PROJECT_NAME})
TARGET_LINK_BOOST_PYTHON(geometry)
Nicolas Mansard's avatar
Nicolas Mansard committed
136
137
SET_TARGET_PROPERTIES(geometry PROPERTIES PREFIX "")

138
139
140
IF(EIGEN_NUMPY_ALIGNED)
  PKG_CONFIG_APPEND_CFLAGS("-DEIGENPY_ALIGNED")
ENDIF(EIGEN_NUMPY_ALIGNED)
141
142

PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
Nicolas Mansard's avatar
Nicolas Mansard committed
143
PKG_CONFIG_APPEND_CFLAGS("-I${PYTHON_INCLUDE_DIRS}")
144
PKG_CONFIG_APPEND_CFLAGS("-I${NUMPY_INCLUDE_DIRS}")
145
PKG_CONFIG_APPEND_BOOST_LIBS(${BOOST_COMPONENTS})
Nicolas Mansard's avatar
Nicolas Mansard committed
146
147

SETUP_PROJECT_FINALIZE()