CMakeLists.txt 4.12 KB
Newer Older
Nicolas Mansard's avatar
Nicolas Mansard committed
1
2
3
#
#  Copyright 2014 CNRS
#
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
4

Nicolas Mansard's avatar
Nicolas Mansard committed
5
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
Nicolas Mansard's avatar
IVIGIT.    
Nicolas Mansard committed
6

Nicolas Mansard's avatar
Nicolas Mansard committed
7
8
9
INCLUDE(cmake/base.cmake)
INCLUDE(cmake/boost.cmake)
INCLUDE(cmake/python.cmake)
Nicolas Mansard's avatar
IVIGIT.    
Nicolas Mansard committed
10

Nicolas Mansard's avatar
Nicolas Mansard committed
11
12
SET(PROJECT_NAME eigenpy)
SET(PROJECT_DESCRIPTION "Wrapping Eigen3 -- numpy")
13
SET(PROJECT_URL "http://github.com/stack-of-tasks/eigenpy")
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
14

Nicolas Mansard's avatar
Nicolas Mansard committed
15
16
17
# Disable -Werror on Unix for now.
SET(CXX_DISABLE_WERROR True)
SET(CMAKE_VERBOSE_MAKEFILE True)
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
18

Nicolas Mansard's avatar
Nicolas Mansard committed
19
SETUP_PROJECT()
20
STRING(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
Nicolas Mansard's avatar
Nicolas Mansard committed
21

22
23
24
25
IF(APPLE)
  SET(CMAKE_MACOSX_RPATH TRUE)
ENDIF(APPLE)

26
27
28
29
30
31
32
33
34
# ----------------------------------------------------
# --- 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
35
36
37
# ----------------------------------------------------
# --- DEPENDANCIES -----------------------------------
# ----------------------------------------------------
38
ADD_REQUIRED_DEPENDENCY("eigen3 >= 3.0.5")
Nicolas Mansard's avatar
Nicolas Mansard committed
39
40
41
42
SET(BOOST_COMPONENTS python)
SEARCH_FOR_BOOST()
set(Python_ADDITIONAL_VERSIONS 2.7)
FINDPYTHON()
43
FIND_NUMPY()
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
44

Nicolas Mansard's avatar
Nicolas Mansard committed
45
46
47
48
49
# ----------------------------------------------------
# --- INCLUDE ----------------------------------------
# ----------------------------------------------------
SET(${PROJECT_NAME}_HEADERS
  src/eigenpy.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
50
  src/exception.hpp
51
52
  src/details.hpp
  src/fwd.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
53
54
55
56
  src/map.hpp
  src/geometry.hpp
  src/angle-axis.hpp
  src/quaternion.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
57
58
)
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/eigenpy")
Nicolas Mansard's avatar
Nicolas Mansard committed
59
INCLUDE_DIRECTORIES(${${PROJECT_NAME}_BINARY_DIR}/include/eigenpy)
Nicolas Mansard's avatar
Nicolas Mansard committed
60
61
62
63
64
65
66
67
68
69
70
71
72
73

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
74
          PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
Nicolas Mansard's avatar
Nicolas Mansard committed
75
76
77
78
79
ENDFOREACH(header)

# ----------------------------------------------------
# --- TARGETS ----------------------------------------
# ----------------------------------------------------
80
81
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIRS})
# Add Boost path to include directories.
82
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
Nicolas Mansard's avatar
Nicolas Mansard committed
83

84
SET(${PROJECT_NAME}_SOURCES
Nicolas Mansard's avatar
Nicolas Mansard committed
85
  src/exception.cpp
86
87
  src/eigenpy.cpp
  src/details.cpp
Nicolas Mansard's avatar
Nicolas Mansard committed
88
89
  src/angle-axis.cpp
  src/quaternion.cpp
90
)
Nicolas Mansard's avatar
Nicolas Mansard committed
91

92
93
94
95
96
97
98
# 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)

99
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
100
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} eigen3)
101
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
Nicolas Mansard's avatar
Nicolas Mansard committed
102
103
104
105
106

# ----------------------------------------------------
# --- UNIT TEST --------------------------------------
# ----------------------------------------------------
ADD_LIBRARY(matrix SHARED unittest/matrix.cpp)
107
TARGET_LINK_LIBRARIES(matrix ${Boost_LIBRARIES} ${PROJECT_NAME})
Nicolas Mansard's avatar
Nicolas Mansard committed
108
109
110
SET_TARGET_PROPERTIES(matrix PROPERTIES PREFIX "")

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

114
115
116
IF(EIGEN_NUMPY_ALIGNED)
  PKG_CONFIG_APPEND_CFLAGS("-DEIGENPY_ALIGNED")
ENDIF(EIGEN_NUMPY_ALIGNED)
Nicolas Mansard's avatar
Nicolas Mansard committed
117
PKG_CONFIG_APPEND_CFLAGS("-I${PYTHON_INCLUDE_DIRS}")
118
PKG_CONFIG_APPEND_CFLAGS("-I${NUMPY_INCLUDE_DIRS}")
119
120
121
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
122
123

SETUP_PROJECT_FINALIZE()