Skip to content

Conversation

@th-skam
Copy link
Collaborator

@th-skam th-skam commented Sep 10, 2025

This PR simplifies the CMakeLists.txt and CollisionAlgorithmConfig.cmake.in files.
This is to be more consistent with the structure of other SOFA plugins (e.g. BeamAdapter) and to ease the build-checks in the current and the ConstraintGeometry repositories, as well as the non-regression testing being currently built.

@epernod
Copy link
Contributor

epernod commented Sep 12, 2025

@bakpaul @fredroy
Could you have a quick look at this one. All file are moved to another architecture. Could you confirm this is the good way to go for SOFA plugins?

Copy link
Contributor

@fredroy fredroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(maybe in an other PR)
and set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) should be removed as well. And use *_API macro mechanism to select which symbols to be exported

CMakeLists.txt Outdated
"deprecated/*.inl"
"deprecated/*.cpp"
)
file(GLOB_RECURSE HEADER_FILES "src/*.h" "src/*.inl")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not really advised to use GLOB_RECURSE for sources files
https://cmake.org/cmake/help/latest/command/file.html#glob



Note

We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the generated build system cannot know when to ask CMake to regenerate. The CONFIGURE_DEPENDS flag may not work reliably on all generators, or if a new generator is added in the future that cannot support it, projects using it will be stuck. Even if CONFIGURE_DEPENDS works reliably, there is still a cost to perform the check on every rebuild. 

CMakeLists.txt Outdated
INCLUDE_SOURCE_DIR "src"
INCLUDE_INSTALL_DIR ${PROJECT_NAME}
EXAMPLE_INSTALL_DIR "scenes"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually plugins must set "RELOCATABLE"

Suggested change
)
RELOCATABLE "plugins"
)

#include <CollisionAlgorithm/BaseElement.h>
#include <thread>

namespace sofa::collisionAlgorithm {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not related to the PR, but I would take the opportunity while refactoring/breaking stuff, to change the namespace (AFAIK there is not any namespace in camelCase)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this has been handy when we only want collision without insertion (e.g. needle vs bones).
I'll probably absorb this in the new algorithm but since I have all relevant scenes set up this way I'm keeping it around for the time being.


#ifdef SOFA_BUILD_COLLISIONALGORITHM
# define SOFA_TARGET @PROJECT_NAME@
# define SOFA_COLLISIONALGORITHM_API SOFA_EXPORT_DYNAMIC_LIBRARY
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the good way but I saw that it is just used in the init.cpp files. I think you will need to use it to export the classes as well (or the explicit instanciations if they are templated).
But if you are not on Windows, it will be a bit difficult to do it "blindly" so it may be the best to do it in a other PR and test it on Windows.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for these tips @fredroy!

A question about using this feature properly in SOFA plugins:
I would be using the *_API macro to export classes in the following situations:

  • For base classes that I might want to inherit from and extend in another plugin
  • Derived ones that will end up in a sofa scene as components
  • Some internal classes (like an iterator) that are returned by public functions and should be exposed

and limit the export right there. Would you recommend this approach or perhaps export classes in other cases as well?

Copy link
Contributor

@epernod epernod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all approve, I'll do the same :)

@epernod epernod 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 Sep 19, 2025
@epernod epernod merged commit 834531e into master Sep 19, 2025
4 checks passed
@epernod epernod deleted the rework-cmake branch September 19, 2025 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: enhancement pr: status ready Approved a pull-request, ready to be squashed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants