PhysX needs CMake consumer support #278
Replies: 3 comments 2 replies
-
Hi @JoeRosselli - we have an unofficial vcpkg port: #162 |
Beta Was this translation helpful? Give feedback.
-
The way I do this is by not using the official CMake-based build system at all and just listing all the relevant .cpp files in an add_library call in my own CMakeLists.txt, along with a couple defines (_DEBUG XOR NDEBUG, DISABLE_CUDA_PHYSX, PX_PHYSX_STATIC_LIB, and optionally PX_CHECKED) and flags (-fno-strict-aliasing and optionally -fno-rtti -fno-exceptions), and adding include directories until the compiler can find all header files. This works perfectly with cross compiling and does not need network access nor any dependencies beyond a standard C++ toolchain. |
Beta Was this translation helpful? Give feedback.
-
This would be a great improvement for this library. |
Beta Was this translation helpful? Give feedback.
-
Hi,
It seems like PhysX is primarily CMake-based for its build system, which is great. However, it only uses CMake for building itself and stops just short of utilizing CMake to allow CMake-based consumers to take a dependency on PhysX.
The current state of things appears to be that if you're making a cross-platform product that depends on PhysX there's no non-hacky way to take a dependency on PhysX (5.X).
The official instructions for taking a dependency on PhysX in a CMake project (https://nvidia-omniverse.github.io/PhysX/physx/5.3.1/docs/BuildingWithPhysX.html) is a completely manual process where we need to separately, manually, build PhysX, and then in the consumer project explicitly configure the PhysX include directory(s), library directory, and manually specify binaries to link against (in a very specific correct order or it all explodes).
I also get a multitude of errors trying to follow this process, different errors on different platforms, but that's besides the point.
This process however, doesn't integrate at all with cross-platform consumer CMake projects. PhysX builds itself into a number of different directories, depending on platform and compiler, and build type, with a number of configurations for static or dll output, and it even involves a non-CMake step, running a generate script before then manually building PhysX. There's no way to configure a CMake project to consume PhysX, from source, in a generic, cross-platform way.
Even if there was a good way in CMake to generically link against the PhysX output, it still requires manually building PhysX, which is a huge burden for consumers, as consumers of my project can't just use CMake to open and build my project, they need to be instructed on how to manually build PhysX first as a completely separate step.
There seems to a vcpkg physx package which tries to wrap all of the PhysX output in a way that consumers can natively consume them. However, this is broken on Linux (Issue #277), so cross-platform projects can not depend on PhysX this way. It seems like this has been broken for a long time (the entire history of 5.X?)
I've spent multiple times longer trying to cleanly integrate PhysX into my project than it took to port my entire physics system over to using PhysX from a different physics engine.
As PhysX is CMake-based, it ideally needs to additionally do one of these things:
and/or
and/or
and/or
There seems to be at least one effort to improve things in this direction, NVIDIAGameWorks/PhysX#222 , but that's apparently for PhysX 4.X and has been in limbo for 4 or 5 years now.
Maybe I'm missing something? How, as a CMake-based, cross-platform, consumer, and I supposed to integrate with PhysX in a clean way?
Beta Was this translation helpful? Give feedback.
All reactions