]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
CMakeLists: Fallback to RelWithDebInfo
authorMatan Breizman <mbreizma@redhat.com>
Tue, 4 Feb 2025 10:24:43 +0000 (10:24 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Thu, 8 May 2025 12:55:00 +0000 (12:55 +0000)
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 <mbreizma@redhat.com>
(cherry picked from commit c5766bb2c48634925c8685b779ec814edc43d17b)

CMakeLists.txt

index dc411ddfa7d4609fbdc7ae22a984bc09d33cc81e..05260ffd2ce6c4e3377832ac3490731f8eba78da 100644 (file)
@@ -16,12 +16,14 @@ if(NOT CMAKE_BUILD_TYPE)
   if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
     message(WARNING "CMAKE_BUILD_TYPE not specified, assuming CMAKE_BUILD_TYPE=Debug because .git exists.")
     set(default_build_type "Debug")
-    set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
-        STRING "Default BUILD_TYPE is Debug, other options are: RelWithDebInfo, Release, and MinSizeRel." FORCE)
   else()
-    message(WARNING "CMAKE_BUILD_TYPE not specified, leaving unset because .git does NOT exist.")
+    message(WARNING "CMAKE_BUILD_TYPE not specified, setting to RelWithDebInfo because .git does NOT exist.")
+    set(default_build_type "RelWithDebInfo")
   endif()
+  set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
+  STRING "BUILD_TYPE is ${default_build_type}, other options are: RelWithDebInfo, Release, and MinSizeRel." FORCE)
 endif()
+message(STATUS "BUILD_TYPE is ${CMAKE_BUILD_TYPE}")
 
 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
   set(LINUX ON)