|
| 1 | +## Redistribution and use in source and binary forms, with or without |
| 2 | +## modification, are permitted provided that the following conditions |
| 3 | +## are met: |
| 4 | +## * Redistributions of source code must retain the above copyright |
| 5 | +## notice, this list of conditions and the following disclaimer. |
| 6 | +## * Redistributions in binary form must reproduce the above copyright |
| 7 | +## notice, this list of conditions and the following disclaimer in the |
| 8 | +## documentation and/or other materials provided with the distribution. |
| 9 | +## * Neither the name of NVIDIA CORPORATION nor the names of its |
| 10 | +## contributors may be used to endorse or promote products derived |
| 11 | +## from this software without specific prior written permission. |
| 12 | +## |
| 13 | +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY |
| 14 | +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
| 17 | +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | +## |
| 25 | +## Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved. |
| 26 | + |
| 27 | +cmake_minimum_required(VERSION 3.13) |
| 28 | +project(PhysX C CXX) |
| 29 | +cmake_policy(SET CMP0057 NEW) # Enable IN_LIST |
| 30 | +cmake_policy(SET CMP0077 NEW) # option() does nothing when variable is alredy set |
| 31 | + |
| 32 | +# PhysXSDK options: |
| 33 | +option(PX_BUILDSNIPPETS "Generate the snippets" OFF) |
| 34 | +option(PX_CMAKE_SUPPRESS_REGENERATION "Disable zero_check projects" OFF) |
| 35 | + |
| 36 | +# PhysX options: |
| 37 | +option(PX_SCALAR_MATH "Disable SIMD math" OFF) |
| 38 | +option(PX_GENERATE_STATIC_LIBRARIES "Generate static libraries" OFF) |
| 39 | +option(PX_EXPORT_LOWLEVEL_PDB "Export low level pdb's" OFF) |
| 40 | +option(PX_GENERATE_GPU_PROJECTS_ONLY "Generate GPU projects only. (Untested)" OFF) |
| 41 | +mark_as_advanced(PX_GENERATE_GPU_PROJECTS_ONLY) |
| 42 | + |
| 43 | +set(PUBLIC_RELEASE OFF) |
| 44 | + |
| 45 | +# Enable folder properties |
| 46 | +set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 47 | + |
| 48 | +if(CMAKE_CONFIGURATION_TYPES) |
| 49 | + set(CMAKE_CONFIGURATION_TYPES debug checked profile release) |
| 50 | + set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING |
| 51 | + "Reset config to what we need" |
| 52 | + FORCE) |
| 53 | + |
| 54 | + set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "") |
| 55 | + set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "") |
| 56 | + |
| 57 | + # XXX(phcerdan) PDB are not for consumers, ignore this line |
| 58 | + # Build PDBs for all configurations. |
| 59 | + # set(CMAKE_SHARED_LINKER_FLAGS "/DEBUG") |
| 60 | +endif() |
| 61 | + |
| 62 | +# Disable zero_check projects. The default for Switch and XboxOne is ON. |
| 63 | +if(PX_CMAKE_SUPPRESS_REGENERATION) |
| 64 | + set(CMAKE_SUPPRESS_REGENERATION TRUE) |
| 65 | +endif() |
| 66 | + |
| 67 | +### Set PHYSX_ROOT_DIR to PROJECT_SOURCE_DIR |
| 68 | +if(DEFINED PHYSX_ROOT_DIR) |
| 69 | + message(WARNING "PHYSX_ROOT_DIR is externally defined, but it will be overwritten in this CMakeLists. DEPRECATED") |
| 70 | + message("PHYSX_ROOT_DIR (externally set --not used--): ${PHYSX_ROOT_DIR}") |
| 71 | + message("PHYSX_ROOT_DIR (currently set): ${PROJECT_SOURCE_DIR}") |
| 72 | +endif() |
| 73 | +set(PHYSX_ROOT_DIR ${PROJECT_SOURCE_DIR}) |
| 74 | + |
| 75 | +### Set TARGET_BUILD_PLATFORM using CMAKE_SYSTEM_NAME |
| 76 | +# for compatibility with current CMake files, |
| 77 | +# for cross-complation, CMAKE_SYSTEM_NAME can be set when running cmake |
| 78 | +if(DEFINED TARGET_BUILD_PLATFORM) |
| 79 | + if(TARGET_BUILD_PLATFORM STREQUAL "switch" OR |
| 80 | + TARGET_BUILD_PLATFORM STREQUAL "playstation" OR |
| 81 | + TARGET_BUILD_PLATFORM STREQUAL "ios") |
| 82 | + message(FATAL_ERROR "switch, playstation and ios builds are not valid because have not been tested. Use official repository for these.") |
| 83 | + endif() |
| 84 | + message(INFO "TARGET_BUILD_PLATFORM (externally set --not used--): ${TARGET_BUILD_PLATFORM}") |
| 85 | +endif() |
| 86 | + |
| 87 | +set(TARGET_BUILD_PLATFORM "") |
| 88 | +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") |
| 89 | + set(TARGET_BUILD_PLATFORM "windows") |
| 90 | +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 91 | + set(TARGET_BUILD_PLATFORM "linux") |
| 92 | +elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") |
| 93 | + set(TARGET_BUILD_PLATFORM "mac") |
| 94 | +elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") |
| 95 | + set(TARGET_BUILD_PLATFORM "android") |
| 96 | +endif() |
| 97 | + |
| 98 | +### Set CMake folders |
| 99 | +set(CMAKEMODULES_PATH ${PROJECT_SOURCE_DIR}/../externals/cmakemodules/ CACHE INTERNAL "Path to CMakeModules") |
| 100 | +set(CMAKEMODULES_NAME "CMakeModules" CACHE INTERNAL "CMakeModules name") |
| 101 | +set(CMAKEMODULES_VERSION "1.27" CACHE INTERNAL "CMakeModules version from generation batch") |
| 102 | +# CMAKE_MODULE_PATH is empty by default |
| 103 | +list(APPEND CMAKE_MODULE_PATH ${CMAKEMODULES_PATH}) |
| 104 | + |
| 105 | +### Set platform specific files |
| 106 | +set(PROJECT_CMAKE_FILES_DIR source/compiler/cmake) |
| 107 | +# The following files define all the flags specific to platforms, compilers and build configurations. |
| 108 | +# The file is included in the source/ subdirectory |
| 109 | +set(PLATFORM_CMAKE_FILES_DIR "${PHYSX_ROOT_DIR}/${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}") |
| 110 | +set(PLATFORM_CMAKELISTS "${PLATFORM_CMAKE_FILES_DIR}/CMakeLists.txt") |
| 111 | + |
| 112 | +SET(CMAKE_POSITION_INDEPENDENT_CODE ON) |
| 113 | + |
| 114 | +# INSTALL PATHS |
| 115 | +if(WIN32) |
| 116 | + SET(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../install/windows/PhysX") |
| 117 | +elseif(APPLE) |
| 118 | + SET(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../install/mac/PhysX") |
| 119 | +else() |
| 120 | + SET(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../install/linux/PhysX") |
| 121 | +endif() |
| 122 | +SET(PHYSX_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/PhysX CACHE INTERNAL "Install path to install PhysX") |
| 123 | +MESSAGE(STATUS "PHYSX_INSTALL_PREFIX: " ${PHYSX_INSTALL_PREFIX}) |
| 124 | + |
| 125 | +# Set PX_ROOT_LIB_DIR (used in cmake files) |
| 126 | +string(TOLOWER ${CMAKE_C_COMPILER_ID} compiler_id) |
| 127 | +# No need to add TARGET_BUILD_PLATFORM and compiler_id in the folder structure |
| 128 | +# set(PX_ROOT_LIB_DIR "${PHYSX_INSTALL_PREFIX}/bin/${TARGET_BUILD_PLATFORM}\.${compiler_id}") |
| 129 | +set(PX_ROOT_LIB_DIR "${PHYSX_INSTALL_PREFIX}/bin") |
| 130 | + |
| 131 | +# We add CMakeLists.txt in the source folders, following standard CMake practices |
| 132 | +# Add PhysX SDK Source code to solution |
| 133 | +set(BUILD_SOURCE_FOLDER ${CMAKE_CURRENT_BINARY_DIR}/sdk_source_bin) |
| 134 | +add_subdirectory(source ${BUILD_SOURCE_FOLDER}) |
| 135 | + |
| 136 | +if(PX_BUILDSNIPPETS) |
| 137 | + # TODO(phcerdan) this is the part to simplify |
| 138 | + # Add Snippets projects into the solution |
| 139 | + add_subdirectory(${PHYSX_ROOT_DIR}/snippets/compiler/cmake ${CMAKE_CURRENT_BINARY_DIR}/sdk_snippets_bin) |
| 140 | + |
| 141 | + message("Added Snippets") |
| 142 | +endif() |
0 commit comments