diff --git a/SofaPython3Config.cmake.in b/SofaPython3Config.cmake.in index 2c3410a46..52669ce6a 100644 --- a/SofaPython3Config.cmake.in +++ b/SofaPython3Config.cmake.in @@ -9,12 +9,16 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") include(SofaPython3Tools) # Find Python3 -if(NOT Python_FOUND) - find_package(Python @PythonMAJMIN@ EXACT QUIET REQUIRED COMPONENTS Interpreter Development) +if(NOT TARGET Python::Python) + if(CMAKE_VERSION VERSION_LESS "3.24.0") + find_package(Python @PythonMAJMIN@ EXACT QUIET REQUIRED COMPONENTS Interpreter Development) + else() + find_package(Python @PythonMAJMIN@ EXACT QUIET REQUIRED COMPONENTS Interpreter Development GLOBAL) + endif() endif() # Find pybind11 -if(NOT pybind11_FOUND) +if(NOT TARGET pybind11) # Save PYTHON_* vars set(PYTHON_VERSION_RESET "${PYTHON_VERSION}") set(PYTHON_EXECUTABLE_RESET "${PYTHON_EXECUTABLE}") @@ -40,7 +44,11 @@ if(NOT pybind11_FOUND) set(PYTHON_INCLUDE_DIR "${Python_INCLUDE_DIRS}" CACHE INTERNAL "" FORCE) endif() - find_package(pybind11 @pybind11_VERSION@ QUIET REQUIRED CONFIG) + if(CMAKE_VERSION VERSION_LESS "3.24.0") + find_package(pybind11 @pybind11_VERSION@ QUIET REQUIRED CONFIG) + else() + find_package(pybind11 @pybind11_VERSION@ QUIET REQUIRED CONFIG GLOBAL) + endif() # Reset PYTHON_* vars set(PYTHON_VERSION "${PYTHON_VERSION_RESET}" CACHE STRING "" FORCE) diff --git a/bindings/BindingsConfig.cmake.in b/bindings/BindingsConfig.cmake.in index d270f1dd7..1c73cc1f2 100644 --- a/bindings/BindingsConfig.cmake.in +++ b/bindings/BindingsConfig.cmake.in @@ -5,7 +5,9 @@ set(SP3_WITH_SOFAEXPORTER @SP3_WITH_SOFAEXPORTER@) -find_package(SofaPython3 QUIET REQUIRED COMPONENTS +find_package(Sofa.Config QUIET REQUIRED) + +sofa_find_package(SofaPython3 QUIET REQUIRED COMPONENTS Bindings.Modules Bindings.Sofa Bindings.SofaGui @@ -13,7 +15,7 @@ find_package(SofaPython3 QUIET REQUIRED COMPONENTS Bindings.SofaTypes ) if(SP3_WITH_SOFAEXPORTER) - find_package(SofaPython3 QUIET REQUIRED COMPONENTS Bindings.SofaExporter) + sofa_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 diff --git a/bindings/Modules/Bindings.ModulesConfig.cmake.in b/bindings/Modules/Bindings.ModulesConfig.cmake.in index 197bba2cf..1f281c241 100644 --- a/bindings/Modules/Bindings.ModulesConfig.cmake.in +++ b/bindings/Modules/Bindings.ModulesConfig.cmake.in @@ -3,16 +3,17 @@ @PACKAGE_GUARD@ @PACKAGE_INIT@ -find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin Bindings.Sofa) +find_package(Sofa.Config QUIET REQUIRED) +sofa_find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin Bindings.Sofa) # Required by Bindings.Modules.SofaBaseTopology -find_package(Sofa.Component.Topology.Container.Grid QUIET REQUIRED) +sofa_find_package(Sofa.Component.Topology.Container.Grid QUIET REQUIRED) # Required by Bindings.Modules.SofaDeformable -find_package(Sofa.Component.SolidMechanics.Spring QUIET REQUIRED) +sofa_find_package(Sofa.Component.SolidMechanics.Spring QUIET REQUIRED) # Required by Bindings.Modules.SofaLinearSolver -find_package(Sofa.Component.LinearSolver.Iterative QUIET REQUIRED) +sofa_find_package(Sofa.Component.LinearSolver.Iterative 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 diff --git a/bindings/Sofa/Bindings.SofaConfig.cmake.in b/bindings/Sofa/Bindings.SofaConfig.cmake.in index f38f9849e..42f003bce 100644 --- a/bindings/Sofa/Bindings.SofaConfig.cmake.in +++ b/bindings/Sofa/Bindings.SofaConfig.cmake.in @@ -3,21 +3,23 @@ @PACKAGE_GUARD@ @PACKAGE_INIT@ -find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin) +find_package(Sofa.Config QUIET REQUIRED) + +sofa_find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin) # Required by Bindings.Sofa.Helper, Bindings.Sofa.Types -find_package(Sofa.Core QUIET REQUIRED) +sofa_find_package(Sofa.Core QUIET REQUIRED) # Required by Bindings.Sofa.Core -find_package(Sofa.Simulation.Core QUIET REQUIRED) +sofa_find_package(Sofa.Simulation.Core QUIET REQUIRED) # Required by Bindings.Sofa.Core -find_package(Sofa.Component.Visual QUIET REQUIRED) -find_package(Sofa.Component.Collision.Response.Contact QUIET REQUIRED) -find_package(Sofa.SimpleApi QUIET REQUIRED) +sofa_find_package(Sofa.Component.Visual QUIET REQUIRED) +sofa_find_package(Sofa.Component.Collision.Response.Contact QUIET REQUIRED) +sofa_find_package(Sofa.SimpleApi QUIET REQUIRED) # Required by Bindings.Sofa.Simulation -find_package(Sofa.Simulation.Graph QUIET REQUIRED) +sofa_find_package(Sofa.Simulation.Graph 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