]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add CMake build type “CI” like “RelWithDebInfo” but without -DNDEBUG
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 23 Aug 2020 18:10:36 +0000 (20:10 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 23 Aug 2020 18:11:19 +0000 (20:11 +0200)
CMakeLists.txt
cmake/CIBuildType.cmake [new file with mode: 0644]

index e8ee6d0bbd1fee632022a98dec815f998c579172..38c347b532a41080837dc3eeb0387c98dddc37dd 100644 (file)
@@ -21,6 +21,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
 #
 include(StandardSettings)
 include(StandardWarnings)
+include(CIBuildType)
 include(DefaultBuildType)
 
 #
diff --git a/cmake/CIBuildType.cmake b/cmake/CIBuildType.cmake
new file mode 100644 (file)
index 0000000..963bc50
--- /dev/null
@@ -0,0 +1,31 @@
+# Add a build type called "CI" which is like RelWithDebInfo but with assertions
+# enabled, i.e. without passing -DNDEBUG to the compiler.
+
+set(CMAKE_CXX_FLAGS_CI ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} CACHE STRING
+ "Flags used by the C++ compiler during CI builds."
+  FORCE)
+set(CMAKE_C_FLAGS_CI ${CMAKE_C_FLAGS_RELWITHDEBINFO} CACHE STRING
+  "Flags used by the C compiler during CI builds."
+  FORCE)
+set(CMAKE_EXE_LINKER_FLAGS_CI
+  ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} CACHE STRING
+  "Flags used for linking binaries during CI builds."
+  FORCE)
+set(CMAKE_SHARED_LINKER_FLAGS_CI
+  ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} CACHE STRING
+  "Flags used by the shared libraries linker during CI builds."
+  FORCE)
+mark_as_advanced(
+  CMAKE_CXX_FLAGS_CI
+  CMAKE_C_FLAGS_CI
+  CMAKE_EXE_LINKER_FLAGS_CI
+  CMAKE_SHARED_LINKER_FLAGS_CI)
+# Update the documentation string of CMAKE_BUILD_TYPE for GUIs
+set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
+  "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel CI."
+  FORCE)
+
+string(REPLACE -DNDEBUG "" CMAKE_CXX_FLAGS_CI ${CMAKE_CXX_FLAGS_CI})
+string(REPLACE -DNDEBUG "" CMAKE_C_FLAGS_CI ${CMAKE_C_FLAGS_CI})
+string(STRIP ${CMAKE_CXX_FLAGS_CI} CMAKE_CXX_FLAGS_CI)
+string(STRIP ${CMAKE_C_FLAGS_CI} CMAKE_C_FLAGS_CI)