Skip to content

Commit 1687e56

Browse files
committed
Hack a redefinition of mapping of CMAKE_BUILD_TYPE for add_subdirectory cases.
1 parent 4bdc673 commit 1687e56

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

physx/CMakeLists.txt

+18
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ cmake_minimum_required(VERSION 3.13)
3131
# Same values than CMAKE_CONFIGURATION_TYPES
3232
# From https://gitlab.kitware.com/cmake/cmake/issues/19401
3333
get_property(multiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
34+
if(DEFINED CMAKE_BUILD_TYPE)
35+
# Because CMAKE_BUILD_TYPE is not standard for this project, we will restore the original
36+
# after configuring this project
37+
set(RESTORE_CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE})
38+
if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
39+
set(CMAKE_BUILD_TYPE "release" CACHE STRING "Choose the type of build.")
40+
else if(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
41+
set(CMAKE_BUILD_TYPE "profile" CACHE STRING "Choose the type of build.")
42+
else if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
43+
set(CMAKE_BUILD_TYPE "debug" CACHE STRING "Choose the type of build.")
44+
else()
45+
message(FATAL_ERROR "Unknown CMAKE_BUILD_TYPE: ${RESTORE_CMAKE_BUILD_TYPE}")
46+
endif()
47+
endif()
3448
if(NOT multiConfig AND NOT DEFINED CMAKE_BUILD_TYPE)
3549
set(default_build_type "release")
3650
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
@@ -176,4 +190,8 @@ if(PX_BUILDPUBLICSAMPLES)
176190
message("Added Samples")
177191
endif()
178192
endif()
193+
# Restore the CMAKE_BUILD_TYPE
194+
if(DEFINED RESTORE_CMAKE_BUILD_TYPE)
195+
set(CMAKE_BUILD_TYPE ${RESTORE_CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build.")
196+
endif()
179197

0 commit comments

Comments
 (0)