Conversation
scivision
commented
Mar 2, 2026
- apply warning flags to debug builds - avoids problem with new compiler and flag bugs
- simplify CI settings by using JSON
- use std::filesystem canonically
- consistent use of "class point2D_t;" this was stopping GCC from building
This is canonical and simpler way
sometimes a new compiler (even GCC) has bugs internally for -Wall
There was a problem hiding this comment.
Pull request overview
This PR updates the project build/configuration to better support modern GCC and simplifies CI by switching to CMake presets/workflows, along with a few C++ source fixes/cleanups.
Changes:
- Add
CMakePresets.jsonand update CI to usecmake --workflowinstead of the oldctest -S setup.cmake. - Adjust warning flags to apply to Debug/RelWithDebInfo builds and update install rules in
CMakeLists.txt. - Modernize some C++ code paths (filesystem usage, error handling), and fix
point2D_tforward declaration consistency.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/saveresource.cpp | Uses std::filesystem for save path + directory creation and adds basic error reporting. |
| src/loadresource.cpp | Comment whitespace/formatting adjustments only. |
| src/headers/gameboard.hpp | Forward declaration updated to class point2D_t; to match definition. |
| src/global.cpp | Wraps system("clear"/"cls") to report failure. |
| setup.cmake | Removed legacy CTest script-based CI entry point. |
| meson.build | Removed Meson build configuration. |
| CMakePresets.json | Adds configure/build/test/workflow presets for Debug/Release pipelines. |
| CMakeLists.txt | Updates compiler warning flags and modifies install behavior/paths. |
| .github/workflows/ci.yml | Switches CI to CMake workflow presets and expands trigger paths. |
Comments suppressed due to low confidence (1)
meson.build:1
- Removing
meson.builddrops Meson as a supported build system; the PR description doesn't mention this deprecation/removal. Either keep Meson support or explicitly note the removal (and any migration guidance) in the PR description/README to avoid surprising downstream users.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const auto path_to_file_gd_state = "../data/SavedGameFiles/" + filename; | ||
| std::remove(path_to_file_gd_state.c_str()); | ||
| const auto path_to_file_gd_state = directory_path / filename; | ||
| std::filesystem::remove(path_to_file_gd_state); |
There was a problem hiding this comment.
std::filesystem::remove(path_to_file_gd_state) can throw std::filesystem::filesystem_error on permissions/IO issues. Since this function already uses std::error_code for create_directories, use the remove(path, ec) overload (or catch exceptions) to avoid terminating the program when deletion fails.
| std::filesystem::remove(path_to_file_gd_state); | |
| std::filesystem::remove(path_to_file_gd_state, ec); | |
| if (ec) { | |
| std::cerr << path_to_file_gd_state << " " << ec.message() << "\n"; | |
| return; | |
| } |
| if(system("cls")) { | ||
| #else | ||
| system("clear"); | ||
| if(system("clear")) { | ||
| #endif | ||
| std::cerr << "Failed to clear screen: " << std::error_code(errno, std::generic_category()).message() << "\n"; | ||
| } |
There was a problem hiding this comment.
system() failure reporting here is misleading: a non-zero return value usually indicates the command exited with an error status and does not necessarily set errno. Capture the return code from system() and report it (and only consult errno when system() returns -1).
|
|
||
| install(TARGETS 2048 | ||
| RUNTIME DESTINATION bin) | ||
| install(TARGETS 2048) |
There was a problem hiding this comment.
install(TARGETS 2048) no longer specifies destinations; CMake will install into the default/current directory under the prefix, which changes the previously explicit RUNTIME DESTINATION bin behavior. Specify destinations (e.g., RUNTIME/BUNDLE/LIBRARY/ARCHIVE) to keep installs predictable across platforms.
| install(TARGETS 2048) | |
| install(TARGETS 2048 | |
| RUNTIME DESTINATION bin) |
| - "**.hpp" | ||
| - "**.cmake" | ||
| - "**/CMakeLists.txt" | ||
| - ".github/workflows/ci.yml" |
There was a problem hiding this comment.
The push path filter does not include CMakePresets.json, so changes to presets/workflows won't trigger CI on push. Add CMakePresets.json (and any other build config files you rely on) to the on.push.paths list if you want CI to validate those changes.
| - ".github/workflows/ci.yml" | |
| - ".github/workflows/ci.yml" | |
| - "CMakePresets.json" |
| - uses: actions/checkout@v2 | ||
| - &checkout | ||
| uses: actions/checkout@v6 | ||
|
|
There was a problem hiding this comment.
CI uses cmake --workflow ..., which requires a relatively recent CMake with workflow preset support. Ensure the GitHub runners' CMake meets that requirement (or add a setup step to install/pin a suitable CMake version), otherwise the workflow may start failing without any code changes.
| - uses: jwlawson/actions-setup-cmake@v2 | |
| with: | |
| cmake-version: '3.27.0' |
| const auto path_to_file_gd_state = directory_path / filename; | ||
| std::filesystem::remove(path_to_file_gd_state); | ||
|
|
||
| saveToFilePreviousGameStateData(path_to_file_gd_state, gb); | ||
| saveToFilePreviousGameStateData(path_to_file_gd_state.string(), gb); |
There was a problem hiding this comment.
directory_path / filename will ignore directory_path when filename is an absolute path (or contains a root name), which lets user input save/remove files outside ../data/SavedGameFiles/. Since the filename comes from stdin, restrict it to a relative basename (or reject absolute paths / parent traversal) before constructing the filesystem path.
|
|
||
| install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data | ||
| DESTINATION ${CMAKE_INSTALL_PREFIX}) | ||
| DESTINATION ${CMAKE_INSTALL_PREFIX}/data) |
There was a problem hiding this comment.
DESTINATION ${CMAKE_INSTALL_PREFIX}/data bakes the configured install prefix into the install rules and ignores cmake --install --prefix ... (and may attempt to install into a system location). Use a relative destination like DESTINATION data (or DESTINATION .) so the chosen prefix at install time is respected.
| DESTINATION ${CMAKE_INSTALL_PREFIX}/data) | |
| DESTINATION data) |