forked from NVIDIA-Omniverse/PhysX
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15465c0
commit e05bcd7
Showing
5 changed files
with
321 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
## Redistribution and use in source and binary forms, with or without | ||
## modification, are permitted provided that the following conditions | ||
## are met: | ||
## * Redistributions of source code must retain the above copyright | ||
## notice, this list of conditions and the following disclaimer. | ||
## * Redistributions in binary form must reproduce the above copyright | ||
## notice, this list of conditions and the following disclaimer in the | ||
## documentation and/or other materials provided with the distribution. | ||
## * Neither the name of NVIDIA CORPORATION nor the names of its | ||
## contributors may be used to endorse or promote products derived | ||
## from this software without specific prior written permission. | ||
## | ||
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY | ||
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
## | ||
## Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved. | ||
|
||
cmake_minimum_required(VERSION 3.13) | ||
project(PhysX C CXX) | ||
cmake_policy(SET CMP0057 NEW) # Enable IN_LIST | ||
cmake_policy(SET CMP0077 NEW) # option() does nothing when variable is alredy set | ||
|
||
# PhysXSDK options: | ||
option(PX_BUILDSNIPPETS "Generate the snippets" OFF) | ||
option(PX_CMAKE_SUPPRESS_REGENERATION "Disable zero_check projects" OFF) | ||
|
||
# PhysX options: | ||
option(PX_SCALAR_MATH "Disable SIMD math" OFF) | ||
option(PX_GENERATE_STATIC_LIBRARIES "Generate static libraries" OFF) | ||
option(PX_EXPORT_LOWLEVEL_PDB "Export low level pdb's" OFF) | ||
option(PX_GENERATE_GPU_PROJECTS_ONLY "Generate GPU projects only. (Untested)" OFF) | ||
mark_as_advanced(PX_GENERATE_GPU_PROJECTS_ONLY) | ||
|
||
set(PUBLIC_RELEASE OFF) | ||
|
||
# Enable folder properties | ||
set_property(GLOBAL PROPERTY USE_FOLDERS ON) | ||
|
||
if(CMAKE_CONFIGURATION_TYPES) | ||
set(CMAKE_CONFIGURATION_TYPES debug checked profile release) | ||
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING | ||
"Reset config to what we need" | ||
FORCE) | ||
|
||
set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "") | ||
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "") | ||
|
||
# XXX(phcerdan) PDB are not for consumers, ignore this line | ||
# Build PDBs for all configurations. | ||
# set(CMAKE_SHARED_LINKER_FLAGS "/DEBUG") | ||
endif() | ||
|
||
# Disable zero_check projects. The default for Switch and XboxOne is ON. | ||
if(PX_CMAKE_SUPPRESS_REGENERATION) | ||
set(CMAKE_SUPPRESS_REGENERATION TRUE) | ||
endif() | ||
|
||
### Set PHYSX_ROOT_DIR to PROJECT_SOURCE_DIR | ||
if(DEFINED PHYSX_ROOT_DIR) | ||
message(WARNING "PHYSX_ROOT_DIR is externally defined, but it will be overwritten in this CMakeLists. DEPRECATED") | ||
message("PHYSX_ROOT_DIR (externally set --not used--): ${PHYSX_ROOT_DIR}") | ||
message("PHYSX_ROOT_DIR (currently set): ${PROJECT_SOURCE_DIR}") | ||
endif() | ||
set(PHYSX_ROOT_DIR ${PROJECT_SOURCE_DIR}) | ||
|
||
### Set TARGET_BUILD_PLATFORM using CMAKE_SYSTEM_NAME | ||
# for compatibility with current CMake files, | ||
# for cross-complation, CMAKE_SYSTEM_NAME can be set when running cmake | ||
if(DEFINED TARGET_BUILD_PLATFORM) | ||
if(TARGET_BUILD_PLATFORM STREQUAL "switch" OR | ||
TARGET_BUILD_PLATFORM STREQUAL "playstation" OR | ||
TARGET_BUILD_PLATFORM STREQUAL "ios") | ||
message(FATAL_ERROR "switch, playstation and ios builds are not valid because have not been tested. Use official repository for these.") | ||
endif() | ||
message(INFO "TARGET_BUILD_PLATFORM (externally set --not used--): ${TARGET_BUILD_PLATFORM}") | ||
endif() | ||
|
||
set(TARGET_BUILD_PLATFORM "") | ||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows") | ||
set(TARGET_BUILD_PLATFORM "windows") | ||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") | ||
set(TARGET_BUILD_PLATFORM "linux") | ||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") | ||
set(TARGET_BUILD_PLATFORM "mac") | ||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") | ||
set(TARGET_BUILD_PLATFORM "android") | ||
endif() | ||
|
||
### Set CMake folders | ||
set(CMAKEMODULES_PATH ${PROJECT_SOURCE_DIR}/../externals/cmakemodules/ CACHE INTERNAL "Path to CMakeModules") | ||
set(CMAKEMODULES_NAME "CMakeModules" CACHE INTERNAL "CMakeModules name") | ||
set(CMAKEMODULES_VERSION "1.27" CACHE INTERNAL "CMakeModules version from generation batch") | ||
# CMAKE_MODULE_PATH is empty by default | ||
list(APPEND CMAKE_MODULE_PATH ${CMAKEMODULES_PATH}) | ||
|
||
### Set platform specific files | ||
set(PROJECT_CMAKE_FILES_DIR source/compiler/cmake) | ||
# The following files define all the flags specific to platforms, compilers and build configurations. | ||
# The file is included in the source/ subdirectory | ||
set(PLATFORM_CMAKE_FILES_DIR "${PHYSX_ROOT_DIR}/${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}") | ||
set(PLATFORM_CMAKELISTS "${PLATFORM_CMAKE_FILES_DIR}/CMakeLists.txt") | ||
|
||
SET(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
|
||
# INSTALL PATHS | ||
if(WIN32) | ||
SET(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../install/windows/PhysX") | ||
elseif(APPLE) | ||
SET(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../install/mac/PhysX") | ||
else() | ||
SET(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../install/linux/PhysX") | ||
endif() | ||
SET(PHYSX_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/PhysX CACHE INTERNAL "Install path to install PhysX") | ||
MESSAGE(STATUS "PHYSX_INSTALL_PREFIX: " ${PHYSX_INSTALL_PREFIX}) | ||
|
||
# Set PX_ROOT_LIB_DIR (used in cmake files) | ||
string(TOLOWER ${CMAKE_C_COMPILER_ID} compiler_id) | ||
# No need to add TARGET_BUILD_PLATFORM and compiler_id in the folder structure | ||
# set(PX_ROOT_LIB_DIR "${PHYSX_INSTALL_PREFIX}/bin/${TARGET_BUILD_PLATFORM}\.${compiler_id}") | ||
set(PX_ROOT_LIB_DIR "${PHYSX_INSTALL_PREFIX}/bin") | ||
|
||
# We add CMakeLists.txt in the source folders, following standard CMake practices | ||
# Add PhysX SDK Source code to solution | ||
set(BUILD_SOURCE_FOLDER ${CMAKE_CURRENT_BINARY_DIR}/sdk_source_bin) | ||
add_subdirectory(source ${BUILD_SOURCE_FOLDER}) | ||
|
||
if(PX_BUILDSNIPPETS) | ||
# TODO(phcerdan) this is the part to simplify | ||
# Add Snippets projects into the solution | ||
add_subdirectory(${PHYSX_ROOT_DIR}/snippets/compiler/cmake ${CMAKE_CURRENT_BINARY_DIR}/sdk_snippets_bin) | ||
|
||
message("Added Snippets") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
MESSAGE(STATUS "PhysX Build Platform: " ${TARGET_BUILD_PLATFORM}) | ||
MESSAGE(STATUS " CXX Compiler: " ${CMAKE_CXX_COMPILER}) | ||
|
||
# Avoid including NvidiaBuildOptions: {{{ | ||
option(NV_USE_STATIC_WINCRT "Use the statically linked windows CRT" ON) | ||
mark_as_advanced(NV_USE_STATIC_WINCRT) | ||
option(NV_USE_DEBUG_WINCRT "Use the debug version of the CRT" OFF) | ||
mark_as_advanced(NV_USE_DEBUG_WINCRT) | ||
set(NV_USE_GAMEWORKS_OUTPUT_DIRS ON) | ||
|
||
include(GetCompilerAndPlatform) | ||
if(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
set(LIBPATH_SUFFIX "64") | ||
# Set default exe suffix. Unset on platforms that don't need it. Include underscore since it's optional | ||
set(EXE_SUFFIX "_64") | ||
set(RESOURCE_LIBPATH_SUFFIX "x64") | ||
else() | ||
set(LIBPATH_SUFFIX "32") | ||
# Set default exe suffix. Unset on platforms that don't need it. Include underscore since it's optional | ||
set(EXE_SUFFIX "_32") | ||
set(RESOURCE_LIBPATH_SUFFIX "x86") | ||
endif() | ||
# Set the WINCRT_DEBUG and WINCRT_NDEBUG variables for use in project compile settings | ||
# Really only relevant to windows | ||
set(DISABLE_ITERATOR_DEBUGGING "/D \"_HAS_ITERATOR_DEBUGGING=0\" /D \"_ITERATOR_DEBUG_LEVEL=0\"") | ||
set(DISABLE_ITERATOR_DEBUGGING_CUDA "-D_HAS_ITERATOR_DEBUGGING=0 -D_ITERATOR_DEBUG_LEVEL=0") | ||
set(CRT_DEBUG_FLAG "/D \"_DEBUG\"") | ||
set(CRT_NDEBUG_FLAG "/D \"NDEBUG\"") | ||
# Need a different format for CUDA | ||
set(CUDA_DEBUG_FLAG "-DNDEBUG ${DISABLE_ITERATOR_DEBUGGING_CUDA}") | ||
set(CUDA_NDEBUG_FLAG "-DNDEBUG") | ||
IF(NV_USE_STATIC_WINCRT) | ||
SET(WINCRT_NDEBUG "/MT ${DISABLE_ITERATOR_DEBUGGING} ${CRT_NDEBUG_FLAG}" CACHE INTERNAL "Windows CRT build setting") | ||
SET(CUDA_CRT_COMPILE_OPTIONS_NDEBUG "/MT") | ||
|
||
IF (NV_USE_DEBUG_WINCRT) | ||
SET(CUDA_DEBUG_FLAG "-D_DEBUG") | ||
SET(WINCRT_DEBUG "/MTd ${CRT_DEBUG_FLAG}" CACHE INTERNAL "Windows CRT build setting") | ||
SET(CUDA_CRT_COMPILE_OPTIONS_DEBUG "/MTd") | ||
ELSE() | ||
SET(WINCRT_DEBUG "/MT ${DISABLE_ITERATOR_DEBUGGING} ${CRT_NDEBUG_FLAG}" CACHE INTERNAL "Windows CRT build setting") | ||
SET(CUDA_CRT_COMPILE_OPTIONS_DEBUG "/MT") | ||
ENDIF() | ||
ELSE() | ||
SET(WINCRT_NDEBUG "/MD ${DISABLE_ITERATOR_DEBUGGING} ${CRT_NDEBUG_FLAG}") | ||
SET(CUDA_CRT_COMPILE_OPTIONS_NDEBUG "/MD") | ||
|
||
IF(NV_USE_DEBUG_WINCRT) | ||
SET(CUDA_DEBUG_FLAG "-D_DEBUG") | ||
SET(WINCRT_DEBUG "/MDd ${CRT_DEBUG_FLAG}" CACHE INTERNAL "Windows CRT build setting") | ||
SET(CUDA_CRT_COMPILE_OPTIONS_DEBUG "/MDd") | ||
ELSE() | ||
SET(WINCRT_DEBUG "/MD ${DISABLE_ITERATOR_DEBUGGING} ${CRT_NDEBUG_FLAG}" CACHE INTERNAL "Windows CRT build setting") | ||
SET(CUDA_CRT_COMPILE_OPTIONS_DEBUG "/MD") | ||
ENDIF() | ||
ENDIF() | ||
|
||
# platform_bin_name is of type linux.clang, win.x86_64.vc140 etc. | ||
GetPlatformBinName(PLATFORM_BIN_NAME ${LIBPATH_SUFFIX}) | ||
message(STATUS "PLATFORM_BIN_NAME: ${PLATFORM_BIN_NAME}") | ||
# }}} End NvidiaBuildOptions replacement | ||
|
||
set(physx_build_targets_file "${CMAKE_CURRENT_BINARY_DIR}/PhysXTargets.cmake") | ||
set(install_cmake_dir "${PX_ROOT_LIB_DIR}/cmake/physx") | ||
|
||
# Include the platform specific CMakeLists | ||
message(STATUS "PLATFORM_CMAKELISTS: ${PLATFORM_CMAKELISTS}") | ||
include(${PLATFORM_CMAKELISTS}) | ||
|
||
# generate PxPhysXConfig.h header that will contain PhysX configuration defines like PX_PHYSX_STATIC_LIB | ||
# XXX(phcerdan) the template is actually empty? Maybe populated after? No harm having an empty header meanwhile. | ||
SET(HEADER_GUARD_NAME "CONFIG") | ||
SET(HEADER_CONTENT "") | ||
configure_file(${CMAKEMODULES_PATH}/template/PxIncludeTemplate.h ${PHYSX_ROOT_DIR}/include/PxConfig.h) | ||
|
||
### Move libPhysXGPU from source tree to build and install tree: | ||
# libPhysXGPU libraries are in the repository (/bin) but the CUDA code is not open | ||
# XXX(phcerdan) Nvidia does not provides GNU (gcc) GPU libaries, only clang. | ||
# XXX(phcerdan) I guess both compilers are ABI compatible, but not explicitly tested in this codebase | ||
# XXX(phcerdan) GCC in linux is not an option right now upstream | ||
|
||
include(GetCompilerAndPlatform) | ||
if(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
set(LIBPATH_SUFFIX "64") | ||
# Set default exe suffix. Unset on platforms that don't need it. Include underscore since it's optional | ||
set(EXE_SUFFIX "_64") | ||
else() | ||
set(LIBPATH_SUFFIX "32") | ||
# Set default exe suffix. Unset on platforms that don't need it. Include underscore since it's optional | ||
set(EXE_SUFFIX "_32") | ||
endif() | ||
# platform_bin_name is of type linux.clang, win.x86_64.vc140 etc. | ||
GetPlatformBinName(PLATFORM_BIN_NAME ${LIBPATH_SUFFIX}) | ||
message(STATUS "PLATFORM_BIN_NAME: ${PLATFORM_BIN_NAME}") | ||
|
||
# set(gpu_source_libs_folder "${CMAKE_SOURCE_DIR}/bin/${PLATFORM_BIN_NAME}/$<CONFIG>") | ||
# set(gpu_source_libs_folder "${CMAKE_SOURCE_DIR}/bin/${PLATFORM_BIN_NAME}/${CMAKE_BUILD_TYPE}") | ||
# Build tree | ||
# file(COPY ${CMAKE_SOURCE_DIR}/bin/${PLATFORM_BIN_NAME}/$<CONFIG> | ||
# DESTINATION "${BUILD_SOURCE_FOLDER}") | ||
# Install tree | ||
install(FILES ${CMAKE_SOURCE_DIR}/bin/${PLATFORM_BIN_NAME}/$<CONFIG> | ||
# DESTINATION "${PHYSX_INSTALL_PREFIX}/bin/${CMAKE_BUILD_TYPE}") | ||
DESTINATION "${PHYSX_INSTALL_PREFIX}/bin/$<CONFIG>") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@PACKAGE_INIT@ | ||
|
||
include(CMakeFindDependencyMacro) | ||
|
||
# get_filename_component(PhysX_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) | ||
if(NOT TARGET PhysX) | ||
include ("@PACKAGE_PhysX_TARGETS_FILE@") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.