Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SofaMacros] Handle COMPONENTS (needed by SofaPython3) #1671

Merged
merged 7 commits into from
Jan 14, 2021

Conversation

guparan
Copy link
Contributor

@guparan guparan commented Dec 17, 2020

Allow a 3-level organization: Package > Component > Target

Example with SofaPython3 (PR to come in SofaPython3 repo)

You want to do:

find_package(SofaPython3 COMPONENTS Bindings)

To do that, you must use these macros in your project:

    # In SofaPython3/CMakeLists.txt
    # Create a Package without Target to contain the Components
    sofa_create_package(
        PACKAGE_NAME SofaPython3
        PACKAGE_VERSION ${PROJECT_VERSION}
        RELOCATABLE "plugins"
        )
    # In SofaPython3/Bindings/CMakeLists.txt
    # Create a Component with Targets into that Package
    sofa_create_component_in_package_with_targets(
        COMPONENT_NAME Bindings
        COMPONENT_VERSION ${SofaPython3_VERSION}
        PACKAGE_NAME SofaPython3
        TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
        INCLUDE_SOURCE_DIR "src"
        INCLUDE_INSTALL_DIR "."
        RELOCATABLE ".."
        )

By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@guparan guparan added pr: status to review To notify reviewers to review this pull-request pr: clean Cleaning the code pr: new feature Implement a new feature labels Dec 17, 2020
@jnbrunet
Copy link
Contributor

jnbrunet commented Jan 7, 2021

Hey @guparan ,

Thanks a lot for this. I've tested it very quickly. In order to use this for SofaPython3, we would need to be able to specify where to install some targets and files relative to the install prefix. For example, the binding libraries should be installed in lib/python3/site-packages/...

Here is the installation tree that we would need for SofaPython3:

.
├── bin
│   ├── Bindings.Modules.Tests
│   ├── Bindings.SofaRuntime.Tests
│   ├── Bindings.Sofa.Tests
│   ├── Bindings.SofaTypes.Tests
│   ├── Components
│   │   └── Components.py
│   ├── Core
│   │   ├── BaseData.py
│   │   ├── BaseLink.py
│   │   ├── BaseObject.py
│   │   ├── Base.py
│   │   ├── Controller.py
│   │   ├── DataEngine.py
│   │   ├── ForceField.py
│   │   ├── ForceField.py.orig
│   │   ├── MyRestShapeForceField.py
│   │   └── PythonRestShapeForceField.py
│   ├── Helper
│   │   ├── FileRepository.py
│   │   └── Message.py
│   ├── pyfiles
│   │   └── vector_test.py
│   ├── Simulation
│   │   ├── Node.py
│   │   └── Simulation.py
│   ├── SofaDeformable
│   │   ├── LinearSpring.py
│   │   └── SpringForceField.py
│   ├── tests
│   │   └── Base.py
│   └── Types
│       ├── BoundingBox.py
│       ├── RGBAColor.py
│       └── Vec3.py
├── include
│   └── SofaPython3
│       ├── config.h
│       ├── DataCache.h
│       ├── DataHelper.h
│       ├── initModule.h
│       ├── Prefab.h
│       ├── PythonEnvironment.h
│       ├── PythonFactory.h
│       ├── PythonTestExtractor.h
│       ├── PythonTest.h
│       ├── SceneLoaderPY3.h
│       ├── Sofa
│       │   ├── Components
│       │   │   └── Submodule_Components.h
│       │   ├── Core
│       │   │   ├── Binding_BaseCamera_doc.h
│       │   │   ├── Binding_BaseCamera.h
│       │   │   ├── Binding_BaseContext.h
│       │   │   ├── Binding_BaseData_doc.h
│       │   │   ├── Binding_BaseData.h
│       │   │   ├── Binding_Base_doc.h
│       │   │   ├── Binding_Base.h
│       │   │   ├── Binding_BaseLink_doc.h
│       │   │   ├── Binding_BaseLink.h
│       │   │   ├── Binding_BaseObject_doc.h
│       │   │   ├── Binding_BaseObject.h
│       │   │   ├── Binding_ContactListener_doc.h
│       │   │   ├── Binding_ContactListener.h
│       │   │   ├── Binding_Context.h
│       │   │   ├── Binding_Controller_doc.h
│       │   │   ├── Binding_Controller.h
│       │   │   ├── Binding_DataDict_doc.h
│       │   │   ├── Binding_DataDict.h
│       │   │   ├── Binding_DataEngine_doc.h
│       │   │   ├── Binding_DataEngine.h
│       │   │   ├── Binding_ForceField_doc.h
│       │   │   ├── Binding_ForceField.h
│       │   │   ├── Binding_Node_doc.h
│       │   │   ├── Binding_Node.h
│       │   │   ├── Binding_NodeIterator.h
│       │   │   ├── Binding_ObjectFactory_doc.h
│       │   │   ├── Binding_ObjectFactory.h
│       │   │   ├── Binding_Prefab_doc.h
│       │   │   ├── Binding_Prefab.h
│       │   │   ├── Binding_PythonScriptEvent.h
│       │   │   └── Data
│       │   │       ├── Binding_DataContainer_doc.h
│       │   │       ├── Binding_DataContainer.h
│       │   │       ├── Binding_DataLink.h
│       │   │       ├── Binding_DataString_doc.h
│       │   │       ├── Binding_DataString.h
│       │   │       ├── Binding_DataVectorString_doc.h
│       │   │       └── Binding_DataVectorString.h
│       │   ├── Helper
│       │   │   ├── Binding_MessageHandler.h
│       │   │   ├── Binding_Vector.h
│       │   │   └── System
│       │   │       ├── Binding_FileRepository.h
│       │   │       └── Submodule_System.h
│       │   ├── Simulation
│       │   │   └── Submodule_Simulation_doc.h
│       │   └── Types
│       │       └── Binding_BoundingBox.h
│       ├── SofaBaseTopology
│       │   ├── Binding_RegularGridTopology_doc.h
│       │   ├── Binding_RegularGridTopology.h
│       │   ├── Binding_SparseGridTopology_doc.h
│       │   └── Binding_SparseGridTopology.h
│       ├── SofaDeformable
│       │   ├── Binding_LinearSpring_doc.h
│       │   ├── Binding_LinearSpring.h
│       │   ├── Binding_SpringForceField_doc.h
│       │   └── Binding_SpringForceField.h
│       ├── SofaGui
│       │   ├── Binding_BaseGui.h
│       │   └── Binding_GUIManager.h
│       ├── SofaRuntime
│       │   └── Timer
│       │       ├── Submodule_Timer_doc.h
│       │       └── Submodule_Timer.h
│       └── SofaTypes
│           ├── Binding_Mat.h
│           ├── Binding_Quat.h
│           └── Binding_Vec.h
├── lib
│   ├── cmake
│   │   └── SofaPython3
│   │       ├── BindingsConfig.cmake
│   │       ├── BindingsTargets.cmake
│   │       ├── BindingsTargets-debug.cmake
│   │       ├── PluginConfig.cmake
│   │       ├── PluginTargets.cmake
│   │       ├── PluginTargets-debug.cmake
│   │       ├── SofaPython3Config.cmake
│   │       └── SofaPython3ConfigVersion.cmake
│   ├── libSofaPython3.so
│   └── python3
│       └── site-packages
│           ├── Sofa
│           │   ├── Components.cpython-39-x86_64-linux-gnu.so
│           │   ├── constants
│           │   │   ├── __init__.py
│           │   │   ├── KeyCode.py
│           │   │   └── Key.py
│           │   ├── Core.cpython-39-x86_64-linux-gnu.so
│           │   ├── Gui.cpython-39-x86_64-linux-gnu.so
│           │   ├── Helper.cpython-39-x86_64-linux-gnu.so
│           │   ├── __init__.py
│           │   ├── livecoding.py
│           │   ├── prefab.py
│           │   ├── PyTypes
│           │   │   ├── __init__.py
│           │   │   ├── RGBAColor.py
│           │   │   └── Vec3.py
│           │   ├── Simulation.cpython-39-x86_64-linux-gnu.so
│           │   ├── SofaBaseTopology.cpython-39-x86_64-linux-gnu.so
│           │   ├── SofaDeformable.cpython-39-x86_64-linux-gnu.so
│           │   ├── test.py
│           │   └── Types.cpython-39-x86_64-linux-gnu.so
│           ├── SofaRuntime
│           │   ├── __init__.py
│           │   └── SofaRuntime.cpython-39-x86_64-linux-gnu.so
│           ├── SofaTypes
│           │   ├── __init__.py
│           │   └── SofaTypes.cpython-39-x86_64-linux-gnu.so
│           └── splib
│               ├── animation
│               │   ├── animate.py
│               │   ├── easing.py
│               │   └── __init__.py
│               ├── caching
│               │   ├── cacher.py
│               │   └── __init__.py
│               ├── __init__.py
│               └── meshing
│                   ├── cgal_sofa.py
│                   ├── data
│                   │   └── meshes
│                   │       ├── gallbladder.stl
│                   │       ├── parametric_mesh_example.step
│                   │       └── surface_mesh_example.stl
│                   ├── gmsh_sofa.py
│                   ├── __init__.py
│                   └── pygalmesh_sofa.py
└── share
    └── SofaPython3
        ├── documentation
        │   ├── Contributing.rst
        │   ├── CustomModule.rst
        │   ├── index.rst
        │   ├── install.rst
        │   ├── SofaModule.rst
        │   └── SofaPlugin.rst
        └── examples
            ├── backend_pygame.py
            ├── BaseCamera.py
            ├── CMakeLists.txt
            ├── ControllerScene.py
            ├── easingSceneMatplotlib.py
            ├── easingScene.py
            ├── emptyController.py
            ├── emptyDataEngine.py
            ├── emptyForceField.py
            ├── example-forcefield2.py
            ├── example-forcefield.py
            ├── example.pyscn
            ├── example-scriptcontroller.py
            ├── keyEvents.py
            ├── pygame_test.py
            ├── ReadTheDocs_Example.py
            ├── realTimeClockScene.py
            ├── SofaGui.py
            └── test.scn

@guparan
Copy link
Contributor Author

guparan commented Jan 11, 2021

@jnbrunet Thanks for the explicit install tree, just what I needed 👍
sofa-framework/SofaPython3#83 should bring us that.

@guparan
Copy link
Contributor Author

guparan commented Jan 11, 2021

I messed up this branch... Let me fix that.
EDIT: done.

Allow a 3-level organization: Package > Component > Target

Example of SofaPython3:
You want to do: find_package(SofaPython3 COMPONENTS Bindings)
To do that, you must use these macros in your project:
    # In SofaPython3/CMakeLists.txt
    # Create a Package (without Target) to contain the Components
    sofa_create_package(
        PACKAGE_NAME SofaPython3
        PACKAGE_VERSION ${PROJECT_VERSION}
        RELOCATABLE "plugins"
        )
    # In SofaPython3/Bindings/CMakeLists.txt
    # Create a Component (with Targets) into that Package
    sofa_create_component_in_package_with_targets(
        COMPONENT_NAME Bindings
        COMPONENT_VERSION ${SofaPython3_VERSION}
        PACKAGE_NAME SofaPython3
        TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
        INCLUDE_SOURCE_DIR "src"
        INCLUDE_INSTALL_DIR "."
        RELOCATABLE ".."
        )
@jnbrunet jnbrunet added pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels Jan 14, 2021
@jnbrunet jnbrunet merged commit ce22d38 into sofa-framework:master Jan 14, 2021
jnbrunet pushed a commit that referenced this pull request Jan 14, 2021
* [CMake] Allow SofaPython3 build alongside SofaPython

with SOFA_BUILD_TESTS=ON

* [SofaMacros] ADD macros for COMPONENT handling

Allow a 3-level organization: Package > Component > Target

Example of SofaPython3:
You want to do: find_package(SofaPython3 COMPONENTS Bindings)
To do that, you must use these macros in your project:
    # In SofaPython3/CMakeLists.txt
    # Create a Package (without Target) to contain the Components
    sofa_create_package(
        PACKAGE_NAME SofaPython3
        PACKAGE_VERSION ${PROJECT_VERSION}
        RELOCATABLE "plugins"
        )
    # In SofaPython3/Bindings/CMakeLists.txt
    # Create a Component (with Targets) into that Package
    sofa_create_component_in_package_with_targets(
        COMPONENT_NAME Bindings
        COMPONENT_VERSION ${SofaPython3_VERSION}
        PACKAGE_NAME SofaPython3
        TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
        INCLUDE_SOURCE_DIR "src"
        INCLUDE_INSTALL_DIR "."
        RELOCATABLE ".."
        )

* [SofaMacros] Add comments and clean new macros

* [plugins] FIX SofaPython3 order

* [SofaMacros] Allow to skip the "optimize build dir" step

* [SofaMacros] FIX missing dot-to-underscore replacement
@guparan guparan added this to the v20.12 milestone Jan 18, 2021
fredroy pushed a commit to fredroy/sofa that referenced this pull request Jan 21, 2021
…k#1671)

* [CMake] Allow SofaPython3 build alongside SofaPython

with SOFA_BUILD_TESTS=ON

* [SofaMacros] ADD macros for COMPONENT handling

Allow a 3-level organization: Package > Component > Target

Example of SofaPython3:
You want to do: find_package(SofaPython3 COMPONENTS Bindings)
To do that, you must use these macros in your project:
    # In SofaPython3/CMakeLists.txt
    # Create a Package (without Target) to contain the Components
    sofa_create_package(
        PACKAGE_NAME SofaPython3
        PACKAGE_VERSION ${PROJECT_VERSION}
        RELOCATABLE "plugins"
        )
    # In SofaPython3/Bindings/CMakeLists.txt
    # Create a Component (with Targets) into that Package
    sofa_create_component_in_package_with_targets(
        COMPONENT_NAME Bindings
        COMPONENT_VERSION ${SofaPython3_VERSION}
        PACKAGE_NAME SofaPython3
        TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
        INCLUDE_SOURCE_DIR "src"
        INCLUDE_INSTALL_DIR "."
        RELOCATABLE ".."
        )

* [SofaMacros] Add comments and clean new macros

* [plugins] FIX SofaPython3 order

* [SofaMacros] Allow to skip the "optimize build dir" step

* [SofaMacros] FIX missing dot-to-underscore replacement
@guparan guparan deleted the sofamacros_for_sofapython3 branch October 29, 2021 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: clean Cleaning the code pr: new feature Implement a new feature pr: status ready Approved a pull-request, ready to be squashed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants