diff --git a/CMakeLists.txt b/CMakeLists.txt index 21fb43623f0..38ad7ab671e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,12 @@ cmake_minimum_required(VERSION 3.2) +# Build a Release version by default (default build flags for each build type +# are configured below). +if (NOT EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt) + if (NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) + endif() +endif() # Grab the current CBMC version from config.inc # We do this so we have a matching cbmc version between the Makefile build and diff --git a/COMPILING.md b/COMPILING.md index e4e5dece720..57a3b78eda5 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -266,7 +266,8 @@ require manual modification of build files. Generally it is not necessary to manually specify individual compiler or linker flags, as CMake defines a number of "build modes" including Debug and Release modes. To build in a particular mode, add the flag - `-DCMAKE_BUILD_TYPE=Debug` (or `Release`) to the initial invocation. + `-DCMAKE_BUILD_TYPE=Debug` (or `RelWithDebInfo`) to the initial invocation. + The default is to perform an optimized build via the `Release` configuration. If you *do* need to manually add flags, use `-DCMAKE_CXX_FLAGS=...` and `-DCMAKE_EXE_LINKER_FLAGS=...`. This is useful for enabling clang's