Skip to content

Commit 1db08c8

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

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

physx/CMakeLists.txt

+16
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ 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+
endif()
45+
endif()
3446
if(NOT multiConfig AND NOT DEFINED CMAKE_BUILD_TYPE)
3547
set(default_build_type "release")
3648
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
@@ -176,4 +188,8 @@ if(PX_BUILDPUBLICSAMPLES)
176188
message("Added Samples")
177189
endif()
178190
endif()
191+
# Restore the CMAKE_BUILD_TYPE
192+
if(DEFINED RESTORE_CMAKE_BUILD_TYPE)
193+
set(CMAKE_BUILD_TYPE ${RESTORE_CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build.")
194+
endif()
179195

0 commit comments

Comments
 (0)