Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMake/SofaPython3Tools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion Plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions Plugin/PluginConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
74 changes: 39 additions & 35 deletions SofaPython3Config.cmake.in
Original file line number Diff line number Diff line change
@@ -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@)
Expand All @@ -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()
Expand Down
42 changes: 11 additions & 31 deletions bindings/BindingsConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
20 changes: 20 additions & 0 deletions bindings/Modules/Bindings.ModulesConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -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@)
9 changes: 7 additions & 2 deletions bindings/Modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ 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)
find_package(SofaDeformable REQUIRED)

SP3_add_python_module(
TARGET ${PROJECT_NAME}
PACKAGE Bindings
PACKAGE Bindings.Modules
MODULE SofaDeformable
DESTINATION Sofa
SOURCES ${SOURCE_FILES}
Expand Down
4 changes: 2 additions & 2 deletions bindings/Modules/src/SofaPython3/SofaGL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
20 changes: 20 additions & 0 deletions bindings/Sofa/Bindings.SofaConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -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@)
9 changes: 7 additions & 2 deletions bindings/Sofa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
6 changes: 3 additions & 3 deletions bindings/Sofa/src/SofaPython3/Sofa/Simulation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ set(SOURCE_FILES
)

if (NOT TARGET SofaPython3::Plugin)
find_package(SofaPython3 REQUIRED)
find_package(SofaPython3 REQUIRED COMPONENTS Plugin)
endif()

find_package(SofaFramework REQUIRED)
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
)
6 changes: 3 additions & 3 deletions bindings/Sofa/src/SofaPython3/Sofa/Types/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
DEPENDS Sofa.Core Sofa.DefaultType SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core
)
Loading