@@ -31,6 +31,20 @@ cmake_minimum_required(VERSION 3.13)
31
31
# Same values than CMAKE_CONFIGURATION_TYPES
32
32
# From https://gitlab.kitware.com/cmake/cmake/issues/19401
33
33
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 ()
34
48
if (NOT multiConfig AND NOT DEFINED CMAKE_BUILD_TYPE )
35
49
set (default_build_type "release" )
36
50
message (STATUS "Setting build type to '${default_build_type} ' as none was specified." )
@@ -176,4 +190,8 @@ if(PX_BUILDPUBLICSAMPLES)
176
190
message ("Added Samples" )
177
191
endif ()
178
192
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 ()
179
197
0 commit comments