Skip to content

Commit c0dc9e7

Browse files
authored
Merge pull request #5646 from tautschnig/cmake-default
CMake builds: set a default build type (Release)
2 parents 4cc9611 + 2a17a11 commit c0dc9e7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
cmake_minimum_required(VERSION 3.2)
22

3+
# Build a Release version by default (default build flags for each build type
4+
# are configured below).
5+
if (NOT EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt)
6+
if (NOT CMAKE_BUILD_TYPE)
7+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
8+
endif()
9+
endif()
310

411
# Grab the current CBMC version from config.inc
512
# We do this so we have a matching cbmc version between the Makefile build and

COMPILING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ require manual modification of build files.
266266
Generally it is not necessary to manually specify individual compiler or
267267
linker flags, as CMake defines a number of "build modes" including Debug and
268268
Release modes. To build in a particular mode, add the flag
269-
`-DCMAKE_BUILD_TYPE=Debug` (or `Release`) to the initial invocation.
269+
`-DCMAKE_BUILD_TYPE=Debug` (or `RelWithDebInfo`) to the initial invocation.
270+
The default is to perform an optimized build via the `Release` configuration.
270271
271272
If you *do* need to manually add flags, use `-DCMAKE_CXX_FLAGS=...` and
272273
`-DCMAKE_EXE_LINKER_FLAGS=...`. This is useful for enabling clang's

0 commit comments

Comments
 (0)