[physx] Add support for Linux, macOS, and UWP (#13849)

This commit is contained in:
Adam Johnson 2020-11-08 00:43:59 -05:00 committed by GitHub
parent 5a97bb2f57
commit 9c56f59ed4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 136 additions and 149 deletions

View File

@ -1,5 +1,4 @@
Source: physx
Version: 4.1.1
Port-Version: 5
Port-Version: 6
Description: The NVIDIA PhysX SDK is a scalable multi-platform physics solution supporting a wide range of devices, from smartphones to high-end multicore CPUs and GPUs
Supports: !uwp

View File

@ -0,0 +1,13 @@
diff --git a/physx/source/geomutils/src/gjk/GuGJKType.h b/physx/source/geomutils/src/gjk/GuGJKType.h
index a0099e2f..b824ec7a 100644
--- a/physx/source/geomutils/src/gjk/GuGJKType.h
+++ b/physx/source/geomutils/src/gjk/GuGJKType.h
@@ -151,7 +151,7 @@ namespace Gu
virtual Ps::aos::Vec3V getCenter() const { return mAToB.transform(getConvex<Convex>().getCenter()); }
- PX_FORCE_INLINE Ps::aos::PsMatTransformV& getRelativeTransform(){ return mAToB; }
+ PX_FORCE_INLINE const Ps::aos::PsMatTransformV& getRelativeTransform(){ return mAToB; }
//ML: we can't force inline function, otherwise win modern will throw compiler error
PX_INLINE RelativeConvex<typename ConvexGeom<Convex>::Type > getGjkConvex() const

View File

@ -1,83 +1,4 @@
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
set(SYSTEM_PLATFORM "32")
set(SYSTEM_PLATFORM_PATH "x86_32")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(SYSTEM_PLATFORM "64")
set(SYSTEM_PLATFORM_PATH "x86_64")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
set(SYSTEM_PLATFORM "arm32")
set(SYSTEM_PLATFORM_PATH "arm_32")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(SYSTEM_PLATFORM "arm64")
set(SYSTEM_PLATFORM_PATH "arm_64")
else()
message(FATAL_ERROR "Unsupported architecture: ${VCPKG_TARGET_ARCHITECTURE}")
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
set(GENERATE_STATIC_LIBRARIES "True")
elseif(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
set(GENERATE_STATIC_LIBRARIES "False")
endif()
if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_UWP)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
set(MSBUILD_PLATFORM "Win32")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(MSBUILD_PLATFORM "x64")
elseif(VCPKG_TARGET_IS_UWP)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
set(MSBUILD_PLATFORM "ARM")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(MSBUILD_PLATFORM "ARM64")
else()
message(FATAL_ERROR "Unsupported UWP architecture: ${VCPKG_TARGET_ARCHITECTURE}")
endif()
else()
message(FATAL_ERROR "Unsupported Windows architecture: ${VCPKG_TARGET_ARCHITECTURE}")
endif()
if(VCPKG_PLATFORM_TOOLSET STREQUAL "v140")
set(MSVC_VERSION "14")
set(TOOLSET_VERSION "140")
elseif(VCPKG_PLATFORM_TOOLSET STREQUAL "v141")
set(MSVC_VERSION "15")
set(TOOLSET_VERSION "141")
elseif(VCPKG_PLATFORM_TOOLSET STREQUAL "v142")
set(MSVC_VERSION "16")
set(TOOLSET_VERSION "142")
else()
message(FATAL_ERROR "Unsupported platform toolset.")
endif()
set(FLOAT_POINT_PRECISE_MATH "False")
set(BUILD_SNIPPETS "False")
set(BUILD_PUBLIC_SAMPLES "False")
if(VCPKG_TARGET_IS_WINDOWS)
set(SYSTEM "win")
if(VCPKG_CRT_LINKAGE STREQUAL "dynamic")
set(USE_STATIC_WINCRT "False")
set(RUNTIME_LIBRARY_LINKAGE "md")
elseif(VCPKG_CRT_LINKAGE STREQUAL "static")
set(USE_STATIC_WINCRT "True")
set(RUNTIME_LIBRARY_LINKAGE "mt")
endif()
set(USE_DEBUG_CRT "True")
set(COMPILER "vc${MSVC_VERSION}${SYSTEM}${SYSTEM_PLATFORM}")
set(PRESET_FILE ${COMPILER}-${RUNTIME_LIBRARY_LINKAGE}-${VCPKG_LIBRARY_LINKAGE})
set(BUILD_PATH "${SYSTEM}.${SYSTEM_PLATFORM_PATH}.vc${TOOLSET_VERSION}.${RUNTIME_LIBRARY_LINKAGE}")
elseif(VCPKG_TARGET_IS_UWP)
set(SYSTEM "uwp")
set(USE_STATIC_WINCRT "False")
set(USE_DEBUG_CRT "False")
set(COMPILER "vc${MSVC_VERSION}${SYSTEM}${SYSTEM_PLATFORM}")
set(PRESET_FILE ${COMPILER}-${VCPKG_LIBRARY_LINKAGE})
set(BUILD_PATH "${SYSTEM}.${SYSTEM_PLATFORM_PATH}.vc${TOOLSET_VERSION}")
endif()
else()
message(FATAL_ERROR "Unsupported platform: ${VCPKG_CMAKE_SYSTEM_NAME}")
endif()
vcpkg_fail_port_install(ON_TARGET MINGW)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
@ -89,67 +10,138 @@ vcpkg_from_github(
internalMBP_symbols.patch
msvc_142_bug_workaround.patch
vs16_3_typeinfo_header_fix.patch
)
file(REMOVE ${SOURCE_PATH}/physx/buildtools/presets/public/${PRESET_FILE}.xml)
configure_file(${CMAKE_CURRENT_LIST_DIR}/preset.xml.in ${SOURCE_PATH}/physx/buildtools/presets/public/${PRESET_FILE}.xml)
vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON3_DIR ${PYTHON3} DIRECTORY)
vcpkg_add_to_path(${PYTHON3_DIR})
get_filename_component(CMAKE_DIR ${CMAKE_COMMAND} DIRECTORY)
# If cmake is not installed then adding it to the end of the path
# will allow generate_projects.bat to find the cmake used by vcpkg.
vcpkg_add_to_path(${CMAKE_DIR})
vcpkg_execute_required_process(
COMMAND ${SOURCE_PATH}/physx/generate_projects.bat ${PRESET_FILE}
WORKING_DIRECTORY ${SOURCE_PATH}/physx
LOGNAME build-${TARGET_TRIPLET}
fix_discarded_qualifiers.patch
)
if(NOT DEFINED RELEASE_CONFIGURATION)
set(RELEASE_CONFIGURATION "release")
set(RELEASE_CONFIGURATION "release")
endif()
set(DEBUG_CONFIGURATION "debug")
vcpkg_build_msbuild(
PROJECT_PATH ${SOURCE_PATH}/physx/compiler/${COMPILER}/PhysXSDK.sln
RELEASE_CONFIGURATION ${RELEASE_CONFIGURATION}
DEBUG_CONFIGURATION ${DEBUG_CONFIGURATION}
PLATFORM ${MSBUILD_PLATFORM}
set(OPTIONS
"-DPHYSX_ROOT_DIR=${SOURCE_PATH}/physx"
"-DPXSHARED_PATH=${SOURCE_PATH}/pxshared"
"-DPXSHARED_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}"
"-DCMAKEMODULES_PATH=${SOURCE_PATH}/externals/cmakemodules"
"-DCMAKEMODULES_NAME=CMakeModules"
"-DCMAKE_MODULES_VERSION=1.27"
"-DPX_BUILDSNIPPETS=OFF"
"-DPX_BUILDPUBLICSAMPLES=OFF"
"-DPX_FLOAT_POINT_PRECISE_MATH=OFF"
"-DPX_COPY_EXTERNAL_DLL=OFF"
"-DGPU_DLL_COPIED=ON"
)
file(INSTALL ${SOURCE_PATH}/physx/include/ DESTINATION ${CURRENT_PACKAGES_DIR}/include/${PORT}/)
file(INSTALL ${SOURCE_PATH}/pxshared/include/ DESTINATION ${CURRENT_PACKAGES_DIR}/include/${PORT}/)
set(OPTIONS_RELEASE
"-DPX_OUTPUT_BIN_DIR=${CURRENT_PACKAGES_DIR}"
"-DPX_OUTPUT_LIB_DIR=${CURRENT_PACKAGES_DIR}"
)
set(OPTIONS_DEBUG
"-DPX_OUTPUT_BIN_DIR=${CURRENT_PACKAGES_DIR}/debug"
"-DPX_OUTPUT_LIB_DIR=${CURRENT_PACKAGES_DIR}/debug"
"-DNV_USE_DEBUG_WINCRT=ON"
)
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
file(GLOB RELEASE_BINS ${SOURCE_PATH}/physx/bin/${BUILD_PATH}/${RELEASE_CONFIGURATION}/*.dll)
file(INSTALL ${RELEASE_BINS} DESTINATION ${CURRENT_PACKAGES_DIR}/bin)
file(GLOB DEBUG_BINS ${SOURCE_PATH}/physx/bin/${BUILD_PATH}/${DEBUG_CONFIGURATION}/*.dll)
file(INSTALL ${DEBUG_BINS} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin)
vcpkg_copy_pdbs()
if(VCPKG_TARGET_IS_UWP)
list(APPEND OPTIONS "-DTARGET_BUILD_PLATFORM=uwp")
elseif(VCPKG_TARGET_IS_WINDOWS)
list(APPEND OPTIONS "-DTARGET_BUILD_PLATFORM=windows")
elseif(VCPKG_TARGET_IS_OSX)
list(APPEND OPTIONS "-DTARGET_BUILD_PLATFORM=mac")
elseif(VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_FREEBSD)
list(APPEND OPTIONS "-DTARGET_BUILD_PLATFORM=linux")
elseif(VCPKG_TARGET_IS_ANDROID)
list(APPEND OPTIONS "-DTARGET_BUILD_PLATFORM=android")
else()
message(FATAL_ERROR "Unhandled or unsupported target platform.")
endif()
file(
GLOB
RELEASE_LIBS
${SOURCE_PATH}/physx/bin/${BUILD_PATH}/${RELEASE_CONFIGURATION}/*.lib
${SOURCE_PATH}/physx/bin/${BUILD_PATH}/${RELEASE_CONFIGURATION}/*.pdb
${SOURCE_PATH}/physx/compiler/${COMPILER}/sdk_source_bin/${RELEASE_CONFIGURATION}/*.pdb
)
file(INSTALL ${RELEASE_LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/lib)
if(VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_IOS)
list(APPEND OPTIONS "-DNV_FORCE_64BIT_SUFFIX=ON" "-DNV_FORCE_32BIT_SUFFIX=OFF")
endif()
file(
GLOB
DEBUG_LIBS
${SOURCE_PATH}/physx/bin/${BUILD_PATH}/${DEBUG_CONFIGURATION}/*.lib
${SOURCE_PATH}/physx/bin/${BUILD_PATH}/${DEBUG_CONFIGURATION}/*.pdb
${SOURCE_PATH}/physx/compiler/${COMPILER}/sdk_source_bin/${DEBUG_CONFIGURATION}/*.pdb
)
file(INSTALL ${DEBUG_LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
list(APPEND OPTIONS "-DPX_GENERATE_STATIC_LIBRARIES=OFF")
else()
list(APPEND OPTIONS "-DPX_GENERATE_STATIC_LIBRARIES=ON")
endif()
if(VCPKG_CRT_LINKAGE STREQUAL "dynamic")
list(APPEND OPTIONS "-DNV_USE_STATIC_WINCRT=OFF")
else()
list(APPEND OPTIONS "-DNV_USE_STATIC_WINCRT=ON")
endif()
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
list(APPEND OPTIONS "-DPX_OUTPUT_ARCH=arm")
else()
list(APPEND OPTIONS "-DPX_OUTPUT_ARCH=x86")
endif()
# Replicate PhysX's CXX Flags here so we don't have to patch out /WX and -Wall
list(APPEND OPTIONS "-DPHYSX_CXX_FLAGS:INTERNAL=${VCPKG_CXX_FLAGS}")
vcpkg_configure_cmake(
SOURCE_PATH "${SOURCE_PATH}/physx/compiler/public"
PREFER_NINJA
DISABLE_PARALLEL_CONFIGURE
OPTIONS ${OPTIONS}
OPTIONS_DEBUG ${OPTIONS_DEBUG}
OPTIONS_RELEASE ${OPTIONS_RELEASE}
)
vcpkg_install_cmake()
# NVIDIA Gameworks release structure is generally something like <compiler>/<configuration>/[artifact]
# It would be nice to patch this out, but that directory structure is hardcoded over many cmake files.
# So, we have this helpful helper to copy the bins and libs out.
function(fixup_physx_artifacts)
macro(_fixup _IN_DIRECTORY _OUT_DIRECTORY)
foreach(_SUFFIX IN LISTS _fpa_SUFFIXES)
file(GLOB_RECURSE _ARTIFACTS
LIST_DIRECTORIES false
"${CURRENT_PACKAGES_DIR}/${_IN_DIRECTORY}/*${_SUFFIX}"
)
if(_ARTIFACTS)
file(COPY ${_ARTIFACTS} DESTINATION "${CURRENT_PACKAGES_DIR}/${_OUT_DIRECTORY}")
endif()
endforeach()
endmacro()
cmake_parse_arguments(_fpa "" "DIRECTORY" "SUFFIXES" ${ARGN})
_fixup("bin" ${_fpa_DIRECTORY})
_fixup("debug/bin" "debug/${_fpa_DIRECTORY}")
endfunction()
fixup_physx_artifacts(
DIRECTORY "lib"
SUFFIXES ${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX} ${VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX}
)
fixup_physx_artifacts(
DIRECTORY "bin"
SUFFIXES ${VCPKG_TARGET_SHARED_LIBRARY_SUFFIX} ".pdb"
)
# Remove compiler directory and descendents.
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/bin/"
"${CURRENT_PACKAGES_DIR}/debug/bin/"
)
else()
file(GLOB PHYSX_ARTIFACTS LIST_DIRECTORIES true
"${CURRENT_PACKAGES_DIR}/bin/*"
"${CURRENT_PACKAGES_DIR}/debug/bin/*"
)
foreach(_ARTIFACT IN LISTS PHYSX_ARTIFACTS)
if(IS_DIRECTORY ${_ARTIFACT})
file(REMOVE_RECURSE ${_ARTIFACT})
endif()
endforeach()
endif()
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/source"
"${CURRENT_PACKAGES_DIR}/source"
)
file(INSTALL ${SOURCE_PATH}/README.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<preset name="vc${MSVC_VERSION}${SYSTEM}${SYSTEM_PLATFORM}" comment="VC${MSVC_VERSION} ${SYSTEM}${SYSTEM_PLATFORM} PhysX general settings">
<platform targetPlatform="${SYSTEM}${SYSTEM_PLATFORM}" compiler="vc${MSVC_VERSION}" />
<CMakeSwitches>
<cmakeSwitch name="PX_BUILDSNIPPETS" value="${BUILD_SNIPPETS}" comment="Generate the snippets" />
<cmakeSwitch name="PX_BUILDPUBLICSAMPLES" value="${BUILD_PUBLIC_SAMPLES}" comment="Generate the samples projects" />
<cmakeSwitch name="PX_GENERATE_STATIC_LIBRARIES" value="${GENERATE_STATIC_LIBRARIES}" comment="Generate static libraries" />
<cmakeSwitch name="NV_USE_STATIC_WINCRT" value="${USE_STATIC_WINCRT}" comment="Use the statically linked windows CRT" />
<cmakeSwitch name="NV_USE_DEBUG_WINCRT" value="${USE_DEBUG_CRT}" comment="Use the debug version of the CRT" />
<cmakeSwitch name="PX_FLOAT_POINT_PRECISE_MATH" value="${FLOAT_POINT_PRECISE_MATH}" comment="Float point precise math" />
</CMakeSwitches>
<CMakeParams>
<cmakeParam name="CMAKE_INSTALL_PREFIX" value="install/vc${MSVC_VERSION}${SYSTEM}${SYSTEM_PLATFORM}/PhysX" comment="Install path relative to PhysX SDK root" />
</CMakeParams>
</preset>

View File

@ -1248,8 +1248,6 @@ pfring:x64-osx=fail
pfring:x64-linux=fail
physfs:arm64-windows=fail
physx:arm64-windows=fail
physx:x64-linux=fail
physx:x64-osx=fail
piex:x64-osx=fail
pistache:arm64-windows=fail
pistache:arm-uwp=fail