From 5c778cba02a96eda5012404f5b7a5d0aa118fd54 Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Mon, 14 Jul 2025 16:19:41 +0900 Subject: [PATCH 1/4] Dont search for python and pybind11 if already found previously --- SofaPython3Config.cmake.in | 8 ++++---- bindings/BindingsConfig.cmake.in | 6 ++++-- bindings/Modules/Bindings.ModulesConfig.cmake.in | 9 +++++---- bindings/Sofa/Bindings.SofaConfig.cmake.in | 16 +++++++++------- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/SofaPython3Config.cmake.in b/SofaPython3Config.cmake.in index 2c3410a46..1aa3d609c 100644 --- a/SofaPython3Config.cmake.in +++ b/SofaPython3Config.cmake.in @@ -9,12 +9,12 @@ 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) + find_package(Python @PythonMAJMIN@ EXACT QUIET REQUIRED COMPONENTS Interpreter Development GLOBAL) 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 +40,7 @@ if(NOT pybind11_FOUND) set(PYTHON_INCLUDE_DIR "${Python_INCLUDE_DIRS}" CACHE INTERNAL "" FORCE) endif() - find_package(pybind11 @pybind11_VERSION@ QUIET REQUIRED CONFIG) + find_package(pybind11 @pybind11_VERSION@ QUIET REQUIRED CONFIG GLOBAL) # 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..81ab72538 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) +sofa_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 From 0c8ff089a193617e0cf3c05cbe54be774346c25f Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Tue, 15 Jul 2025 16:19:58 +0900 Subject: [PATCH 2/4] remove unsupported keyword Global (need cmake 3.24) --- SofaPython3Config.cmake.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SofaPython3Config.cmake.in b/SofaPython3Config.cmake.in index 1aa3d609c..8f325a5db 100644 --- a/SofaPython3Config.cmake.in +++ b/SofaPython3Config.cmake.in @@ -10,7 +10,7 @@ include(SofaPython3Tools) # Find Python3 if(NOT TARGET Python::Python) - find_package(Python @PythonMAJMIN@ EXACT QUIET REQUIRED COMPONENTS Interpreter Development GLOBAL) + find_package(Python @PythonMAJMIN@ EXACT QUIET REQUIRED COMPONENTS Interpreter Development) endif() # Find pybind11 @@ -40,7 +40,7 @@ if(NOT TARGET pybind11) set(PYTHON_INCLUDE_DIR "${Python_INCLUDE_DIRS}" CACHE INTERNAL "" FORCE) endif() - find_package(pybind11 @pybind11_VERSION@ QUIET REQUIRED CONFIG GLOBAL) + find_package(pybind11 @pybind11_VERSION@ QUIET REQUIRED CONFIG) # Reset PYTHON_* vars set(PYTHON_VERSION "${PYTHON_VERSION_RESET}" CACHE STRING "" FORCE) From 0f50e21739d4473b8142b7b875f6a618c850861c Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Tue, 15 Jul 2025 16:30:47 +0900 Subject: [PATCH 3/4] restore global keyword while testing cmake version --- SofaPython3Config.cmake.in | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/SofaPython3Config.cmake.in b/SofaPython3Config.cmake.in index 8f325a5db..52669ce6a 100644 --- a/SofaPython3Config.cmake.in +++ b/SofaPython3Config.cmake.in @@ -10,7 +10,11 @@ include(SofaPython3Tools) # Find Python3 if(NOT TARGET Python::Python) - find_package(Python @PythonMAJMIN@ EXACT QUIET REQUIRED COMPONENTS Interpreter Development) + 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 @@ -40,7 +44,11 @@ if(NOT TARGET pybind11) 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) From 9ef13d215c14e14a67f192c073a790a6590987c0 Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Wed, 23 Jul 2025 16:54:03 +0900 Subject: [PATCH 4/4] Update Bindings.SofaConfig.cmake.in --- bindings/Sofa/Bindings.SofaConfig.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/Sofa/Bindings.SofaConfig.cmake.in b/bindings/Sofa/Bindings.SofaConfig.cmake.in index 81ab72538..42f003bce 100644 --- a/bindings/Sofa/Bindings.SofaConfig.cmake.in +++ b/bindings/Sofa/Bindings.SofaConfig.cmake.in @@ -3,7 +3,7 @@ @PACKAGE_GUARD@ @PACKAGE_INIT@ -sofa_find_package(Sofa.Config QUIET REQUIRED) +find_package(Sofa.Config QUIET REQUIRED) sofa_find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin)