Skip to content

Commit d0b4ff4

Browse files
committed
CMakeLists: Fallback to RelWithDebInfo
Currently, if .git exists, we set CMAKE_BUILD_TYPE=Debug. Otherwise, we leave it empty and no optimization flags will be used. With this change, the fallback CMAKE_BUILD_TYPE is set to RelWithDebInfo instead. From CMAKE_BUILD_TYPE manual: The default value is often an empty string, but this is usually not desirable and one of the other standard build types is usually more appropriate. Note: One notable change is that -DNDEBUG will now be defined. Signed-off-by: Matan Breizman <[email protected]> (cherry picked from commit c5766bb)
1 parent 2ed4296 commit d0b4ff4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ if(NOT CMAKE_BUILD_TYPE)
1616
if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
1717
message(WARNING "CMAKE_BUILD_TYPE not specified, assuming CMAKE_BUILD_TYPE=Debug because .git exists.")
1818
set(default_build_type "Debug")
19-
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
20-
STRING "Default BUILD_TYPE is Debug, other options are: RelWithDebInfo, Release, and MinSizeRel." FORCE)
2119
else()
22-
message(WARNING "CMAKE_BUILD_TYPE not specified, leaving unset because .git does NOT exist.")
20+
message(WARNING "CMAKE_BUILD_TYPE not specified, setting to RelWithDebInfo because .git does NOT exist.")
21+
set(default_build_type "RelWithDebInfo")
2322
endif()
23+
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
24+
STRING "BUILD_TYPE is ${default_build_type}, other options are: RelWithDebInfo, Release, and MinSizeRel." FORCE)
2425
endif()
26+
message(STATUS "BUILD_TYPE is ${CMAKE_BUILD_TYPE}")
2527

2628
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
2729
set(LINUX ON)

0 commit comments

Comments
 (0)