]> git.apps.os.sepia.ceph.com Git - ceph-ci.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:38:11 +0000 (12:38 +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>
CMakeLists.txt

index 8ded471e2ded19934a2310df5dbed14ddd3c18cb..9d81e8f391b96f1f2404ff491af580d73de2d279 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)