From 6c93e07ffa5ca5a6a40e38bef62ba0616f950a13 Mon Sep 17 00:00:00 2001 From: msclock Date: Fri, 6 Sep 2024 22:52:44 +0800 Subject: [PATCH] perf: switch CMAKE_BUILD_TYPE to Debug by default (#363) Signed-off-by: msclock --- README.md | 2 +- cmake/presets/base.json | 2 +- cmake/vcpkg/scripts/build_type.cmake | 6 ++---- docs/tutorials/building.md | 2 +- template/README.md.jinja | 2 +- .../building.md | 2 +- template/cmake/presets/base.json | 2 +- template/cmake/vcpkg/scripts/build_type.cmake | 6 ++---- 8 files changed, 10 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 27965340..06dad3cf 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ A continuously evolving basic template for cpp development. - Supports `code coverage` with [lcov](https://github.com/linux-test-project/lcov), [gcovr](https://github.com/gcovr/gcovr), llvm-cov, and [opencppcoverage](https://github.com/OpenCppCoverage/OpenCppCoverage). - Supports `hardening compilation `for MSVC, Clang, and GCC. - Provides compile, header, application target generation. - - Build with preset build types: Debug, Release, RelWithDebInfo(Default), MinSizeRel. + - Build with preset build types: Debug(Default), Release, RelWithDebInfo, MinSizeRel. - Supports package managers: [vcpkg](https://github.com/microsoft/vcpkg), [conan](https://github.com/conan-io/cmake-conan), and [cpm](https://github.com/cpm-cmake/CPM.cmake). - Use [cmake-registry](https://github.com/msclock/cmake-registry) to provide various cmake modules and scripts. - Lint tool `pre-commit` integration with various linters, including [clang-format](https://github.com/pre-commit/mirrors-clang-format), [codespell](https://github.com/codespell-project/codespell), [markdownlint](https://github.com/igorshubovych/markdownlint-cli), and more. diff --git a/cmake/presets/base.json b/cmake/presets/base.json index 8238cb7f..e929d276 100644 --- a/cmake/presets/base.json +++ b/cmake/presets/base.json @@ -17,7 +17,7 @@ "cacheVariables": { "CMAKE_EXPORT_COMPILE_COMMANDS": true, "CMAKE_COMPILE_WARNING_AS_ERROR": false, - "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "CMAKE_BUILD_TYPE": "Debug", "CMAKE_VERBOSE_MAKEFILE": "FALSE" } } diff --git a/cmake/vcpkg/scripts/build_type.cmake b/cmake/vcpkg/scripts/build_type.cmake index 8a608433..a49dad63 100644 --- a/cmake/vcpkg/scripts/build_type.cmake +++ b/cmake/vcpkg/scripts/build_type.cmake @@ -6,12 +6,10 @@ This module initializes the build type. ]] if(NOT CMAKE_BUILD_TYPE) - message( - STATUS "Setting CMAKE_BUILD_TYPE to 'RelWithDebInfo' as none was specified." - ) + message(STATUS "Setting CMAKE_BUILD_TYPE to 'Debug' as none was specified.") endif() set(CMAKE_BUILD_TYPE - RelWithDebInfo + Debug CACHE STRING "Choose the type of build.") # Set the possible values of build type for cmake-gui, ccmake diff --git a/docs/tutorials/building.md b/docs/tutorials/building.md index 894c8f53..752129f0 100644 --- a/docs/tutorials/building.md +++ b/docs/tutorials/building.md @@ -61,7 +61,7 @@ The Table below shows the necessary variables for different platforms and config - `VCPKG_ROOT` and `VCPKG_INSTALLATION_ROOT` are same and both are optional and it's used to specify the path to a vcpkg installation directory. If not specified, cmake/vcpkg/vcpkg.toolchain.cmake will automatically create one for you. - `CMAKE_GENERATOR` is recommended to use Ninja as it's faster than the default generator. - `VCPKG_TARGET_TRIPLET/VCPKG_HOST_TRIPLET` is optional and it is automatically detected by cmake/vcpkg/vcpkg.toolchain.cmake if not specified. - - `CMAKE_BUILD_TYPE` is optional and default is set to RelWithDebInfo by `cmake/vcpkg/vcpkg.toolchain.cmake`. + - `CMAKE_BUILD_TYPE` is optional and default is set to Debug by `cmake/vcpkg/vcpkg.toolchain.cmake`. ``` Here's an example of building the project with the specified variables: diff --git a/template/README.md.jinja b/template/README.md.jinja index 77ae8499..0fca90dc 100644 --- a/template/README.md.jinja +++ b/template/README.md.jinja @@ -45,7 +45,7 @@ - Supports `code coverage` with [lcov](https://github.com/linux-test-project/lcov), [gcovr](https://github.com/gcovr/gcovr), llvm-cov, and [opencppcoverage](https://github.com/OpenCppCoverage/OpenCppCoverage). - Supports `hardening compilation `for MSVC, Clang, and GCC. - Provides compile, header, application target generation. - - Build with preset build types: Debug, Release, RelWithDebInfo(Default), MinSizeRel. + - Build with preset build types: Debug(Default), Release, RelWithDebInfo, MinSizeRel. - Supports package managers: [vcpkg](https://github.com/microsoft/vcpkg), [conan](https://github.com/conan-io/cmake-conan), and [cpm](https://github.com/cpm-cmake/CPM.cmake). - Use [cmake-registry](https://github.com/msclock/cmake-registry) to provide various cmake modules and scripts. - Lint tool `pre-commit` integration with various linters, including [clang-format](https://github.com/pre-commit/mirrors-clang-format), [codespell](https://github.com/codespell-project/codespell), [markdownlint](https://github.com/igorshubovych/markdownlint-cli), and more. diff --git a/template/[% if docs_type == 'sphinx' %]docs[% endif %]/[% if repo_name == 'ss-cpp' %]tutorials[% endif %]/building.md b/template/[% if docs_type == 'sphinx' %]docs[% endif %]/[% if repo_name == 'ss-cpp' %]tutorials[% endif %]/building.md index 894c8f53..752129f0 100644 --- a/template/[% if docs_type == 'sphinx' %]docs[% endif %]/[% if repo_name == 'ss-cpp' %]tutorials[% endif %]/building.md +++ b/template/[% if docs_type == 'sphinx' %]docs[% endif %]/[% if repo_name == 'ss-cpp' %]tutorials[% endif %]/building.md @@ -61,7 +61,7 @@ The Table below shows the necessary variables for different platforms and config - `VCPKG_ROOT` and `VCPKG_INSTALLATION_ROOT` are same and both are optional and it's used to specify the path to a vcpkg installation directory. If not specified, cmake/vcpkg/vcpkg.toolchain.cmake will automatically create one for you. - `CMAKE_GENERATOR` is recommended to use Ninja as it's faster than the default generator. - `VCPKG_TARGET_TRIPLET/VCPKG_HOST_TRIPLET` is optional and it is automatically detected by cmake/vcpkg/vcpkg.toolchain.cmake if not specified. - - `CMAKE_BUILD_TYPE` is optional and default is set to RelWithDebInfo by `cmake/vcpkg/vcpkg.toolchain.cmake`. + - `CMAKE_BUILD_TYPE` is optional and default is set to Debug by `cmake/vcpkg/vcpkg.toolchain.cmake`. ``` Here's an example of building the project with the specified variables: diff --git a/template/cmake/presets/base.json b/template/cmake/presets/base.json index 8238cb7f..e929d276 100644 --- a/template/cmake/presets/base.json +++ b/template/cmake/presets/base.json @@ -17,7 +17,7 @@ "cacheVariables": { "CMAKE_EXPORT_COMPILE_COMMANDS": true, "CMAKE_COMPILE_WARNING_AS_ERROR": false, - "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "CMAKE_BUILD_TYPE": "Debug", "CMAKE_VERBOSE_MAKEFILE": "FALSE" } } diff --git a/template/cmake/vcpkg/scripts/build_type.cmake b/template/cmake/vcpkg/scripts/build_type.cmake index 8a608433..a49dad63 100644 --- a/template/cmake/vcpkg/scripts/build_type.cmake +++ b/template/cmake/vcpkg/scripts/build_type.cmake @@ -6,12 +6,10 @@ This module initializes the build type. ]] if(NOT CMAKE_BUILD_TYPE) - message( - STATUS "Setting CMAKE_BUILD_TYPE to 'RelWithDebInfo' as none was specified." - ) + message(STATUS "Setting CMAKE_BUILD_TYPE to 'Debug' as none was specified.") endif() set(CMAKE_BUILD_TYPE - RelWithDebInfo + Debug CACHE STRING "Choose the type of build.") # Set the possible values of build type for cmake-gui, ccmake