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

CMake targets are not exported #208

Open
diegoferigo opened this issue Oct 23, 2019 · 2 comments · May be fixed by #222
Open

CMake targets are not exported #208

diegoferigo opened this issue Oct 23, 2019 · 2 comments · May be fixed by #222

Comments

@diegoferigo
Copy link

I am checking the best way to link PhysX against targets of my CMake project. The documentation reports the steps to add the include directories and the linked libraries.

However, considering that PhysX has a very good CMake structure, it would be great if the targets were directly exported by CMake.

I found that an export set already exists:

INSTALL(
TARGETS ${PHYSXDISTRO_LIBS}
EXPORT PhysXSDK
DESTINATION $<$<CONFIG:debug>:${PX_ROOT_LIB_DIR}/debug>$<$<CONFIG:release>:${PX_ROOT_LIB_DIR}/release>$<$<CONFIG:checked>:${PX_ROOT_LIB_DIR}/checked>$<$<CONFIG:profile>:${PX_ROOT_LIB_DIR}/profile>
)

But it is never installed. This means that something similar is missing:

INSTALL(
    EXPORT PhysXSDK
    DESTINATION ...
    NAMESPACE PhysX)

The final goal is having properly exported targets that transitively carry properties. Exporting the targets, together with a proper package config file, would allow user code to do the following:

# Add the install prefix to the CMake search path.
# It would be compatible also if users install outside the PhysX repo folder.
list(APPEND CMAKE_PREFIX_PATH "/path/to/repo/PhysX/install/linux/PhysX"

find_package(PhysX 4.1.1 REQUIRED COMPONENTS PhysX PhysXCommon PhysXCooking PhysXGpu ...)

add_library(MyLibrary SHARED src/mylibrary.cpp)
target_link_library(MyLibrary PhysX::PhysX PhysX::PhysXCommon PhysX::PhysXGpu ...)

Note that in this way users do not have to specify anything but the linked imported target. As a bonus user would also get a proper release matching.

Resources:

@phcerdan
Copy link

Hi @diegoferigo, the PR #222 provides a PhysXConfig.cmake for the build and install tree,
so find_package(PhysX) can be used.
It also removed the requirement of python and the presets for the different platforms. The goal is to facilitate integration of PhysX in third party projects. Any comments on that PR is welcome, and hope it helps!

@diegoferigo
Copy link
Author

Hi @phcerdan, thanks a lot, it looks great! I left few preliminary comments in the PR. I let you know more as soon as I can test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants