diff --git a/CMake/SofaPython3Tools.cmake b/CMake/SofaPython3Tools.cmake index 6360995e3..5a44ae7a1 100644 --- a/CMake/SofaPython3Tools.cmake +++ b/CMake/SofaPython3Tools.cmake @@ -342,6 +342,13 @@ function(SP3_add_python_module) LIBRARY DESTINATION "lib/${SP3_PYTHON_PACKAGES_DIRECTORY}/${DESTINATION}" COMPONENT libraries ARCHIVE DESTINATION "lib/${SP3_PYTHON_PACKAGES_DIRECTORY}/${DESTINATION}" COMPONENT libraries ) + elseif (DESTINATION) + install( + TARGETS ${A_TARGET} + 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 + ) endif() foreach(header ${A_HEADERS}) diff --git a/Plugin/CMakeLists.txt b/Plugin/CMakeLists.txt index 314f04a9b..0fd25ad2c 100644 --- a/Plugin/CMakeLists.txt +++ b/Plugin/CMakeLists.txt @@ -48,7 +48,7 @@ add_library(SofaPython3::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_compile_definitions(${PROJECT_NAME} PRIVATE "-DSOFA_BUILD_SOFAPYTHON3") -target_link_libraries(${PROJECT_NAME} PUBLIC SofaCore SofaDefaultType SofaSimulationCore SofaSimulationGraph Sofa.Helper) +target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Core Sofa.DefaultType Sofa.SimulationCore SofaSimulationGraph Sofa.Helper) target_link_libraries(${PROJECT_NAME} PUBLIC pybind11::module pybind11::embed) if(SP3_BUILD_TEST AND Sofa.Testing_FOUND) diff --git a/Plugin/PluginConfig.cmake.in b/Plugin/PluginConfig.cmake.in index 0641dc00d..0febbeaf3 100644 --- a/Plugin/PluginConfig.cmake.in +++ b/Plugin/PluginConfig.cmake.in @@ -1,21 +1,21 @@ -# CMake package configuration file for the @PROJECT_NAME@ module +# CMake package configuration file for @PROJECT_NAME@ + @PACKAGE_GUARD@ @PACKAGE_INIT@ set(SP3_BUILD_TEST @SP3_BUILD_TEST@) -find_package(pybind11 CONFIG REQUIRED) -find_package(SofaFramework REQUIRED) -find_package(SofaSimulationGraph REQUIRED) - +find_package(pybind11 QUIET REQUIRED CONFIG) +find_package(SofaFramework QUIET REQUIRED) +find_package(SofaSimulationGraph QUIET REQUIRED) if(SP3_BUILD_TEST) - find_package(Sofa.Testing REQUIRED) + find_package(Sofa.Testing QUIET REQUIRED) endif() # If we are importing this config file and the target is not yet there this is indicating that # target is an imported one. So we include it if(NOT TARGET @PROJECT_NAME@) - include("${CMAKE_CURRENT_LIST_DIR}/PluginTargets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") endif() # Check that the component/target is there. diff --git a/SofaPython3Config.cmake.in b/SofaPython3Config.cmake.in index e9ff715aa..b8b94de31 100644 --- a/SofaPython3Config.cmake.in +++ b/SofaPython3Config.cmake.in @@ -1,6 +1,5 @@ -# CMake package configuration file for the @PROJECT_NAME@ module +# CMake package configuration file for @PROJECT_NAME@ -@PACKAGE_GUARD@ @PACKAGE_INIT@ set(SP3_WITH_SOFAEXPORTER @SP3_WITH_SOFAEXPORTER@) @@ -10,44 +9,49 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") include(SofaPython3Tools) # Find Python3 -find_package(Python @PYBIND11_PYTHON_VERSION@ COMPONENTS Interpreter Development REQUIRED) +if(NOT Python_FOUND) + find_package(Python @Python_VERSION@ QUIET REQUIRED COMPONENTS Interpreter Development) +endif() -# Save PYTHON_* vars -set(PYTHON_VERSION_RESET "${PYTHON_VERSION}") -set(PYTHON_EXECUTABLE_RESET "${PYTHON_EXECUTABLE}") -set(PYTHON_LIBRARIES_RESET "${PYTHON_LIBRARIES}") -set(PYTHON_INCLUDE_DIRS_RESET "${PYTHON_INCLUDE_DIRS}") -set(PYTHON_LIBRARY_RESET "${PYTHON_LIBRARY}") -set(PYTHON_INCLUDE_DIR_RESET "${PYTHON_INCLUDE_DIR}") +# Find pybind11 +if(NOT pybind11_FOUND) + # Save PYTHON_* vars + set(PYTHON_VERSION_RESET "${PYTHON_VERSION}") + set(PYTHON_EXECUTABLE_RESET "${PYTHON_EXECUTABLE}") + set(PYTHON_LIBRARIES_RESET "${PYTHON_LIBRARIES}") + set(PYTHON_INCLUDE_DIRS_RESET "${PYTHON_INCLUDE_DIRS}") + set(PYTHON_LIBRARY_RESET "${PYTHON_LIBRARY}") + set(PYTHON_INCLUDE_DIR_RESET "${PYTHON_INCLUDE_DIR}") -# Change PYTHON_* vars before pybind11 find_package -# to be sure that pybind11 relies on the right Python version -set(PYTHON_VERSION "${Python_VERSION}" CACHE STRING "" FORCE) -set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}" CACHE FILEPATH "" FORCE) -set(PYTHON_LIBRARIES "${Python_LIBRARIES}" CACHE STRING "" FORCE) -set(PYTHON_INCLUDE_DIRS "${Python_INCLUDE_DIRS}" CACHE STRING "" FORCE) -if(EXISTS "${Python_LIBRARY}") - set(PYTHON_LIBRARY "${Python_LIBRARY}" CACHE INTERNAL "" FORCE) -elseif(EXISTS "${Python_LIBRARIES}") - set(PYTHON_LIBRARY "${Python_LIBRARIES}" CACHE INTERNAL "" FORCE) -endif() -if(EXISTS "${Python_INCLUDE_DIR}") - set(PYTHON_INCLUDE_DIR "${Python_INCLUDE_DIR}" CACHE INTERNAL "" FORCE) -elseif(EXISTS "${Python_INCLUDE_DIRS}") - set(PYTHON_INCLUDE_DIR "${Python_INCLUDE_DIRS}" CACHE INTERNAL "" FORCE) -endif() + # Change PYTHON_* vars before pybind11 find_package + # to be sure that pybind11 relies on the right Python version + set(PYTHON_VERSION "${Python_VERSION}" CACHE STRING "" FORCE) + set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}" CACHE FILEPATH "" FORCE) + set(PYTHON_LIBRARIES "${Python_LIBRARIES}" CACHE STRING "" FORCE) + set(PYTHON_INCLUDE_DIRS "${Python_INCLUDE_DIRS}" CACHE STRING "" FORCE) + if(EXISTS "${Python_LIBRARY}") + set(PYTHON_LIBRARY "${Python_LIBRARY}" CACHE INTERNAL "" FORCE) + elseif(EXISTS "${Python_LIBRARIES}") + set(PYTHON_LIBRARY "${Python_LIBRARIES}" CACHE INTERNAL "" FORCE) + endif() + if(EXISTS "${Python_INCLUDE_DIR}") + set(PYTHON_INCLUDE_DIR "${Python_INCLUDE_DIR}" CACHE INTERNAL "" FORCE) + elseif(EXISTS "${Python_INCLUDE_DIRS}") + set(PYTHON_INCLUDE_DIR "${Python_INCLUDE_DIRS}" CACHE INTERNAL "" FORCE) + endif() -# Set the minimum pybind11 version to 2.3 (before that the pybind11::embed target did not exist) -find_package(pybind11 2.3 CONFIG QUIET REQUIRED) + find_package(pybind11 @pybind11_VERSION@ QUIET REQUIRED CONFIG) -# Reset PYTHON_* vars -set(PYTHON_VERSION "${PYTHON_VERSION_RESET}" CACHE STRING "" FORCE) -set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE_RESET}" CACHE FILEPATH "" FORCE) -set(PYTHON_LIBRARIES "${PYTHON_LIBRARIES_RESET}" CACHE STRING "" FORCE) -set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS_RESET}" CACHE STRING "" FORCE) -set(PYTHON_LIBRARY "${PYTHON_LIBRARY_RESET}" CACHE INTERNAL "" FORCE) -set(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_DIR_RESET}" CACHE INTERNAL "" FORCE) + # Reset PYTHON_* vars + set(PYTHON_VERSION "${PYTHON_VERSION_RESET}" CACHE STRING "" FORCE) + set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE_RESET}" CACHE FILEPATH "" FORCE) + set(PYTHON_LIBRARIES "${PYTHON_LIBRARIES_RESET}" CACHE STRING "" FORCE) + set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS_RESET}" CACHE STRING "" FORCE) + set(PYTHON_LIBRARY "${PYTHON_LIBRARY_RESET}" CACHE INTERNAL "" FORCE) + set(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_DIR_RESET}" CACHE INTERNAL "" FORCE) +endif() +# Find SofaPython3::XXXXX if(NOT SofaPython3_FIND_COMPONENTS) set(SofaPython3_FIND_COMPONENTS Plugin Bindings) endif() diff --git a/bindings/BindingsConfig.cmake.in b/bindings/BindingsConfig.cmake.in index 42e41b64c..d270f1dd7 100644 --- a/bindings/BindingsConfig.cmake.in +++ b/bindings/BindingsConfig.cmake.in @@ -1,45 +1,25 @@ -# CMake package configuration file for the @PROJECT_NAME@ module +# CMake package configuration file for @PROJECT_NAME@ @PACKAGE_GUARD@ @PACKAGE_INIT@ -# Required by all targets -find_package(pybind11 CONFIG REQUIRED) +set(SP3_WITH_SOFAEXPORTER @SP3_WITH_SOFAEXPORTER@) -# Required by Modules.SofaBaseTopology, Sofa.Components, Sofa.Core, Sofa.Helper, Sofa.Types, SofaExporter, SofaGui, SofaRuntime, SofaTypes -find_package(SofaPython3 COMPONENTS Plugin) - -# Required by the bindings Modules.SofaBaseTopology -find_package(SofaBaseTopology REQUIRED) - -# Required by the bindings Modules.SofaDeformable -find_package(SofaDeformable REQUIRED) - -# Required by the bindings Sofa.Components, Sofa.Core, Sofa.Helper, Sofa.Simulation, Sofa.Types, SofaGui -find_package(SofaFramework REQUIRED) - -# Required by the bindings Sofa.Simulation, SofaRuntime -find_package(SofaSimulationGraph REQUIRED) - -# Required by the bindings SofaRuntime -find_package(SofaSimulationCommon REQUIRED) - -# Required by the bindings SofaGui -find_package(Sofa.GL QUIET) -find_package(SofaGui REQUIRED) - -# Required by the bindings Sofa.Core -find_package(SofaBaseVisual REQUIRED) - -# Required by the bindings SofaExporter +find_package(SofaPython3 QUIET REQUIRED COMPONENTS + Bindings.Modules + Bindings.Sofa + Bindings.SofaGui + Bindings.SofaRuntime + Bindings.SofaTypes + ) if(SP3_WITH_SOFAEXPORTER) - find_package(SofaExporter REQUIRED) + find_package(SofaPython3 QUIET REQUIRED COMPONENTS Bindings.SofaExporter) endif() # If we are importing this config file and the target is not yet there this is indicating that # target is an imported one. So we include it if(NOT TARGET @PROJECT_NAME@) - include("${CMAKE_CURRENT_LIST_DIR}/BindingsTargets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") endif() # Check that the component/target is there. diff --git a/bindings/Modules/Bindings.ModulesConfig.cmake.in b/bindings/Modules/Bindings.ModulesConfig.cmake.in new file mode 100644 index 000000000..314a4b35d --- /dev/null +++ b/bindings/Modules/Bindings.ModulesConfig.cmake.in @@ -0,0 +1,20 @@ +# CMake package configuration file for @PROJECT_NAME@ + +@PACKAGE_GUARD@ +@PACKAGE_INIT@ + +find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin Bindings.Sofa) + +# Required by Bindings.Modules.SofaBaseTopology +find_package(SofaBaseTopology QUIET REQUIRED) +# Required by Bindings.Modules.SofaDeformable +find_package(SofaDeformable QUIET REQUIRED) + +# If we are importing this config file and the target is not yet there this is indicating that +# target is an imported one. So we include it +if(NOT TARGET @PROJECT_NAME@) + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +endif() + +# Check that the component/target is there. +check_required_components(@PROJECT_NAME@) diff --git a/bindings/Modules/CMakeLists.txt b/bindings/Modules/CMakeLists.txt index d653248e4..6cf000c9f 100644 --- a/bindings/Modules/CMakeLists.txt +++ b/bindings/Modules/CMakeLists.txt @@ -23,8 +23,13 @@ foreach(modulebindings_module ${MODULEBINDINGS_MODULE_LIST}) set_target_properties(${PROJECT_NAME}.${modulebindings_module} PROPERTIES FOLDER "Bindings/Modules") endforeach() -install(TARGETS ${PROJECT_NAME} EXPORT BindingsTargets) - if(SP3_BUILD_TEST) add_subdirectory(tests) endif() + +sofa_create_component_in_package_with_targets( + COMPONENT_NAME ${PROJECT_NAME} + COMPONENT_VERSION ${SofaPython3_VERSION} + PACKAGE_NAME SofaPython3 + TARGETS ${PROJECT_NAME} + ) diff --git a/bindings/Modules/src/SofaPython3/SofaBaseTopology/CMakeLists.txt b/bindings/Modules/src/SofaPython3/SofaBaseTopology/CMakeLists.txt index b9604287f..a549f5d6e 100644 --- a/bindings/Modules/src/SofaPython3/SofaBaseTopology/CMakeLists.txt +++ b/bindings/Modules/src/SofaPython3/SofaBaseTopology/CMakeLists.txt @@ -17,7 +17,7 @@ find_package(SofaBaseTopology REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings + PACKAGE Bindings.Modules MODULE SofaBaseTopology DESTINATION Sofa SOURCES ${SOURCE_FILES} diff --git a/bindings/Modules/src/SofaPython3/SofaDeformable/CMakeLists.txt b/bindings/Modules/src/SofaPython3/SofaDeformable/CMakeLists.txt index d4f3f54ef..4f4a304f3 100644 --- a/bindings/Modules/src/SofaPython3/SofaDeformable/CMakeLists.txt +++ b/bindings/Modules/src/SofaPython3/SofaDeformable/CMakeLists.txt @@ -14,7 +14,7 @@ set(HEADER_FILES ) if (NOT TARGET SofaPython3::Plugin) - find_package(SofaPython3 REQUIRED) + find_package(SofaPython3 REQUIRED COMPONENTS Plugin Bindings.Sofa) endif() find_package(SofaBase REQUIRED) @@ -22,7 +22,7 @@ find_package(SofaDeformable REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings + PACKAGE Bindings.Modules MODULE SofaDeformable DESTINATION Sofa SOURCES ${SOURCE_FILES} diff --git a/bindings/Modules/src/SofaPython3/SofaGL/CMakeLists.txt b/bindings/Modules/src/SofaPython3/SofaGL/CMakeLists.txt index 2e8ad764c..16eafb236 100644 --- a/bindings/Modules/src/SofaPython3/SofaGL/CMakeLists.txt +++ b/bindings/Modules/src/SofaPython3/SofaGL/CMakeLists.txt @@ -11,14 +11,14 @@ set(HEADER_FILES ) if (NOT TARGET SofaPython3::Plugin) - find_package(SofaPython3 REQUIRED) + find_package(SofaPython3 REQUIRED COMPONENTS Plugin Bindings.Sofa) endif() find_package(Sofa.GL REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings + PACKAGE Bindings.Modules MODULE SofaGL DESTINATION Sofa SOURCES ${SOURCE_FILES} diff --git a/bindings/Sofa/Bindings.SofaConfig.cmake.in b/bindings/Sofa/Bindings.SofaConfig.cmake.in new file mode 100644 index 000000000..dfdffa0d9 --- /dev/null +++ b/bindings/Sofa/Bindings.SofaConfig.cmake.in @@ -0,0 +1,20 @@ +# CMake package configuration file for @PROJECT_NAME@ + +@PACKAGE_GUARD@ +@PACKAGE_INIT@ + +find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin) + +# Required by Bindings.Sofa.Components, Bindings.Sofa.Core, Bindings.Sofa.Helper, Bindings.Sofa.Simulation, Bindings.Sofa.Types, Bindings.SofaGui +find_package(SofaFramework QUIET REQUIRED) +# Required by Bindings.Sofa.Simulation, Bindings.SofaRuntime +find_package(SofaSimulationGraph QUIET REQUIRED) + +# If we are importing this config file and the target is not yet there this is indicating that +# target is an imported one. So we include it +if(NOT TARGET @PROJECT_NAME@) + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +endif() + +# Check that the component/target is there. +check_required_components(@PROJECT_NAME@) diff --git a/bindings/Sofa/CMakeLists.txt b/bindings/Sofa/CMakeLists.txt index 371c13d15..9bfab5b51 100644 --- a/bindings/Sofa/CMakeLists.txt +++ b/bindings/Sofa/CMakeLists.txt @@ -26,8 +26,13 @@ foreach(sofabindings_module ${SOFABINDINGS_MODULE_LIST}) target_link_libraries(${PROJECT_NAME} INTERFACE ${PROJECT_NAME}.${sofabindings_module}) endforeach() -install(TARGETS ${PROJECT_NAME} EXPORT BindingsTargets) - if(SP3_BUILD_TEST) add_subdirectory(tests) endif() + +sofa_create_component_in_package_with_targets( + COMPONENT_NAME ${PROJECT_NAME} + COMPONENT_VERSION ${SofaPython3_VERSION} + PACKAGE_NAME SofaPython3 + TARGETS ${PROJECT_NAME} + ) diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Components/CMakeLists.txt b/bindings/Sofa/src/SofaPython3/Sofa/Components/CMakeLists.txt index cfb3d04ba..755c179dc 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Components/CMakeLists.txt +++ b/bindings/Sofa/src/SofaPython3/Sofa/Components/CMakeLists.txt @@ -12,7 +12,7 @@ find_package(SofaFramework REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings + PACKAGE Bindings.Sofa MODULE Components DESTINATION Sofa SOURCES ${SOURCE_FILES} diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt b/bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt index 2019180d1..6920bf831 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt +++ b/bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt @@ -70,7 +70,7 @@ set(SOURCE_FILES ) if (NOT TARGET SofaPython3::Plugin) - find_package(SofaPython3 REQUIRED) + find_package(SofaPython3 REQUIRED COMPONENTS Plugin) endif() find_package(SofaFramework REQUIRED) @@ -80,7 +80,7 @@ find_package(SofaBaseUtils REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings + PACKAGE Bindings.Sofa MODULE Core DESTINATION Sofa SOURCES ${SOURCE_FILES} diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt b/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt index a0350531f..d4e108b3e 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt +++ b/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt @@ -19,7 +19,7 @@ find_package(SofaFramework REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings + PACKAGE Bindings.Sofa MODULE Helper DESTINATION Sofa SOURCES ${SOURCE_FILES} diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Simulation/CMakeLists.txt b/bindings/Sofa/src/SofaPython3/Sofa/Simulation/CMakeLists.txt index f15f819e6..91550974e 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Simulation/CMakeLists.txt +++ b/bindings/Sofa/src/SofaPython3/Sofa/Simulation/CMakeLists.txt @@ -9,7 +9,7 @@ set(SOURCE_FILES ) if (NOT TARGET SofaPython3::Plugin) - find_package(SofaPython3 REQUIRED) + find_package(SofaPython3 REQUIRED COMPONENTS Plugin) endif() find_package(SofaFramework REQUIRED) @@ -17,10 +17,10 @@ find_package(SofaSimulationGraph REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings + PACKAGE Bindings.Sofa MODULE Simulation DESTINATION Sofa SOURCES ${SOURCE_FILES} HEADERS ${HEADER_FILES} - DEPENDS SofaCore SofaSimulationCore SofaSimulationGraph SofaPython3::Plugin + DEPENDS Sofa.Core Sofa.SimulationCore SofaSimulationGraph SofaPython3::Plugin ) diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Types/CMakeLists.txt b/bindings/Sofa/src/SofaPython3/Sofa/Types/CMakeLists.txt index f3edb6261..2331a4f60 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Types/CMakeLists.txt +++ b/bindings/Sofa/src/SofaPython3/Sofa/Types/CMakeLists.txt @@ -13,10 +13,10 @@ find_package(SofaFramework REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings + PACKAGE Bindings.Sofa MODULE Types DESTINATION Sofa SOURCES ${SOURCE_FILES} HEADERS ${HEADER_FILES} - DEPENDS SofaCore SofaDefaultType SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core -) \ No newline at end of file + DEPENDS Sofa.Core Sofa.DefaultType SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core +) diff --git a/bindings/SofaExporter/Bindings.SofaExporterConfig.cmake.in b/bindings/SofaExporter/Bindings.SofaExporterConfig.cmake.in new file mode 100644 index 000000000..d37d4146d --- /dev/null +++ b/bindings/SofaExporter/Bindings.SofaExporterConfig.cmake.in @@ -0,0 +1,17 @@ +# CMake package configuration file for @PROJECT_NAME@ + +@PACKAGE_GUARD@ +@PACKAGE_INIT@ + +find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin Bindings.Sofa) + +find_package(SofaExporter QUIET REQUIRED) + +# If we are importing this config file and the target is not yet there this is indicating that +# target is an imported one. So we include it +if(NOT TARGET @PROJECT_NAME@) + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +endif() + +# Check that the component/target is there. +check_required_components(@PROJECT_NAME@) diff --git a/bindings/SofaExporter/CMakeLists.txt b/bindings/SofaExporter/CMakeLists.txt index 77e1dc056..880491275 100644 --- a/bindings/SofaExporter/CMakeLists.txt +++ b/bindings/SofaExporter/CMakeLists.txt @@ -17,9 +17,16 @@ find_package(SofaExporter REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings MODULE SofaExporter + DESTINATION . SOURCES ${SOURCE_FILES} HEADERS ${HEADER_FILES} DEPENDS SofaExporter SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core -) \ No newline at end of file +) + +sofa_create_component_in_package_with_targets( + COMPONENT_NAME ${PROJECT_NAME} + COMPONENT_VERSION ${SofaPython3_VERSION} + PACKAGE_NAME SofaPython3 + TARGETS ${PROJECT_NAME} + ) diff --git a/bindings/SofaGui/Bindings.SofaGuiConfig.cmake.in b/bindings/SofaGui/Bindings.SofaGuiConfig.cmake.in new file mode 100644 index 000000000..72c979df2 --- /dev/null +++ b/bindings/SofaGui/Bindings.SofaGuiConfig.cmake.in @@ -0,0 +1,20 @@ +# CMake package configuration file for @PROJECT_NAME@ + +@PACKAGE_GUARD@ +@PACKAGE_INIT@ + +find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin Bindings.Sofa) + +find_package(Sofa.GL QUIET REQUIRED) +find_package(Sofa.Core QUIET REQUIRED) +find_package(SofaGuiCommon QUIET REQUIRED) +find_package(SofaGui QUIET REQUIRED) + +# If we are importing this config file and the target is not yet there this is indicating that +# target is an imported one. So we include it +if(NOT TARGET @PROJECT_NAME@) + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +endif() + +# Check that the component/target is there. +check_required_components(@PROJECT_NAME@) diff --git a/bindings/SofaGui/CMakeLists.txt b/bindings/SofaGui/CMakeLists.txt index 7b3865d32..1ae3d8093 100644 --- a/bindings/SofaGui/CMakeLists.txt +++ b/bindings/SofaGui/CMakeLists.txt @@ -17,10 +17,16 @@ find_package(SofaFramework REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings MODULE Gui DESTINATION Sofa SOURCES ${SOURCE_FILES} HEADERS ${HEADER_FILES} - DEPENDS SofaCore SofaGuiCommon SofaGui SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core + DEPENDS Sofa.Core SofaGuiCommon SofaGui SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core ) + +sofa_create_component_in_package_with_targets( + COMPONENT_NAME ${PROJECT_NAME} + COMPONENT_VERSION ${SofaPython3_VERSION} + PACKAGE_NAME SofaPython3 + TARGETS ${PROJECT_NAME} + ) diff --git a/bindings/SofaRuntime/Bindings.SofaRuntimeConfig.cmake.in b/bindings/SofaRuntime/Bindings.SofaRuntimeConfig.cmake.in new file mode 100644 index 000000000..cff20baf4 --- /dev/null +++ b/bindings/SofaRuntime/Bindings.SofaRuntimeConfig.cmake.in @@ -0,0 +1,18 @@ +# CMake package configuration file for @PROJECT_NAME@ + +@PACKAGE_GUARD@ +@PACKAGE_INIT@ + +find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin Bindings.Sofa) + +find_package(SofaSimulationGraph QUIET REQUIRED) +find_package(SofaSimulationCommon QUIET REQUIRED) + +# If we are importing this config file and the target is not yet there this is indicating that +# target is an imported one. So we include it +if(NOT TARGET @PROJECT_NAME@) + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +endif() + +# Check that the component/target is there. +check_required_components(@PROJECT_NAME@) diff --git a/bindings/SofaRuntime/CMakeLists.txt b/bindings/SofaRuntime/CMakeLists.txt index dc894ec39..587d52f14 100644 --- a/bindings/SofaRuntime/CMakeLists.txt +++ b/bindings/SofaRuntime/CMakeLists.txt @@ -22,7 +22,6 @@ SP3_add_python_package( SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings MODULE SofaRuntime DESTINATION SofaRuntime SOURCES ${SOURCE_FILES} @@ -30,6 +29,13 @@ SP3_add_python_module( DEPENDS Sofa.Core Sofa.Helper Sofa.SimulationCore SofaSimulationGraph SofaSimulationCommon SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core ) +sofa_create_component_in_package_with_targets( + COMPONENT_NAME ${PROJECT_NAME} + COMPONENT_VERSION ${SofaPython3_VERSION} + PACKAGE_NAME SofaPython3 + TARGETS ${PROJECT_NAME} + ) + if(SP3_BUILD_TEST) add_subdirectory(tests) endif() diff --git a/bindings/SofaTypes/Bindings.SofaTypesConfig.cmake.in b/bindings/SofaTypes/Bindings.SofaTypesConfig.cmake.in new file mode 100644 index 000000000..b602a2841 --- /dev/null +++ b/bindings/SofaTypes/Bindings.SofaTypesConfig.cmake.in @@ -0,0 +1,15 @@ +# CMake package configuration file for @PROJECT_NAME@ + +@PACKAGE_GUARD@ +@PACKAGE_INIT@ + +find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin Bindings.Sofa) + +# If we are importing this config file and the target is not yet there this is indicating that +# target is an imported one. So we include it +if(NOT TARGET @PROJECT_NAME@) + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +endif() + +# Check that the component/target is there. +check_required_components(@PROJECT_NAME@) diff --git a/bindings/SofaTypes/CMakeLists.txt b/bindings/SofaTypes/CMakeLists.txt index 452a5a46b..a7cc1cbe7 100644 --- a/bindings/SofaTypes/CMakeLists.txt +++ b/bindings/SofaTypes/CMakeLists.txt @@ -24,14 +24,20 @@ find_package(SofaFramework REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings MODULE SofaTypes DESTINATION SofaTypes SOURCES ${SOURCE_FILES} HEADERS ${HEADER_FILES} - DEPENDS SofaDefaultType SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core + DEPENDS Sofa.DefaultType SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core ) +sofa_create_component_in_package_with_targets( + COMPONENT_NAME ${PROJECT_NAME} + COMPONENT_VERSION ${SofaPython3_VERSION} + PACKAGE_NAME SofaPython3 + TARGETS ${PROJECT_NAME} + ) + if(SP3_BUILD_TEST) add_subdirectory(tests) endif()