Use release cmake configuration as a default

This commit is contained in:
dP
2025-10-19 03:15:37 +05:00
parent e4f49a0c02
commit 117365fad7
4 changed files with 12 additions and 9 deletions

View File

@@ -13,9 +13,10 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-source builds not allowed. Please run \"cmake ..\" from the build directory. You may need to delete \"${CMAKE_SOURCE_DIR}/CMakeCache.txt\" first.")
endif()
# Debug mode by default.
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
# Default to Release build if not specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type specified. Defaulting to RelWithDebInfo.")
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE)
endif()
if (EMSCRIPTEN)

View File

@@ -94,8 +94,9 @@ cmake ..
make
```
For more information on how to use CMake (including how to make Release builds),
we urge you to read [their excellent manual](https://cmake.org/cmake/help/latest/guide/user-interaction/index.html).
Unlike vanilla OpenTTD this will make a Release build of CityMania patchpack by default. If you want debug one use `cmake -DCMAKE_BUILD_TYPE=Debug -DOPTION_USE_ASSERTS=ON ..`
For more information on how to use CMake, we urge you to read [their excellent manual](https://cmake.org/cmake/help/latest/guide/user-interaction/index.html).
## CMake Options
@@ -107,9 +108,8 @@ builds.
in case of a crash.
- `-DOPTION_DEDICATED=ON`: build OpenTTD without a GUI. Useful if you are
running a headless server, as it requires less libraries to operate.
- `-DOPTION_USE_ASSERTS=OFF`: disable asserts. Use with care, as assert
statements capture early signs of trouble. Release builds have them
disabled by default.
- `-DOPTION_USE_ASSERTS=ON`: enable asserts. Useful for debugging, as assert
statements capture early signs of trouble.
- `-DOPTION_TOOLS_ONLY=ON`: only build tools like `strgen`. Does not build
the game itself. Useful for cross-compiling.

View File

@@ -0,0 +1,2 @@
# Use ninja and clang for faster build time, use Release and no asserts for best performance
cmake .. -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -DOPTION_USE_ASSERTS=OFF -DCMAKE_COLOR_DIAGNOSTICS=ON ..

View File

@@ -56,7 +56,7 @@ function(set_options)
option(OPTION_DEDICATED "Build dedicated server only (no GUI)" OFF)
option(OPTION_INSTALL_FHS "Install with Filesystem Hierarchy Standard folders" ${DEFAULT_OPTION_INSTALL_FHS})
option(OPTION_USE_ASSERTS "Use assertions; leave enabled for nightlies, betas, and RCs" OFF)
option(OPTION_USE_ASSERTS "Use assertions; Enable for nightlies, betas, and RCs" OFF)
option(OPTION_USE_NSIS "Use NSIS to create windows installer; enable only for stable releases" OFF)
option(OPTION_TOOLS_ONLY "Build only tools target" OFF)
option(OPTION_DOCS_ONLY "Build only docs target" OFF)