diff --git a/CMake/SofaPython3Tools.cmake b/CMake/SofaPython3Tools.cmake index a5635943..5fe03fd3 100644 --- a/CMake/SofaPython3Tools.cmake +++ b/CMake/SofaPython3Tools.cmake @@ -65,7 +65,7 @@ function(SP3_add_python_package) get_filename_component(relative_directory ${file_relative_path} DIRECTORY) install( FILES "${OUTPUT_DIRECTORY}/${file_relative_path}" - DESTINATION "${LIBRARY_OUTPUT_DIRECTORY}/${SP3_PYTHON_PACKAGES_DIRECTORY}/${A_TARGET_DIRECTORY}/${relative_directory}" + DESTINATION "lib/${SP3_PYTHON_PACKAGES_DIRECTORY}/${A_TARGET_DIRECTORY}/${relative_directory}" ) endforeach() @@ -171,9 +171,35 @@ function(SP3_add_python_module) if (APPLE) # In MacOS, the target dependency name is RPATH/site-packages/PackageName, so we need to add - # an RPATH to the directory that contains "site-paclages" + # an RPATH to the directory that contains "site-packages" list(APPEND ${A_TARGET}_DEPENDECIES_RPATH "$ORIGIN/../..") endif() + + # Compute the installation RPATHs from the target's SOFA relocatable dependencies + # 1. First, compute the relative path from the current target towards the "plugins" relocatable directory of SOFA + # 2. Append to the previous computed path the RELOCATABLE_INSTALL_DIR target property of the dependency since the + # latter is formulated with respect to the "plugins" relocatable (e.g. "plugins/SofaBoundaryConditions/lib") + foreach(DEPENDENCY ${A_DEPENDS}) + if (TARGET ${DEPENDENCY}) + get_target_property(DEPENDENCY_RELOCATABLE_INSTALL_DIR "${DEPENDENCY}" RELOCATABLE_INSTALL_DIR) + if (DEPENDENCY_RELOCATABLE_INSTALL_DIR) + # Get the relative path from this binding module to the install lib directory + # For example, for lib/python3/site-packages/Sofa/Core.***.so, the relative path will be + # "../../.." + file(RELATIVE_PATH relative_towards_plugins_dir "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${SP3_PYTHON_PACKAGES_DIRECTORY}/${DESTINATION}" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") + # Here, we assume that the SP3 plugin will be installed in the SOFA plugins directory (i.e. $SOFA_ROOT/plugins) + # Hence, we need to compute the relative path from this plugins directory to the current binding + # modules, for example, plugins/SofaPython3/lib/python3/site-packages/Sofa/Core.***.so + # will become "../../../../../.." (three levels upper than the previous computed relative path) + set(relative_towards_plugins_dir "${relative_towards_plugins_dir}../../..") + + # Alright, now we have the path from the current target towards the "plugins" relocatable directory of SOFA + # We can compute the relative path from the current target towards the dependency relocatable path. + set(relative_towards_dependency_dir "${relative_towards_plugins_dir}/${DEPENDENCY_RELOCATABLE_INSTALL_DIR}") + list(APPEND ${A_TARGET}_DEPENDECIES_RPATH "$ORIGIN/${relative_towards_dependency_dir}/lib") + endif() + endif() + endforeach() set_target_properties( ${A_TARGET} @@ -220,9 +246,9 @@ function(SP3_add_python_module) install(TARGETS ${A_TARGET} EXPORT BindingsTargets - RUNTIME DESTINATION "${LIBRARY_OUTPUT_DIRECTORY}/${SP3_PYTHON_PACKAGES_DIRECTORY}/${DESTINATION}" COMPONENT applications - LIBRARY DESTINATION "${LIBRARY_OUTPUT_DIRECTORY}/${SP3_PYTHON_PACKAGES_DIRECTORY}/${DESTINATION}" COMPONENT libraries - ARCHIVE DESTINATION "${LIBRARY_OUTPUT_DIRECTORY}/${SP3_PYTHON_PACKAGES_DIRECTORY}/${DESTINATION}" COMPONENT libraries + RUNTIME DESTINATION "lib/${SP3_PYTHON_PACKAGES_DIRECTORY}/${DESTINATION}" COMPONENT applications + LIBRARY DESTINATION "lib/${SP3_PYTHON_PACKAGES_DIRECTORY}/${DESTINATION}" COMPONENT libraries + ARCHIVE DESTINATION "lib/${SP3_PYTHON_PACKAGES_DIRECTORY}/${DESTINATION}" COMPONENT libraries ) foreach(header ${A_HEADERS}) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2779322f..73500a03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,6 @@ cmake_minimum_required(VERSION 3.12) -project(SofaPython3) - -# Manually define VERSION -set(SOFAPYTHON3_VERSION_MAJOR 20) -set(SOFAPYTHON3_VERSION_MINOR 12) -set(SOFAPYTHON3_VERSION_PATCH 0) -set(SOFAPYTHON3_VERSION ${SOFAPYTHON3_VERSION_MAJOR}.${SOFAPYTHON3_VERSION_MINOR}.${SOFAPYTHON3_VERSION_PATCH}) +project(SofaPython3 VERSION 20.12.0) # Detect if SofaPython3 is a subproject of another project (eg. when compiled within Sofa) if (NOT "${CMAKE_PROJECT_NAME}" STREQUAL "${PROJECT_NAME}") @@ -31,16 +25,17 @@ if (SP3_COMPILED_AS_SOFA_SUBPROJECT) endif() endif() -# CMAKE TOOLS -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake") -include(SofaPython3Tools) - +# SofaPython3 cannot be compiled alongside SofaPython(2) if (SP3_COMPILED_AS_SOFA_SUBPROJECT) if(PLUGIN_SOFAPYTHON) message(FATAL_ERROR "SofaPython3 cannot be built alongside SofaPython. Please set PLUGIN_SOFAPYTHON to OFF") endif() endif() +# CMAKE TOOLS +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake") +include(SofaPython3Tools) + # OPTIONS include(CMakeDependentOption) @@ -173,24 +168,11 @@ SP3_add_python_package( Sofa/constants ) -configure_package_config_file( - "${CMAKE_CURRENT_SOURCE_DIR}/SofaPython3Config.cmake.in" - "${CMAKE_BINARY_DIR}/cmake/SofaPython3/SofaPython3Config.cmake" - INSTALL_DESTINATION - "${LIBRARY_OUTPUT_DIRECTORY}/cmake/SofaPython3" -) -write_basic_package_version_file( - ${CMAKE_BINARY_DIR}/cmake/SofaPython3/SofaPython3ConfigVersion.cmake - VERSION ${SOFAPYTHON3_VERSION} - COMPATIBILITY AnyNewerVersion -) - -install(FILES - "${CMAKE_BINARY_DIR}/cmake/SofaPython3/SofaPython3Config.cmake" - "${CMAKE_BINARY_DIR}/cmake/SofaPython3/SofaPython3ConfigVersion.cmake" - DESTINATION - "${LIBRARY_OUTPUT_DIRECTORY}/cmake/SofaPython3" -) +sofa_create_package( + PACKAGE_NAME ${PROJECT_NAME} + PACKAGE_VERSION ${PROJECT_VERSION} + RELOCATABLE "plugins" + ) if (SP3_LINK_TO_USER_SITE AND SP3_PYTHON_PACKAGES_LINK_DIRECTORY) file(GLOB directories RELATIVE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${SP3_PYTHON_PACKAGES_DIRECTORY}" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${SP3_PYTHON_PACKAGES_DIRECTORY}/*") @@ -202,7 +184,7 @@ if (SP3_LINK_TO_USER_SITE AND SP3_PYTHON_PACKAGES_LINK_DIRECTORY) install(CODE "\ execute_process( \ COMMAND ${CMAKE_COMMAND} -E copy_directory \ - ${CMAKE_INSTALL_PREFIX}/${LIBRARY_OUTPUT_DIRECTORY}/${SP3_PYTHON_PACKAGES_DIRECTORY}/${directory}/ \ + ${CMAKE_INSTALL_PREFIX}/lib/${SP3_PYTHON_PACKAGES_DIRECTORY}/${directory}/ \ ${SP3_PYTHON_PACKAGES_LINK_DIRECTORY}/${directory} \ )" ) @@ -210,7 +192,7 @@ if (SP3_LINK_TO_USER_SITE AND SP3_PYTHON_PACKAGES_LINK_DIRECTORY) install(CODE "\ execute_process( \ COMMAND ${CMAKE_COMMAND} -E create_symlink \ - ${CMAKE_INSTALL_PREFIX}/${LIBRARY_OUTPUT_DIRECTORY}/${SP3_PYTHON_PACKAGES_DIRECTORY}/${directory}/ \ + ${CMAKE_INSTALL_PREFIX}/lib/${SP3_PYTHON_PACKAGES_DIRECTORY}/${directory}/ \ ${SP3_PYTHON_PACKAGES_LINK_DIRECTORY}/${directory} \ )" ) diff --git a/Plugin/CMakeLists.txt b/Plugin/CMakeLists.txt index d7d9ea21..df66d320 100644 --- a/Plugin/CMakeLists.txt +++ b/Plugin/CMakeLists.txt @@ -41,24 +41,12 @@ find_package(SofaSimulation REQUIRED) add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES}) add_library(SofaPython3::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) -set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "_d") target_compile_definitions(${PROJECT_NAME} PRIVATE "-DSOFA_BUILD_SOFAPYTHON3") -target_compile_definitions(${PROJECT_NAME} PUBLIC "-DSOFA_HAVE_SOFAPYTHON3") - -target_include_directories(${PROJECT_NAME} PUBLIC "$") -target_include_directories(${PROJECT_NAME} PUBLIC "$") target_link_libraries(${PROJECT_NAME} PUBLIC SofaCore SofaDefaultType SofaSimulationCore SofaSimulationGraph SofaHelper) -target_link_libraries(${PROJECT_NAME} PUBLIC pybind11::module pybind11::embed) +target_link_libraries(${PROJECT_NAME} PUBLIC pybind11::module pybind11::embed) set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME SofaPython3) -set_target_properties(${target} PROPERTIES VERSION "${SOFAPYTHON3_VERSION}") - -set_target_properties( - ${PROJECT_NAME} - PROPERTIES - INSTALL_RPATH_USE_LINK_PATH TRUE -) if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") # Sized deallocaion is not enabled by default under clang after c++14 @@ -84,34 +72,13 @@ set_target_properties( CUDA_VISIBILITY_PRESET "hidden" ) -# Install header files -foreach(header ${HEADER_FILES}) - file(RELATIVE_PATH relative_path "${CMAKE_CURRENT_SOURCE_DIR}/src" "${header}") - get_filename_component(relative_directory ${relative_path} DIRECTORY) - - install(FILES "${header}" DESTINATION "include/${relative_directory}" COMPONENT headers) -endforeach() - -configure_package_config_file( - "${CMAKE_CURRENT_SOURCE_DIR}/PluginConfig.cmake.in" - "${CMAKE_BINARY_DIR}/cmake/SofaPython3/PluginConfig.cmake" - INSTALL_DESTINATION - "${LIBRARY_OUTPUT_DIRECTORY}/cmake/SofaPython3" -) - -install(FILES "${CMAKE_BINARY_DIR}/cmake/SofaPython3/PluginConfig.cmake" DESTINATION "${LIBRARY_OUTPUT_DIRECTORY}/cmake/SofaPython3") - -install(TARGETS ${PROJECT_NAME} - EXPORT PluginTargets - RUNTIME DESTINATION "${RUNTIME_OUTPUT_DIRECTORY}" COMPONENT applications - LIBRARY DESTINATION "${LIBRARY_OUTPUT_DIRECTORY}" COMPONENT libraries - ARCHIVE DESTINATION "${ARCHIVE_OUTPUT_DIRECTORY}" COMPONENT libraries -) - -install( - EXPORT PluginTargets - NAMESPACE SofaPython3:: - DESTINATION "${LIBRARY_OUTPUT_DIRECTORY}/cmake/SofaPython3" - COMPONENT headers -) - +sofa_create_component_in_package_with_targets( + COMPONENT_NAME ${PROJECT_NAME} + COMPONENT_VERSION ${SofaPython3_VERSION} + PACKAGE_NAME SofaPython3 + TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES + INCLUDE_SOURCE_DIR "src" + INCLUDE_INSTALL_DIR "." + OPTIMIZE_BUILD_DIR FALSE + RELOCATABLE ".." + ) diff --git a/Plugin/src/SofaPython3/PythonTestExtractor.cpp b/Plugin/src/SofaPython3/PythonTestExtractor.cpp index 8ac5d093..a027dd99 100644 --- a/Plugin/src/SofaPython3/PythonTestExtractor.cpp +++ b/Plugin/src/SofaPython3/PythonTestExtractor.cpp @@ -5,6 +5,9 @@ #include #include +#include +using sofa::helper::system::PluginManager; + using sofa::helper::system::SetDirectory; namespace py = pybind11; @@ -45,6 +48,8 @@ py::object PythonTestExtractor::getTestSuite(py::module& unittest, py::module& m std::vector PythonTestExtractor::extract () const { + PluginManager::getInstance().loadPlugin("SofaPython3"); + PythonEnvironment::Init(); PythonEnvironment::gil scoped_gil; diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt index c1a588c8..4257e2a0 100644 --- a/bindings/CMakeLists.txt +++ b/bindings/CMakeLists.txt @@ -1,15 +1,30 @@ project(Bindings) set(BINDINGS_MODULE_LIST Sofa SofaRuntime SofaGui SofaTypes Modules) +if(SP3_WITH_SOFAEXPORTER) + list(APPEND BINDINGS_MODULE_LIST SofaExporter) +endif() + +# This will set rpaths relative to SP3 plugin library +if(UNIX) + set(CMAKE_INSTALL_RPATH + "$ORIGIN/../lib" + "$$ORIGIN/../lib" + ) + if(APPLE) + set(CMAKE_MACOSX_RPATH ON) + list(APPEND CMAKE_INSTALL_RPATH + "@loader_path/../lib" + "@executable_path/../lib" + ) + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + endif() +endif() foreach(bindings_module ${BINDINGS_MODULE_LIST}) add_subdirectory(${bindings_module}) endforeach() -if (SP3_WITH_SOFAEXPORTER) - add_subdirectory(SofaExporter) -endif() - add_library(${PROJECT_NAME} INTERFACE) add_library(SofaPython3::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) @@ -17,38 +32,23 @@ foreach(bindings_module ${BINDINGS_MODULE_LIST}) target_link_libraries(${PROJECT_NAME} INTERFACE ${PROJECT_NAME}.${bindings_module}) endforeach() -if (SP3_WITH_SOFAEXPORTER) - target_link_libraries(${PROJECT_NAME} INTERFACE ${PROJECT_NAME}.SofaExporter) -endif() - -configure_package_config_file( - "${CMAKE_CURRENT_SOURCE_DIR}/BindingsConfig.cmake.in" - "${CMAKE_BINARY_DIR}/cmake/SofaPython3/BindingsConfig.cmake" - INSTALL_DESTINATION - "${LIBRARY_OUTPUT_DIRECTORY}/cmake/SofaPython3" -) - -install(FILES "${CMAKE_BINARY_DIR}/cmake/SofaPython3/BindingsConfig.cmake" DESTINATION "${LIBRARY_OUTPUT_DIRECTORY}/cmake/SofaPython3") - -install(TARGETS ${PROJECT_NAME} EXPORT BindingsTargets) - -install( - EXPORT BindingsTargets - NAMESPACE SofaPython3:: - DESTINATION "${LIBRARY_OUTPUT_DIRECTORY}/cmake/SofaPython3" - COMPONENT headers -) +sofa_create_component_in_package_with_targets( + COMPONENT_NAME ${PROJECT_NAME} + COMPONENT_VERSION ${SofaPython3_VERSION} + PACKAGE_NAME SofaPython3 + TARGETS ${PROJECT_NAME} + ) -if (SP3_COMPILED_AS_SOFA_SUBPROJECT) - ## Python configuration file (build tree), the lib in the source dir (easier while developping .py files) - file(WRITE "${CMAKE_BINARY_DIR}/etc/sofa/python.d/plugin.SofaPython3.bindings" "${CMAKE_BINARY_DIR}/${SP3_PYTHON_PACKAGES_DIRECTORY}\n") +#if (SP3_COMPILED_AS_SOFA_SUBPROJECT) +# ## Python configuration file (build tree), the lib in the source dir (easier while developping .py files) +# file(WRITE "${CMAKE_BINARY_DIR}/etc/sofa/python.d/plugin.SofaPython3.bindings" "${CMAKE_BINARY_DIR}/${SP3_PYTHON_PACKAGES_DIRECTORY}\n") - ## Python configuration file (install tree) - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installed-bindings-config" - "${CMAKE_INSTALL_PREFIX}/${SP3_PYTHON_PACKAGES_DIRECTORY}\n") +# ## Python configuration file (install tree) +# file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installed-bindings-config" +# "${CMAKE_INSTALL_PREFIX}/${SP3_PYTHON_PACKAGES_DIRECTORY}\n") - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/installed-bindings-config" - DESTINATION "etc/sofa/python.d" - RENAME "plugin.SofaPython3.bindings") -endif() \ No newline at end of file +# install(FILES "${CMAKE_CURRENT_BINARY_DIR}/installed-bindings-config" +# DESTINATION "etc/sofa/python.d" +# RENAME "plugin.SofaPython3.bindings") +#endif() diff --git a/bindings/Modules/tests/CMakeLists.txt b/bindings/Modules/tests/CMakeLists.txt index b4bba4c0..27632d42 100644 --- a/bindings/Modules/tests/CMakeLists.txt +++ b/bindings/Modules/tests/CMakeLists.txt @@ -14,20 +14,14 @@ find_package(SofaFramework REQUIRED) enable_testing() add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${PYTHON_FILES}) -target_link_libraries(${PROJECT_NAME} SofaGTestMain SofaHelper SofaPython3::Plugin SofaPython3::Bindings.Modules) +target_link_libraries(${PROJECT_NAME} SofaGTestMain SofaHelper SofaPython3::Plugin) target_compile_definitions(${PROJECT_NAME} PRIVATE "PYTHON_TESTFILES_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\"") set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Bindings/Tests") -set(RPATH "$ORIGIN/../lib") -if (APPLE) - list(APPEND RPATH "@executable_path/../lib") -endif() - -set_target_properties( - ${PROJECT_NAME} - PROPERTIES - INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "${RPATH}" +# This will set rpaths relative to all SOFA core AND relocatable dependencies +sofa_auto_set_target_rpath( + TARGETS ${PROJECT_NAME} + RELOCATABLE "plugins" ) add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}) diff --git a/bindings/Sofa/tests/CMakeLists.txt b/bindings/Sofa/tests/CMakeLists.txt index eef73a1a..a2c083e7 100644 --- a/bindings/Sofa/tests/CMakeLists.txt +++ b/bindings/Sofa/tests/CMakeLists.txt @@ -37,20 +37,14 @@ find_package(SofaFramework REQUIRED) enable_testing() add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${HEADER_FILES} ${PYTHON_FILES}) -target_link_libraries(${PROJECT_NAME} SofaGTestMain SofaHelper SofaPython3::Plugin SofaPython3::Bindings.Sofa SofaPython3::Bindings.SofaTypes SofaPython3::Bindings.SofaRuntime) +target_link_libraries(${PROJECT_NAME} SofaGTestMain SofaHelper SofaPython3::Plugin) target_compile_definitions(${PROJECT_NAME} PRIVATE "PYTHON_TESTFILES_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\"") set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Bindings/Tests") -set(RPATH "$ORIGIN/../lib") -if (APPLE) - list(APPEND RPATH "@executable_path/../lib") -endif() - -set_target_properties( - ${PROJECT_NAME} - PROPERTIES - INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "${RPATH}" +# This will set rpaths relative to all SOFA core AND relocatable dependencies +sofa_auto_set_target_rpath( + TARGETS ${PROJECT_NAME} + RELOCATABLE "plugins" ) add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}) diff --git a/bindings/SofaExporter/CMakeLists.txt b/bindings/SofaExporter/CMakeLists.txt index bf5feef5..93550e62 100644 --- a/bindings/SofaExporter/CMakeLists.txt +++ b/bindings/SofaExporter/CMakeLists.txt @@ -18,8 +18,4 @@ SP3_add_python_module( SOURCES ${SOURCE_FILES} HEADERS ${HEADER_FILES} DEPENDS SofaExporter SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core -) - -if(SP3_BUILD_TEST) - add_subdirectory(tests) -endif() +) \ No newline at end of file diff --git a/bindings/SofaExporter/tests/CMakeLists.txt b/bindings/SofaExporter/tests/CMakeLists.txt deleted file mode 100644 index b6f0c2a6..00000000 --- a/bindings/SofaExporter/tests/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -project(Bindings.SofaExporter.Tests) - -set(SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/PythonModule_SofaExporter_test.cpp -) - -set(PYTHON_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/tests/STLExporter.py - ) - -find_package(SofaGTestMain REQUIRED) -find_package(SofaFramework REQUIRED) - -add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${PYTHON_FILES}) -target_link_libraries(${PROJECT_NAME} SofaGTestMain SofaHelper SofaPython3::Plugin SofaPython3::Bindings.SofaExporter) -target_compile_definitions(${PROJECT_NAME} PRIVATE "PYTHON_TESTFILES_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\"") - -set_target_properties( - ${PROJECT_NAME} - PROPERTIES - INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "$ORIGIN/../lib" -) - -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}) - -SP3_configure_directory(${CMAKE_CURRENT_SOURCE_DIR}/tests ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/tests) -install(DIRECTORY ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/tests DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}) - -install( - TARGETS ${PROJECT_NAME} - EXPORT BindingsTargets - RUNTIME DESTINATION ${RUNTIME_OUTPUT_DIRECTORY} -) \ No newline at end of file diff --git a/bindings/SofaExporter/tests/PythonModule_SofaExporter_test.cpp b/bindings/SofaExporter/tests/PythonModule_SofaExporter_test.cpp deleted file mode 100644 index 56adce02..00000000 --- a/bindings/SofaExporter/tests/PythonModule_SofaExporter_test.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/********************************************************************* -Copyright 2019, CNRS, University of Lille, INRIA - -This file is part of sofaPython3 - -sofaPython3 is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -sofaPython3 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 Public License for more details. - -You should have received a copy of the GNU General Public License -along with sofaqtquick. If not, see . -*********************************************************************/ -/******************************************************************** - Contributors: - - damien.marchal@univ-lille.fr - - bruno.josue.marques@inria.fr - - eve.le-guillou@centrale.centralelille.fr - - jean-nicolas.brunet@inria.fr - - thierry.gaugry@inria.fr -********************************************************************/ - -/****************************************************************************** -* SOFA, Simulation Open-Framework Architecture, development version * -* (c) 2006-2018 INRIA, USTL, UJF, CNRS, MGH * -* * -* This program 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 2.1 of the License, or (at * -* your option) any later version. * -* * -* This program 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 this program. If not, see . * -******************************************************************************* -* Authors: The SOFA Team and external contributors (see Authors.txt) * -* * -* Contact information: contact@sofa-framework.org * -******************************************************************************/ -/****************************************************************************** - * Contributors: * - * - damien.marchal@univ-lille1.fr * - *****************************************************************************/ - -#include - -#include -#include -#include - -using sofapython3::PythonTest ; -using sofapython3::PythonTestExtractor ; -using sofapython3::PrintTo ; -using std::string; - -#include -using sofa::helper::logging::MessageDispatcher; -using sofa::helper::logging::MainPerComponentLoggingMessageHandler; - -namespace -{ - -bool init() -{ - MessageDispatcher::addHandler(&MainPerComponentLoggingMessageHandler::getInstance()) ; - return true; -} - -static int _inited_=init(); - -class SofaExporter : public PythonTest {}; - -/// static build of the test list -static struct PythonModule_SofaExporter_tests : public PythonTestExtractor -{ - PythonModule_SofaExporter_tests() - { - const std::string executable_directory = sofa::helper::Utils::getExecutableDirectory(); - addTestDirectory(executable_directory+"/tests", "SofaExporter_"); - } -} python_tests; - -/// run test list using the custom name function getTestName. -/// this allows to do gtest_filter=*FileName* -INSTANTIATE_TEST_CASE_P(SofaPython3, - SofaExporter, - ::testing::ValuesIn(python_tests.extract()), - SofaExporter::getTestName); - -TEST_P(SofaExporter, all_tests) { run(GetParam()); } - -} diff --git a/bindings/SofaExporter/tests/tests/STLExporter.py b/bindings/SofaExporter/tests/tests/STLExporter.py deleted file mode 100644 index a000fa5b..00000000 --- a/bindings/SofaExporter/tests/tests/STLExporter.py +++ /dev/null @@ -1,11 +0,0 @@ -# coding: utf8 - -import Sofa.Core -import Sofa.Helper -import unittest -import numpy - -class Test(unittest.TestCase): - def test_STLExporter(self): - import Exporter - Sofa.Helper.msg_error("Not implemented yet") diff --git a/bindings/SofaRuntime/tests/CMakeLists.txt b/bindings/SofaRuntime/tests/CMakeLists.txt index 24eb3405..d46d798e 100644 --- a/bindings/SofaRuntime/tests/CMakeLists.txt +++ b/bindings/SofaRuntime/tests/CMakeLists.txt @@ -5,7 +5,7 @@ set(SOURCE_FILES ) set(PYTHON_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/tests/Base.py + ${CMAKE_CURRENT_SOURCE_DIR}/SofaRuntime/Base.py ) find_package(SofaGTestMain REQUIRED) @@ -13,26 +13,20 @@ find_package(SofaFramework REQUIRED) enable_testing() add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${PYTHON_FILES}) -target_link_libraries(${PROJECT_NAME} SofaGTestMain SofaHelper SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core) +target_link_libraries(${PROJECT_NAME} SofaGTestMain SofaHelper SofaPython3::Plugin) target_compile_definitions(${PROJECT_NAME} PRIVATE "PYTHON_TESTFILES_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"") set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Bindings/Tests") -set(RPATH "$ORIGIN/../lib") -if (APPLE) - list(APPEND RPATH "@executable_path/../lib") -endif() - -set_target_properties( - ${PROJECT_NAME} - PROPERTIES - INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "${RPATH}" +# This will set rpaths relative to all SOFA core AND relocatable dependencies +sofa_auto_set_target_rpath( + TARGETS ${PROJECT_NAME} + RELOCATABLE "plugins" ) add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}) -SP3_configure_directory(${CMAKE_CURRENT_SOURCE_DIR}/tests ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/tests) -install(DIRECTORY ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/tests DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}) +SP3_configure_directory(${CMAKE_CURRENT_SOURCE_DIR}/SofaRuntime ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/SofaRuntime) +install(DIRECTORY ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/SofaRuntime DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}) install( TARGETS ${PROJECT_NAME} diff --git a/bindings/SofaRuntime/tests/PythonModule_SofaRuntime_test.cpp b/bindings/SofaRuntime/tests/PythonModule_SofaRuntime_test.cpp index 251cdfdc..f954f075 100644 --- a/bindings/SofaRuntime/tests/PythonModule_SofaRuntime_test.cpp +++ b/bindings/SofaRuntime/tests/PythonModule_SofaRuntime_test.cpp @@ -63,7 +63,7 @@ static struct PythonModule_Sofa_tests : public PythonTestExtractor PythonModule_Sofa_tests() { const std::string executable_directory = sofa::helper::Utils::getExecutableDirectory(); - addTestDirectory(executable_directory+"/tests", "SofaRuntime_"); + addTestDirectory(executable_directory+"/SofaRuntime", "SofaRuntime_"); } } python_tests; diff --git a/bindings/SofaRuntime/tests/tests/Base.py b/bindings/SofaRuntime/tests/SofaRuntime/Base.py similarity index 100% rename from bindings/SofaRuntime/tests/tests/Base.py rename to bindings/SofaRuntime/tests/SofaRuntime/Base.py diff --git a/bindings/SofaTypes/tests/CMakeLists.txt b/bindings/SofaTypes/tests/CMakeLists.txt index 4799cdda..52e919d4 100644 --- a/bindings/SofaTypes/tests/CMakeLists.txt +++ b/bindings/SofaTypes/tests/CMakeLists.txt @@ -17,16 +17,10 @@ target_link_libraries(${PROJECT_NAME} SofaGTestMain SofaHelper SofaPython3::Plu target_compile_definitions(${PROJECT_NAME} PRIVATE "PYTHON_TESTFILES_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/pyfiles/\"") set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Bindings/Tests") -set(RPATH "$ORIGIN/../lib") -if (APPLE) - list(APPEND RPATH "@executable_path/../lib") -endif() - -set_target_properties( - ${PROJECT_NAME} - PROPERTIES - INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "${RPATH}" +# This will set rpaths relative to all SOFA core AND relocatable dependencies +sofa_auto_set_target_rpath( + TARGETS ${PROJECT_NAME} + RELOCATABLE "plugins" ) add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})