diff --git a/CMakeLists.txt b/CMakeLists.txt index d88455b65f..3f77e261fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/COMPILING.md b/COMPILING.md index 74e816253e..03c6b58462 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -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. diff --git a/cmake-ninja-clang-release.sh b/cmake-ninja-clang-release.sh new file mode 100644 index 0000000000..84f7de7003 --- /dev/null +++ b/cmake-ninja-clang-release.sh @@ -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 .. diff --git a/cmake/Options.cmake b/cmake/Options.cmake index 38d708c717..63e0d7337b 100644 --- a/cmake/Options.cmake +++ b/cmake/Options.cmake @@ -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" ON) + 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)