Skip to content

Commit 8e85b3f

Browse files
committed
[CMake] Rework unit tests
1 parent a6867bd commit 8e85b3f

File tree

2 files changed

+47
-10
lines changed

2 files changed

+47
-10
lines changed

CMakeLists.txt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ ENDIF(APPLE)
4848
# --- OPTIONS ---------------------------------------
4949
# ----------------------------------------------------
5050
OPTION (EIGEN_NUMPY_ALIGNED "Directly aligned data between Numpy and Eigen" OFF)
51+
OPTION (BUILD_UNIT_TESTS "Build the unitary tests" ON)
5152

5253
IF(EIGEN_NUMPY_ALIGNED)
5354
ADD_DEFINITIONS(-DEIGENPY_ALIGNED)
@@ -104,7 +105,6 @@ ENDFOREACH(header)
104105
# ----------------------------------------------------
105106
# --- TARGETS ----------------------------------------
106107
# ----------------------------------------------------
107-
108108
SET(${PROJECT_NAME}_SOURCES
109109
src/exception.cpp
110110
src/eigenpy.cpp
@@ -122,15 +122,11 @@ INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
122122
# ----------------------------------------------------
123123
# --- UNIT TEST --------------------------------------
124124
# ----------------------------------------------------
125-
ADD_LIBRARY(matrix SHARED unittest/matrix.cpp)
126-
TARGET_LINK_LIBRARIES(matrix ${PROJECT_NAME})
127-
TARGET_LINK_BOOST_PYTHON(matrix)
128-
SET_TARGET_PROPERTIES(matrix PROPERTIES PREFIX "")
129-
130-
ADD_LIBRARY(geometry SHARED unittest/geometry.cpp)
131-
TARGET_LINK_LIBRARIES(geometry ${PROJECT_NAME})
132-
TARGET_LINK_BOOST_PYTHON(geometry)
133-
SET_TARGET_PROPERTIES(geometry PROPERTIES PREFIX "")
125+
ADD_SUBDIRECTORY(unittest)
126+
127+
# ----------------------------------------------------
128+
# --- EXECUTABLES ------------------------------------
129+
# ----------------------------------------------------
134130

135131
IF(EIGEN_NUMPY_ALIGNED)
136132
PKG_CONFIG_APPEND_CFLAGS("-DEIGENPY_ALIGNED")

unittest/CMakeLists.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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(test ${test} COMMAND ${test})
36+
#ADD_DEPENDENCIES(check ${test})
37+
ENDMACRO(ADD_LIB_UNIT_TEST)
38+
39+
ADD_LIB_UNIT_TEST(matrix "eigen3")
40+
ADD_LIB_UNIT_TEST(geometry "eigen3")
41+

0 commit comments

Comments
 (0)