Skip to content

Commit

Permalink
perf: switch CMAKE_BUILD_TYPE to Debug by default (#363)
Browse files Browse the repository at this point in the history
Signed-off-by: msclock <[email protected]>
  • Loading branch information
msclock authored Sep 6, 2024
1 parent 292bab3 commit 6c93e07
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion cmake/presets/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
6 changes: 2 additions & 4 deletions cmake/vcpkg/scripts/build_type.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion template/README.md.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion template/cmake/presets/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
6 changes: 2 additions & 4 deletions template/cmake/vcpkg/scripts/build_type.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6c93e07

Please sign in to comment.