rdiankov / openrave

Open Robotics Automation Virtual Environment: An environment for testing, developing, and deploying robotics motion planning algorithms.
http://www.openrave.org
Other
698 stars 342 forks source link

WIP: Target exporting with CMake #1184

Closed undisputed-seraphim closed 1 year ago

undisputed-seraphim commented 1 year ago

This merge request aims to implement proper target exporting and importing with CMake.

I need to make these changes because certain embedded platform build systems expect myproject-targets.cmake files to be present in order to facilitate dependency resolution. Existing dependency layers that are bundled with the build system also expect other dependencies to be reasonably well-behaved (does not force-set CMake variables that leak across projects).

High-level overview of changes:

There is also a compatibility shim so that existing libraries that use deprecated behaviours continue to work, but ideally we should fix downstream libraries and them remove this shim.

After this change, any project that wishes to link against OpenRAVE in CMake do not need any to do any voodoo; simply find_package(OpenRAVE REQUIRED) and then target_link_libraries(myproject PUBLIC OpenRAVE::OpenRAVE).

cielavenir commented 1 year ago

oh please check if this change is still compatible with Python3 flavor

undisputed-seraphim commented 1 year ago

oh please check if this change is still compatible with Python3 flavor

The change is purely CMake only, to target Python3 we just change all find_package(Python2 ...) to find_package(Python3 ...)

cielavenir commented 1 year ago

to target Python3 we just change all find_package(Python2 ...) to find_package(Python3 ...)

we will need to patch a lot.

Also, Currently the behavior can be changed by installing python-is-python2 or python-is-python3 without changing CMakeLists, but we will lose that capability.

undisputed-seraphim commented 1 year ago

to target Python3 we just change all find_package(Python2 ...) to find_package(Python3 ...)

we will need to patch a lot.

Also, Currently the behavior can be changed by installing python-is-python2 or python-is-python3 without changing CMakeLists, but we will lose that capability.

We can use FindPython , which will define target names that are version agnostic. i.e.,

find_package(Python 2.7 REQUIRED COMPONENTS Interpreter Development NumPy)
...
target_link_libraries(my_library PUBLIC Python::Module Python::NumPy)

That way, we only need to change 2.7 to 3.x without having to change anything else.

Does that work for you?

cielavenir commented 1 year ago

Sure that should be ok

undisputed-seraphim commented 1 year ago

Closing this due to developments on another branch involving CMake.