Commit a87ea030 authored by Aaron Bray's avatar Aaron Bray
Browse files

Add PhysX build support

parent 6534064c
......@@ -93,13 +93,16 @@ ExternalProject_Add( ${PROJECT_NAME}
CMAKE_ARGS
-DBUILD_EXAMPLES:BOOL=${BUILD_EXAMPLES}
-DBUILD_TESTING:BOOL=${BUILD_TESTING}
-DPHYSX_CONFIGURATION:STRING=${${PROJECT_NAME}_PHYSX_CONFIGURATION}
-D${PROJECT_NAME}_SUPERBUILD:BOOL=OFF
-D${PROJECT_NAME}_USE_OpenHaptics:BOOL=${${PROJECT_NAME}_USE_OpenHaptics}
-D${PROJECT_NAME}_USE_Vulkan:BOOL=${${PROJECT_NAME}_USE_Vulkan}
-D${PROJECT_NAME}_ENABLE_AUDIO:BOOL=${${PROJECT_NAME}_ENABLE_AUDIO}
-D${PROJECT_NAME}_ENABLE_VR:BOOL=${${PROJECT_NAME}_ENABLE_VR}
DEPENDS ${${PROJECT_NAME}_DEPENDENCIES}
PATCH_COMMAND ${VTK_PATCH_COMMAND}
PATCH_COMMAND
COMMAND ${VTK_PATCH_COMMAND}
# Always build these non standard configurations
)
#-----------------------------------------------------------------------------
......
#-----------------------------------------------------------------------------
# Add External Project
#-----------------------------------------------------------------------------
include(imstkAddExternalProject)
imstk_define_external_dirs( PhysX )
if(WIN32)
set(PHYSX_TARGET_BUILD_PLATFORM windows)
elseif(APPLE)
set(PHYSX_TARGET_BUILD_PLATFORM mac)
else()
set(PHYSX_TARGET_BUILD_PLATFORM linux)
endif()
set(PHYSX_iMSTK_INSTALL "${CMAKE_COMMAND}"
-DPhysX_INSTALL_DIR=${PhysX_BINARY_DIR}/install
-DiMSTK_INSTALL_DIR=${CMAKE_INSTALL_PREFIX}
-P ${CMAKE_SOURCE_DIR}/CMake/External/Patches/physx.cmake)
imstk_add_external_project( PhysX
#URL https://github.com/NVIDIAGameWorks/PhysX/archive/4.1.zip
#URL_MD5 79004323c3c39152a6c0491967e0a609
#URL_MD5 32fdaddc4ad4e7e637faa86311eb1803
#DOWNLOAD_DIR ${PhysX_TMP_DIR}
GIT_REPOSITORY https://gitlab.kitware.com/iMSTK/PhysX.git
GIT_TAG 78481093a259101c2a1846370f749ea35cae80e2
GIT_SHALLOW TRUE
SOURCE_SUBDIR ./physx/compiler/public
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=${PhysX_BINARY_DIR}/install
-DPXSHARED_INSTALL_PREFIX:PATH=${PhysX_BINARY_DIR}/install
-DTARGET_BUILD_PLATFORM:STRING=${PHYSX_TARGET_BUILD_PLATFORM}
-DPX_OUTPUT_ARCH:STRING=x86 # Either x86 or arm, only used for naming conventions (postfix)
-DPHYSX_ROOT_DIR:PATH=${PhysX_SOURCE_DIR}/physx
-DCMAKEMODULES_PATH:PATH=${PhysX_SOURCE_DIR}/externals/CMakeModules
-DCMAKEMODULES_VERSION:STRING=1.27 # Must be set, but does not do anything...
-DPXSHARED_PATH:PATH=${PhysX_SOURCE_DIR}/pxshared
-DPX_OUTPUT_LIB_DIR:PATH=${PhysX_BINARY_DIR}
-DPX_OUTPUT_BIN_DIR:PATH=${PhysX_BINARY_DIR}
-DPX_BUILDSNIPPETS:BOOL=FALSE
-DPX_BUILDPUBLICSAMPLES:BOOL=FALSE
-DPX_GENERATE_STATIC_LIBRARIES:BOOL=TRUE
-DNV_USE_DEBUG_WINCRT:BOOL=TRUE
-DPX_FLOAT_POINT_PRECISE_MATH:BOOL=TRUE
-DNV_FORCE_64BIT_SUFFIX:BOOL=TRUE
-DNV_FORCE_32BIT_SUFFIX:BOOL=FALSE
-DNV_USE_GAMEWORKS_OUTPUT_DIRS:BOOL=TRUE
-DNV_APPEND_CONFIG_NAME:BOOL=TRUE
#VERBOSE
BUILD_COMMAND
COMMAND "${CMAKE_COMMAND}" --build . --config release
COMMAND "${CMAKE_COMMAND}" --build . --config profile
COMMAND "${CMAKE_COMMAND}" --build . --config checked
COMMAND "${CMAKE_COMMAND}" --build . --config debug
INSTALL_COMMAND
COMMAND "${CMAKE_COMMAND}" --build . --target install --config release
COMMAND "${CMAKE_COMMAND}" --build . --target install --config profile
COMMAND "${CMAKE_COMMAND}" --build . --target install --config checked
COMMAND "${CMAKE_COMMAND}" --build . --target install --config debug
COMMAND ${PHYSX_iMSTK_INSTALL}
)
......@@ -9,12 +9,12 @@ if(${${PROJECT_NAME}_ENABLE_VR})
endif()
set(VTK_REPO_SOURCE "8.2" CACHE STRING "Select VTK Source Branch/Tag")
set(${PROJECT_NAME}_VTK_REPO_SOURCE "8.2" CACHE STRING "Select VTK Source Branch/Tag")
set(VTK_SOURCES "8.2;8.9;master;release;nightly-master" CACHE INTERNAL "List of available VTK branch,tags to get")
set_property(CACHE VTK_REPO_SOURCE PROPERTY STRINGS ${VTK_SOURCES})
set_property(CACHE ${PROJECT_NAME}_VTK_REPO_SOURCE PROPERTY STRINGS ${VTK_SOURCES})
set(VTK_GIT_TAG)
if(VTK_REPO_SOURCE EQUAL "8.2")
if(${PROJECT_NAME}_VTK_REPO_SOURCE EQUAL "8.2")
set(VTK_MODULE_SETTINGS
-DModule_vtkRenderingOpenGL2:BOOL=ON
-DModule_vtkIOXML:BOOL=ON
......@@ -43,7 +43,7 @@ else()
-DVTK_MODULE_ENABLE_VTK_glew:STRING=YES
-DVTK_MODULE_ENABLE_VTK_RenderingContext2D:STRING=YES
)
if(VTK_REPO_SOURCE EQUAL "8.9")
if(${PROJECT_NAME}_VTK_REPO_SOURCE EQUAL "8.9")
set(VTK_GIT_TAG "9b6a039f43404053a0653f742148d123f6ada7d6")
else()
set(VTK_GIT_TAG "origin/${VTK_GIT_TAG}")
......
# This will copy the PhysX headers and libraries
# from its install directory to the iMSTK install directory
if(POLICY CMP0012)
cmake_policy(SET CMP0012 NEW)
endif()
function(string_starts_with str search bool)
string(FIND "${str}" "${search}" out)
if("${out}" EQUAL 0)
set(${bool} TRUE PARENT_SCOPE)
else()
set(${bool} FALSE PARENT_SCOPE)
endif()
endfunction()
message(STATUS "Installing PhysX from ${PhysX_INSTALL_DIR} to ${iMSTK_INSTALL_DIR}")
set(physx_platform_folder_ "")
file(GLOB dir_list RELATIVE ${PhysX_INSTALL_DIR}/bin/ ${PhysX_INSTALL_DIR}/bin/*)
foreach(dir ${dir_list})
if(IS_DIRECTORY ${PhysX_INSTALL_DIR}/bin/${dir})
string_starts_with(${dir} "win." is_win_)
string_starts_with(${dir} "mac." is_mac_)
string_starts_with(${dir} "linux." is_linux_)
if( ${is_win_} OR ${is_mac_} OR ${is_linux_} )
set(physx_platform_folder_ ${PhysX_INSTALL_DIR}/bin/${dir})
break()
endif()
endif()
endforeach()
message(STATUS "physx_platform_folder : ${physx_platform_folder_}")
file(MAKE_DIRECTORY ${iMSTK_INSTALL_DIR}/include/physx)
file(COPY ${PhysX_INSTALL_DIR}/include/ DESTINATION ${iMSTK_INSTALL_DIR}/include/physx)
file(COPY ${PhysX_INSTALL_DIR}/source/foundation/include/ DESTINATION ${iMSTK_INSTALL_DIR}/include/physx)
file(COPY ${PhysX_INSTALL_DIR}/source/fastxml/include/ DESTINATION ${iMSTK_INSTALL_DIR}/include/physx)
if(EXISTS ${physx_platform_folder_}/debug)
file(COPY ${physx_platform_folder_}/debug/ DESTINATION ${iMSTK_INSTALL_DIR}/lib)
endif()
if(EXISTS ${physx_platform_folder_}/release)
file(COPY ${physx_platform_folder_}/release/ DESTINATION ${iMSTK_INSTALL_DIR}/lib)
endif()
if(EXISTS ${physx_platform_folder_}/checked)
file(COPY ${physx_platform_folder_}/checked/ DESTINATION ${iMSTK_INSTALL_DIR}/lib)
endif()
if(EXISTS ${physx_platform_folder_}/profile)
file(COPY ${physx_platform_folder_}/profile/ DESTINATION ${iMSTK_INSTALL_DIR}/lib)
endif()
......@@ -11,5 +11,5 @@ imstk_find_libary(OpenHapticsSDK hlu " ")#Use same library for debug
imstk_find_package(OpenHapticsSDK)
message(STATUS "OpenHapticsSDK include : ${OPENHAPTICSSDK_INCLUDE_DIRS}")
message(STATUS "OpenHapticsSDK libraries : ${OPENHAPTICSSDK_LIBRARIES}")
#message(STATUS "OpenHapticsSDK include : ${OPENHAPTICSSDK_INCLUDE_DIRS}")
#message(STATUS "OpenHapticsSDK libraries : ${OPENHAPTICSSDK_LIBRARIES}")
include(imstkFind)
#-----------------------------------------------------------------------------
# Find All Headers and Libraries for PhysX SDK
#-----------------------------------------------------------------------------
set(physx_release_type)
if(NOT PHYSX_CONFIGURATION STREQUAL "RELEASE")
set(physx_release_type ${PHYSX_CONFIGURATION})
endif()
imstk_find_header(PhysX PxPhysicsAPI.h physx)
imstk_find_libary(PhysX PhysX _static${physx_release_type}_64 _staticDEBUG_64)#Different release and debug postfixes
imstk_find_libary(PhysX PhysXCharacterKinematic _static${physx_release_type}_64 _staticDEBUG_64)#Different release and debug postfixes
imstk_find_libary(PhysX PhysXCommon _static${physx_release_type}_64 _staticDEBUG_64)#Different release and debug postfixes
imstk_find_libary(PhysX PhysXCooking _static${physx_release_type}_64 _staticDEBUG_64)#Different release and debug postfixes
imstk_find_libary(PhysX PhysXExtensions _static${physx_release_type}_64 _staticDEBUG_64)#Different release and debug postfixes
imstk_find_libary(PhysX PhysXFoundation _static${physx_release_type}_64 _staticDEBUG_64)#Different release and debug postfixes
imstk_find_libary(PhysX PhysXPvdSDK _static${physx_release_type}_64 _staticDEBUG_64)#Different release and debug postfixes
imstk_find_libary(PhysX PhysXVehicle _static${physx_release_type}_64 _staticDEBUG_64)#Different release and debug postfixes
imstk_find_package(PhysX)
message(STATUS "PhysX include : ${PHYSX_INCLUDE_DIRS}")
message(STATUS "PhysX libraries : ${PHYSX_LIBRARIES}")
......@@ -9,6 +9,8 @@ macro(imstk_add_executable target)
if (VTK_VERSION VERSION_GREATER_EQUAL "8.90")
vtk_module_autoinit(TARGETS ${target} MODULES ${VTK_LIBRARIES})
endif()
set_target_properties(${target} PROPERTIES
DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${target}> ${iMSTK_INSTALL_BIN_DIR})
endmacro()
......@@ -66,14 +66,21 @@ endmacro()
macro(imstk_find_libary package library)
# Debug postfix argument is optional
set(release_postfix)
set(debug_postfix ${CMAKE_DEBUG_POSTFIX})
set (extra_macro_args ${ARGN})
# Did we get any optional args?
list(LENGTH extra_macro_args num_extra_args)
if (${num_extra_args} GREATER 0)
if (${num_extra_args} EQUAL 1)
list(GET extra_macro_args 0 debug_postfix)
string(STRIP ${debug_postfix} debug_postfix)
#message(STATUS "${package} changing debug_postfix to ${debug_postfix}")
elseif(${num_extra_args} EQUAL 2)
list(GET extra_macro_args 0 release_postfix)
string(STRIP ${release_postfix} release_postfix)
list(GET extra_macro_args 1 debug_postfix)
string(STRIP ${debug_postfix} debug_postfix)
message(STATUS "Looking for ${package} libraries ${library}${release_postfix} and ${library}${debug_postfix}")
endif()
# Should I look in system locations?
......@@ -96,17 +103,19 @@ macro(imstk_find_libary package library)
endif()
unset(${PACKAGE}_LIBRARY_${library}-RELEASE CACHE)
string(TOUPPER ${package} PACKAGE)
find_library(${PACKAGE}_LIBRARY_${library}-RELEASE
NAMES
${library}
lib${library}
${library}${release_postfix}
lib${library}${release_postfix}
PATHS
${_SEARCH_DIR}
${_SEARCH_DIR}/Release
NO_DEFAULT_PATH
)
unset(${PACKAGE}_LIBRARY_${library}-DEBUG CACHE)
find_library(${PACKAGE}_LIBRARY_${library}-DEBUG
NAMES
${library}${debug_postfix}
......@@ -118,12 +127,14 @@ macro(imstk_find_libary package library)
)
else()
unset(${PACKAGE}_LIBRARY_${library}-RELEASE CACHE)
find_library(${PACKAGE}_LIBRARY_${library}-RELEASE
NAMES
${library}
lib${library}
${library}${release_postfix}
lib${library}${release_postfix}
)
unset(${PACKAGE}_LIBRARY_${library}-DEBUG CACHE)
find_library(${PACKAGE}_LIBRARY_${library}-DEBUG
NAMES
${library}${debug_postfix}
......
......@@ -84,6 +84,11 @@ option(${PROJECT_NAME}_SUPERBUILD "Build ${PROJECT_NAME} and the projects it dep
if(${PROJECT_NAME}_SUPERBUILD)
# Select the release version of PhysX to use
set(${PROJECT_NAME}_PHYSX_CONFIGURATION "RELEASE" CACHE STRING "Select PhysX Library Type for Release and RelWithDebInfo builds")
set(PHYSX_RELEASE_TYPES "RELEASE;CHECKED;PROFILE" CACHE INTERNAL "List of available PhysX release library types")
set_property(CACHE ${PROJECT_NAME}_PHYSX_CONFIGURATION PROPERTY STRINGS ${PHYSX_RELEASE_TYPES})
#-----------------------------------------------------------------------------
# Define External dependencies
#-----------------------------------------------------------------------------
......@@ -106,6 +111,7 @@ if(${PROJECT_NAME}_SUPERBUILD)
imstk_define_dependency(glm)
imstk_define_dependency(imgui)
imstk_define_dependency(LibNiFalcon)
imstk_define_dependency(PhysX)
imstk_define_dependency(SCCD)
imstk_define_dependency(tbb)
imstk_define_dependency(VegaFEM)
......@@ -205,6 +211,12 @@ else()
remove_definitions( -DiMSTK_ENABLE_VR )
endif()
# Select the release version of PhysX to use
set(PHYSX_CONFIGURATION "${PHYSX_CONFIGURATION}" CACHE STRING "Select PhysX Library Type for Release and RelWithDebInfo builds")
set(PHYSX_RELEASE_TYPES "RELEASE;CHECKED;PROFILE" CACHE INTERNAL "List of available PhysX release library types")
set_property(CACHE PHYSX_CONFIGURATION PROPERTY STRINGS ${PHYSX_RELEASE_TYPES})
find_package(PhysX REQUIRED)
# SCCD
find_package( SCCD REQUIRED )
......
......@@ -85,6 +85,25 @@ This will checkout, build and link all iMSTK dependencies. When making changes t
Run CMake-GUI and follow the directions described [HERE](https://cmake.org/runningcmake/). You will have to choose which version of Visual Studio you'd like to use when configuring the project, make sure to select **Microsoft Visual Studio C++ 15 2017**. CMake will generate a `iMSTK.sln` solution file for Visual Studio at the top level. Open this file and build all targets, which will checkout, build and link all iMSTK dependencies. When making changes to iMSTK [base source code](/Base), you can then build from the `iMSTK.sln` solution file located in the `Innerbuild` directory.
If you would like to build on multiple cores add /MP[N] to CMAKE_CXX_FLAGS in CMake-GUI, where N is optional representing the number of cores (without N supplied, the build will use as many cores as available on the device).
* ##### PhysX Support
PhysX supports multiple build configurations, designed for different stages of development and deployment.
* The DEBUG build can be useful for error analysis, but contains asserts used for SDK development which some customers may find too intrusive for daily use. Optimizations are turned off for this configuration.
* The CHECKED build contains code to detect invalid parameters, API race conditions, and other incorrect uses of the API which might otherwise cause mysterious crashes or failures in simulation.
* The PROFILE build omits the checks, but still has PVD and memory instrumentation.
* The RELEASE build is built for minimal footprint and maximum speed. It omits most checks and instrumentation.
Simulation works the same way in all of them, and all are compiled with high optimization levels (except debug configuration).
Due to the fluid nature of development and the need to easily switch between these different configurations, the iMSTK superbuild will build ALL of these configurations, regardless of the provided BUILD_TYPE.
The iMSTK superbuild provides a CMake variable iMSTK_PHYSX_CONFIGURATION for you to specify the PhysX configuration it will use when building both Release and RelWithDebugInfo configurations
Using this variable, you may select RELEASE, CHECKED, or PROFILE, and iMSTK will link to those libraries.
Debug iMSTK builds will always link to the DEBUG PhysX libraries.
By default, RELEASE libraries will be used.
**Note We strongly recommend that you use the CHECKED build if you are developing new PhysX functionality in iMSTK.**
Once the superbuild is complete, you may also switch the PhysX library of the Innerbuild by selecting the desired configuration via the PHYSX_CONFIGURATION variable and regenerating the InnerBuild via CMake.
* ##### Phantom Omni Support
To support the [Geomagic Touch (formerly Sensable Phantom Omni)](http://www.geomagic.com/en/products/phantom-omni/overview) haptic device, follow the steps below:
1. Install the [OpenHaptics] SDK as well as the device drivers:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment