diff --git a/CMakeLists.txt b/CMakeLists.txt index f32ef3b27a5f3b7e562bf1726ef705bdcf3dbf20..b6709408b4cd21467daa8c9a7c69df86906dc477 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,6 +48,7 @@ ENDIF(APPLE) # --- OPTIONS --------------------------------------- # ---------------------------------------------------- OPTION (EIGEN_NUMPY_ALIGNED "Directly aligned data between Numpy and Eigen" OFF) +OPTION (BUILD_UNIT_TESTS "Build the unitary tests" ON) IF(EIGEN_NUMPY_ALIGNED) ADD_DEFINITIONS(-DEIGENPY_ALIGNED) @@ -104,7 +105,6 @@ ENDFOREACH(header) # ---------------------------------------------------- # --- TARGETS ---------------------------------------- # ---------------------------------------------------- - SET(${PROJECT_NAME}_SOURCES src/exception.cpp src/eigenpy.cpp @@ -122,15 +122,11 @@ INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) # ---------------------------------------------------- # --- UNIT TEST -------------------------------------- # ---------------------------------------------------- -ADD_LIBRARY(matrix SHARED unittest/matrix.cpp) -TARGET_LINK_LIBRARIES(matrix ${PROJECT_NAME}) -TARGET_LINK_BOOST_PYTHON(matrix) -SET_TARGET_PROPERTIES(matrix PROPERTIES PREFIX "") - -ADD_LIBRARY(geometry SHARED unittest/geometry.cpp) -TARGET_LINK_LIBRARIES(geometry ${PROJECT_NAME}) -TARGET_LINK_BOOST_PYTHON(geometry) -SET_TARGET_PROPERTIES(geometry PROPERTIES PREFIX "") +ADD_SUBDIRECTORY(unittest) + +# ---------------------------------------------------- +# --- EXECUTABLES ------------------------------------ +# ---------------------------------------------------- IF(EIGEN_NUMPY_ALIGNED) PKG_CONFIG_APPEND_CFLAGS("-DEIGENPY_ALIGNED") diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b80a2ea477439ad96f6909d33eb5e959123159ee --- /dev/null +++ b/unittest/CMakeLists.txt @@ -0,0 +1,41 @@ +# +# Copyright (c) 2016 CNRS +# +# This file is part of eigenpy +# Pinocchio 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. +# Pinocchio 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 +# General Lesser Public License for more details. You should have +# received a copy of the GNU Lesser General Public License along with +# Pinocchio If not, see +# <http://www.gnu.org/licenses/>. + +MACRO(ADD_LIB_UNIT_TEST test PKGS) + IF (BUILD_UNIT_TESTS) + ADD_LIBRARY(${test} SHARED ${test}) + ELSE (BUILD_UNIT_TESTS) + ADD_LIBRARY(${test} SHARED EXCLUDE_FROM_ALL ${test}) + ENDIF (BUILD_UNIT_TESTS) + FOREACH(PKG ${PKGS}) + PKG_CONFIG_USE_DEPENDENCY(${test} ${PKG}) + ENDFOREACH(PKG) + TARGET_LINK_LIBRARIES(${test} ${PROJECT_NAME}) + TARGET_LINK_BOOST_PYTHON(${test}) + SET_TARGET_PROPERTIES(${test} PROPERTIES PREFIX "") + + IF(APPLE) + # We need to change the extension for python bindings + SET_TARGET_PROPERTIES(${test} PROPERTIES SUFFIX ".so") + ENDIF(APPLE) + + #ADD_TEST(test ${test} COMMAND ${test}) + #ADD_DEPENDENCIES(check ${test}) +ENDMACRO(ADD_LIB_UNIT_TEST) + +ADD_LIB_UNIT_TEST(matrix "eigen3") +ADD_LIB_UNIT_TEST(geometry "eigen3") +