Skip to content

Commit daecee3

Browse files
authored
Merge pull request #11 from jcarpent/devel
Improve the packaging of EigenPy
2 parents f336caa + f0a4387 commit daecee3

File tree

4 files changed

+69
-24
lines changed

4 files changed

+69
-24
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
build/
1+
build*
22
release/
33
_build/
44
_release/

CMakeLists.txt

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2015 LAAS-CNRS
2+
# Copyright (c) 2015-2016 LAAS-CNRS
33
#
44
# This file is part of eigenpy.
55
# eigenpy is free software: you can redistribute it and/or
@@ -33,12 +33,22 @@ STRING(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
3333

3434
IF(APPLE)
3535
SET(CMAKE_MACOSX_RPATH TRUE)
36+
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
37+
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
38+
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
39+
40+
#SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
41+
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
42+
IF("${isSystemDir}" STREQUAL "-1")
43+
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
44+
ENDIF("${isSystemDir}" STREQUAL "-1")
3645
ENDIF(APPLE)
3746

3847
# ----------------------------------------------------
3948
# --- OPTIONS ---------------------------------------
4049
# ----------------------------------------------------
4150
OPTION (EIGEN_NUMPY_ALIGNED "Directly aligned data between Numpy and Eigen" OFF)
51+
OPTION (BUILD_UNIT_TESTS "Build the unitary tests" ON)
4252

4353
IF(EIGEN_NUMPY_ALIGNED)
4454
ADD_DEFINITIONS(-DEIGENPY_ALIGNED)
@@ -48,11 +58,16 @@ ENDIF(EIGEN_NUMPY_ALIGNED)
4858
# --- DEPENDANCIES -----------------------------------
4959
# ----------------------------------------------------
5060
ADD_REQUIRED_DEPENDENCY("eigen3 >= 3.0.5")
61+
5162
SET(BOOST_COMPONENTS python)
5263
SEARCH_FOR_BOOST()
53-
set(Python_ADDITIONAL_VERSIONS 2.7)
54-
FINDPYTHON()
64+
# Add Boost path to include directories.
65+
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
66+
67+
FINDPYTHON(2.7 EXACT REQUIRED)
68+
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
5569
FIND_NUMPY()
70+
INCLUDE_DIRECTORIES(${NUMPY_INCLUDE_DIRS})
5671

5772
# ----------------------------------------------------
5873
# --- INCLUDE ----------------------------------------
@@ -90,10 +105,6 @@ ENDFOREACH(header)
90105
# ----------------------------------------------------
91106
# --- TARGETS ----------------------------------------
92107
# ----------------------------------------------------
93-
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIRS})
94-
# Add Boost path to include directories.
95-
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
96-
97108
SET(${PROJECT_NAME}_SOURCES
98109
src/exception.cpp
99110
src/eigenpy.cpp
@@ -102,27 +113,20 @@ SET(${PROJECT_NAME}_SOURCES
102113
src/quaternion.cpp
103114
)
104115

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

112-
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
118+
TARGET_LINK_BOOST_PYTHON(${PROJECT_NAME})
113119
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} eigen3)
114120
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
115121

116122
# ----------------------------------------------------
117123
# --- UNIT TEST --------------------------------------
118124
# ----------------------------------------------------
119-
ADD_LIBRARY(matrix SHARED unittest/matrix.cpp)
120-
TARGET_LINK_LIBRARIES(matrix ${Boost_LIBRARIES} ${PROJECT_NAME})
121-
SET_TARGET_PROPERTIES(matrix PROPERTIES PREFIX "")
125+
ADD_SUBDIRECTORY(unittest)
122126

123-
ADD_LIBRARY(geometry SHARED unittest/geometry.cpp)
124-
TARGET_LINK_LIBRARIES(geometry ${Boost_LIBRARIES} ${PROJECT_NAME})
125-
SET_TARGET_PROPERTIES(geometry PROPERTIES PREFIX "")
127+
# ----------------------------------------------------
128+
# --- EXECUTABLES ------------------------------------
129+
# ----------------------------------------------------
126130

127131
IF(EIGEN_NUMPY_ALIGNED)
128132
PKG_CONFIG_APPEND_CFLAGS("-DEIGENPY_ALIGNED")
@@ -132,7 +136,5 @@ PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
132136
PKG_CONFIG_APPEND_CFLAGS("-I${PYTHON_INCLUDE_DIRS}")
133137
PKG_CONFIG_APPEND_CFLAGS("-I${NUMPY_INCLUDE_DIRS}")
134138
PKG_CONFIG_APPEND_BOOST_LIBS(${BOOST_COMPONENTS})
135-
PKG_CONFIG_APPEND_LIBS_RAW(${PYTHON_LIBRARIES})
136-
137139

138140
SETUP_PROJECT_FINALIZE()

unittest/CMakeLists.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#
2+
# Copyright (c) 2016 CNRS
3+
#
4+
# This file is part of eigenpy
5+
# Pinocchio is free software: you can redistribute it
6+
# and/or modify it under the terms of the GNU Lesser General Public
7+
# License as published by the Free Software Foundation, either version
8+
# 3 of the License, or (at your option) any later version.
9+
# Pinocchio is distributed in the hope that it will be
10+
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11+
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
# General Lesser Public License for more details. You should have
13+
# received a copy of the GNU Lesser General Public License along with
14+
# Pinocchio If not, see
15+
# <http://www.gnu.org/licenses/>.
16+
17+
MACRO(ADD_LIB_UNIT_TEST test PKGS)
18+
IF (BUILD_UNIT_TESTS)
19+
ADD_LIBRARY(${test} SHARED ${test})
20+
ELSE (BUILD_UNIT_TESTS)
21+
ADD_LIBRARY(${test} SHARED EXCLUDE_FROM_ALL ${test})
22+
ENDIF (BUILD_UNIT_TESTS)
23+
FOREACH(PKG ${PKGS})
24+
PKG_CONFIG_USE_DEPENDENCY(${test} ${PKG})
25+
ENDFOREACH(PKG)
26+
TARGET_LINK_LIBRARIES(${test} ${PROJECT_NAME})
27+
TARGET_LINK_BOOST_PYTHON(${test})
28+
SET_TARGET_PROPERTIES(${test} PROPERTIES PREFIX "")
29+
30+
IF(APPLE)
31+
# We need to change the extension for python bindings
32+
SET_TARGET_PROPERTIES(${test} PROPERTIES SUFFIX ".so")
33+
ENDIF(APPLE)
34+
35+
ADD_TEST(NAME ${test} COMMAND ${PYTHON_EXECUTABLE} -c "import ${test}")
36+
ADD_DEPENDENCIES(check ${test})
37+
ENDMACRO(ADD_LIB_UNIT_TEST)
38+
39+
ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
40+
41+
ADD_LIB_UNIT_TEST(matrix "eigen3")
42+
ADD_LIB_UNIT_TEST(geometry "eigen3")
43+

0 commit comments

Comments
 (0)