# O3DE uses the o3de/PhysX fork pinned to the release/104.1 branch. # The CMakeModules (NvidiaBuildOptions etc.) are normally pulled via # NVIDIA Packman; we bundle them from the NVIDIA-Omniverse repo # as Source1 to avoid the Packman dependency. %global commit 60e7d82a3856740881d0c892a01df7fd4e0676f6 %global shortcommit %(c=%{commit}; echo ${c:0:7}) %global snapdate 20230330 # Pinned commit for the NVIDIA-Omniverse/PhysX cmake modules %global omni_commit 09ff24f3279b735e672ff27b155cbf49f6296f4d %global omni_shortcommit %(c=%{omni_commit}; echo ${c:0:7}) # SO version - PhysX does not set an soname itself, we track it manually %global somajor 5 Name: PhysX Version: 5.1.2 Release: 9.%{snapdate}git%{shortcommit}%{?dist} Summary: NVIDIA PhysX physics simulation engine License: BSD-3-Clause URL: https://github.com/o3de/PhysX Source0: %{url}/archive/%{commit}/PhysX-%{shortcommit}.tar.gz # CMakeModules needed by the 104.1 build system (bundled in newer releases) Source1: https://github.com/NVIDIA-Omniverse/PhysX/archive/%{omni_commit}/PhysX-%{omni_shortcommit}.tar.gz # Only x86_64 and aarch64 are relevant targets ExclusiveArch: x86_64 aarch64 BuildRequires: cmake >= 3.12 BuildRequires: gcc-c++ BuildRequires: ninja-build BuildRequires: python3 BuildRequires: chrpath %description NVIDIA PhysX is an open-source, scalable, multi-platform physics simulation engine. It provides rigid body dynamics, soft body simulation, articulated bodies, character controllers, vehicle simulation, and cooking utilities. This package is built from the O3DE (Open 3D Engine) fork for use with the O3DE PhysX Gem. %package devel Summary: Development files for %{name} Requires: %{name}%{?_isa} = %{version}-%{release} %description devel Header files for developing applications that use NVIDIA PhysX. %package static Summary: Static libraries for %{name} Requires: %{name}-devel%{?_isa} = %{version}-%{release} %description static Static libraries for developing applications that use NVIDIA PhysX. %prep %autosetup -n PhysX-%{commit} # Extract CMakeModules from the NVIDIA-Omniverse repo into a temp directory, # then copy the modules subtree into the o3de source tree. mkdir -p _omni_tmp tar xzf %{SOURCE1} -C _omni_tmp cp -a _omni_tmp/PhysX-%{omni_commit}/physx/source/compiler/cmake/modules \ physx/source/compiler/cmake/modules rm -rf _omni_tmp # Both CMakeLists.txt files read CMAKEMODULES_PATH from the # PM_CMakeModules_PATH environment variable (set by NVIDIA Packman). # Patch them to use the modules directory we just extracted instead. # # The entry-point CMakeLists (physx/compiler/public/CMakeLists.txt) sets # CMAKEMODULES_PATH *and* CMAKEMODULES_VERSION first; the inner # CMakeLists (physx/source/compiler/cmake/CMakeLists.txt) skips its own # assignment when CMAKEMODULES_VERSION is already defined. Both must be # patched so the correct path propagates regardless of processing order. sed -i 's|SET(CMAKEMODULES_PATH $ENV{PM_CMakeModules_PATH}|SET(CMAKEMODULES_PATH "${PHYSX_ROOT_DIR}/source/compiler/cmake/modules"|' \ physx/compiler/public/CMakeLists.txt \ physx/source/compiler/cmake/CMakeLists.txt # Remove -Werror flags that break builds with newer GCC # Must cover both the cmake dir and the modules dir (from Source1) find physx -name '*.cmake' -exec sed -i 's/-Werror//g' {} + find physx -name CMakeLists.txt -exec sed -i 's/-Werror//g' {} + # Ensure position-independent code for shared library builds sed -i '/CMAKE_POSITION_INDEPENDENT_CODE/d' physx/source/compiler/cmake/CMakeLists.txt printf '\nset(CMAKE_POSITION_INDEPENDENT_CODE ON)\n' >> physx/source/compiler/cmake/CMakeLists.txt %build export PHYSX_ROOT_DIR=%{_builddir}/PhysX-%{commit}/physx # Build shared libraries %cmake -S physx/compiler/public \ -G Ninja \ -DPHYSX_ROOT_DIR=${PHYSX_ROOT_DIR} \ -DTARGET_BUILD_PLATFORM=linux \ -DPX_BUILDSNIPPETS=OFF \ -DPX_BUILDPVDRUNTIME=OFF \ -DPX_GENERATE_STATIC_LIBRARIES=OFF \ -DPX_GENERATE_GPU_PROJECTS=OFF \ -DCMAKE_BUILD_TYPE=Release \ -DPUBLIC_RELEASE=ON \ -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ -DPX_OUTPUT_LIB_DIR=%{_builddir}/physx_output/shared/lib \ -DPX_OUTPUT_DLL_DIR=%{_builddir}/physx_output/shared/bin \ -DPX_OUTPUT_BIN_DIR=%{_builddir}/physx_output/shared/bin %cmake_build # Build static libraries separately %cmake -S physx/compiler/public \ -G Ninja \ -B %{_builddir}/PhysX-%{commit}/%{__cmake_builddir}-static \ -DPHYSX_ROOT_DIR=${PHYSX_ROOT_DIR} \ -DTARGET_BUILD_PLATFORM=linux \ -DPX_BUILDSNIPPETS=OFF \ -DPX_BUILDPVDRUNTIME=OFF \ -DPX_GENERATE_STATIC_LIBRARIES=ON \ -DPX_GENERATE_GPU_PROJECTS=OFF \ -DCMAKE_BUILD_TYPE=Release \ -DPUBLIC_RELEASE=ON \ -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ -DPX_OUTPUT_LIB_DIR=%{_builddir}/physx_output/static/lib \ -DPX_OUTPUT_DLL_DIR=%{_builddir}/physx_output/static/bin \ -DPX_OUTPUT_BIN_DIR=%{_builddir}/physx_output/static/bin cmake --build %{_builddir}/PhysX-%{commit}/%{__cmake_builddir}-static %{?_smp_mflags} %install install -d %{buildroot}%{_libdir} # Install shared libraries # PhysX outputs libs under PX_OUTPUT_LIB_DIR with additional subdirectories # (bin/linux.x86_64/release/), so search the entire physx_output tree. # Only PhysX, PhysXCommon, PhysXCooking, PhysXFoundation are built as shared # libraries. The others (CharacterKinematic, Extensions, PvdSDK, Vehicle, # Vehicle2) are static-only in shared build mode and get linked into the # main shared libraries. for lib in PhysX PhysXCommon PhysXCooking PhysXFoundation; do SHARED_LIB=$(find %{_builddir}/physx_output/shared -name "lib${lib}.so" -type f 2>/dev/null | head -1) if [ -z "$SHARED_LIB" ]; then SHARED_LIB=$(find %{_builddir}/physx_output/shared -name "lib${lib}*.so*" -type f 2>/dev/null | head -1) fi if [ -n "$SHARED_LIB" ]; then install -p -m 0755 "$SHARED_LIB" %{buildroot}%{_libdir}/lib${lib}.so.%{somajor}.1.2 # Strip build-time RPATH that references the build directory chrpath --delete %{buildroot}%{_libdir}/lib${lib}.so.%{somajor}.1.2 || true ln -s lib${lib}.so.%{somajor}.1.2 %{buildroot}%{_libdir}/lib${lib}.so.%{somajor} ln -s lib${lib}.so.%{somajor} %{buildroot}%{_libdir}/lib${lib}.so fi done # Install static libraries for lib in PhysX PhysXCommon PhysXCooking PhysXFoundation PhysXCharacterKinematic \ PhysXExtensions PhysXPvdSDK PhysXVehicle PhysXVehicle2 \ LowLevel LowLevelAABB LowLevelDynamics SceneQuery SimulationController \ FastXml PhysXTask; do STATIC_LIB=$(find %{_builddir}/physx_output/static -name "lib${lib}.a" -type f 2>/dev/null | head -1) if [ -z "$STATIC_LIB" ]; then STATIC_LIB=$(find %{_builddir}/physx_output/static -name "lib${lib}*.a" -type f 2>/dev/null | head -1) fi if [ -n "$STATIC_LIB" ]; then install -p -m 0644 "$STATIC_LIB" %{buildroot}%{_libdir}/lib${lib}.a fi done # Install headers from physx/include install -d %{buildroot}%{_includedir}/PhysX cp -a physx/include/* %{buildroot}%{_includedir}/PhysX/ %files %license LICENSE.md %{_libdir}/libPhysX.so.%{somajor} %{_libdir}/libPhysX.so.%{somajor}.* %{_libdir}/libPhysXCommon.so.%{somajor} %{_libdir}/libPhysXCommon.so.%{somajor}.* %{_libdir}/libPhysXCooking.so.%{somajor} %{_libdir}/libPhysXCooking.so.%{somajor}.* %{_libdir}/libPhysXFoundation.so.%{somajor} %{_libdir}/libPhysXFoundation.so.%{somajor}.* %files devel %{_includedir}/PhysX/ %{_libdir}/libPhysX.so %{_libdir}/libPhysXCommon.so %{_libdir}/libPhysXCooking.so %{_libdir}/libPhysXFoundation.so %files static # All PhysX components are available as static libraries %{_libdir}/lib*.a %changelog * Wed Feb 11 2026 O3DE Package Maintainers - 5.1.2-9.20230330git60e7d82 - Fix files list: only PhysX, PhysXCommon, PhysXCooking, PhysXFoundation are shared libraries; others are static-only in shared build mode * Wed Feb 11 2026 O3DE Package Maintainers - 5.1.2-8.20230330git60e7d82 - Strip invalid build-time RPATH from shared libraries using chrpath * Wed Feb 11 2026 O3DE Package Maintainers - 5.1.2-7.20230330git60e7d82 - Fix install: search physx_output/ tree for built libraries (PhysX adds bin/linux.x86_64/release/ subdirectories under PX_OUTPUT_*_DIR) * Wed Feb 11 2026 O3DE Package Maintainers - 5.1.2-6.20230330git60e7d82 - Broaden -Werror removal to cover entire physx tree including NvidiaBuildOptions modules * Wed Feb 11 2026 O3DE Package Maintainers - 5.1.2-5.20230330git60e7d82 - Also add PX_OUTPUT_BIN_DIR required by NvidiaBuildOptions.cmake * Wed Feb 11 2026 O3DE Package Maintainers - 5.1.2-3.20230330git60e7d82 - Fix CMakeModules extraction: patch both compiler/public and source/compiler CMakeLists.txt so CMAKEMODULES_PATH resolves correctly - Pin Source1 to NVIDIA-Omniverse/PhysX commit 09ff24f for reproducibility - Replace fragile tar --wildcards extraction with mkdir/cp approach * Tue Feb 11 2025 O3DE Package Maintainers - 5.1.2-1.20230330git60e7d82 - Initial package of NVIDIA PhysX physics simulation engine - Built from O3DE fork commit 60e7d82 (release/104.1 branch) - Includes shared and static libraries plus development headers