From 117365fad76c7cbc0051b6fecc7807689c6b09ec Mon Sep 17 00:00:00 2001 From: dP Date: Sun, 19 Oct 2025 03:15:37 +0500 Subject: [PATCH 1/4] Use release cmake configuration as a default --- CMakeLists.txt | 7 ++++--- COMPILING.md | 10 +++++----- cmake-ninja-clang-release.sh | 2 ++ cmake/Options.cmake | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 cmake-ninja-clang-release.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 7747880169..2cec04f30d 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 da2d172808..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" 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) From c73e76fbf6dec3c018d632cdbb3bf3fb5d78db78 Mon Sep 17 00:00:00 2001 From: dP Date: Sat, 18 Oct 2025 13:39:21 +0500 Subject: [PATCH 2/4] Don't build installer --- .github/workflows/release-windows.yml | 8 +++++--- .github/workflows/release.yml | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml index aa0bbc604b..5322ce67e4 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -101,7 +101,8 @@ jobs: arch: ${{ matrix.host }} - name: Build (with installer) - if: inputs.is_tag == 'true' + if: ${{ false }} # CM doesn't do installer + # if: inputs.is_tag == 'true' shell: bash run: | mkdir build @@ -131,7 +132,7 @@ jobs: AZURE_CODESIGN_PROFILE_NAME: ${{ secrets.AZURE_CODESIGN_PROFILE_NAME }} - name: Build (without installer) - if: inputs.is_tag != 'true' + # if: inputs.is_tag != 'true' CM always builds without shell: bash run: | mkdir build @@ -192,7 +193,8 @@ jobs: echo "::endgroup::" - name: Sign installer - if: inputs.is_tag == 'true' + if: ${{ false }} # CM doesn't do installer + # if: inputs.is_tag == 'true' shell: bash run: | ${GITHUB_WORKSPACE}/os/windows/sign.bat "${GITHUB_WORKSPACE}/build/bundles" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0f4c2208ef..586eb93aac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -193,7 +193,6 @@ jobs: - macos - windows - # if: ${{ false }} if: needs.source.outputs.trigger_type == 'new-master' || needs.source.outputs.trigger_type == 'new-tag' runs-on: ubuntu-20.04 From db7744815196317ed83c8baf586f094ae0696b5e Mon Sep 17 00:00:00 2001 From: dP Date: Sun, 19 Oct 2025 03:34:32 +0500 Subject: [PATCH 3/4] Update workflows to use ubuntu-latest --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 586eb93aac..de08f47ad3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -169,7 +169,7 @@ jobs: if: needs.source.outputs.trigger_type == 'new-master' || needs.source.outputs.trigger_type == 'new-tag' - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Download all bundles @@ -195,7 +195,7 @@ jobs: if: needs.source.outputs.trigger_type == 'new-master' || needs.source.outputs.trigger_type == 'new-tag' - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Download all bundles From 2782a0b73239c895c4c365d42b8959b3a7f54e28 Mon Sep 17 00:00:00 2001 From: dP Date: Sun, 19 Oct 2025 21:40:20 +0500 Subject: [PATCH 4/4] Fix #44: Don't crash when changing show apm setting in the main menu --- src/statusbar_gui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index 07b6cc9aee..3680febf1c 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -283,5 +283,5 @@ void ShowStatusBar() void CM_RedrawStatusBar() { StatusBarWindow *w = dynamic_cast(FindWindowById(WC_STATUS_BAR, 0)); - w->ReInit(); + if (w != nullptr) w->ReInit(); }