-
Notifications
You must be signed in to change notification settings - Fork 320
Work with modern GCC #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Work with modern GCC #151
Changes from all commits
10fa982
faaf732
76ea972
85f92eb
b606980
cab4cc4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,24 +4,23 @@ on: | |||||||||||
| push: | ||||||||||||
| paths: | ||||||||||||
| - "**.cpp" | ||||||||||||
| - "**.hpp" | ||||||||||||
| - "**.cmake" | ||||||||||||
| - "**/CMakeLists.txt" | ||||||||||||
| - ".github/workflows/ci.yml" | ||||||||||||
| pull_request: | ||||||||||||
| paths: | ||||||||||||
| - "**.cpp" | ||||||||||||
| - "**.cmake" | ||||||||||||
| - "**/CMakeLists.txt" | ||||||||||||
| - ".github/workflows/ci.yml" | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| jobs: | ||||||||||||
|
|
||||||||||||
| linux: | ||||||||||||
| core: | ||||||||||||
| runs-on: ${{ matrix.os }} | ||||||||||||
| strategy: | ||||||||||||
| matrix: | ||||||||||||
| os: [ubuntu-latest, windows-latest, macos-latest] | ||||||||||||
| os: [ubuntu-latest, macos-latest, windows-latest] | ||||||||||||
| steps: | ||||||||||||
| - uses: actions/checkout@v2 | ||||||||||||
| - &checkout | ||||||||||||
| uses: actions/checkout@v6 | ||||||||||||
|
|
||||||||||||
|
||||||||||||
| - uses: jwlawson/actions-setup-cmake@v2 | |
| with: | |
| cmake-version: '3.27.0' |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,21 +1,23 @@ | ||||||||
| cmake_minimum_required(VERSION 3.7...3.21) | ||||||||
| cmake_minimum_required(VERSION 3.15...4.3) | ||||||||
| project(2048 LANGUAGES CXX) | ||||||||
| enable_testing() | ||||||||
|
|
||||||||
| set(SOURCES src/2048.cpp src/gameboard.cpp src/gameboard-graphics.cpp src/game.cpp src/game-graphics.cpp src/game-input.cpp src/game-pregamemenu.cpp src/global.cpp src/loadresource.cpp src/menu.cpp src/menu-graphics.cpp src/saveresource.cpp src/scores.cpp src/scores-graphics.cpp src/statistics.cpp src/statistics-graphics.cpp src/tile.cpp src/tile-graphics.cpp) | ||||||||
|
|
||||||||
| if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) | ||||||||
| add_compile_options(-Wall) | ||||||||
| elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) | ||||||||
| add_compile_options(-Wall) | ||||||||
| elseif(CMAKE_CXX_COMPILER_ID MATCHES "^Intel") | ||||||||
| if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||||||||
| add_compile_options($<$<CONFIG:Debug,RelWithDebInfo>:-Wall>) | ||||||||
| elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") | ||||||||
| add_compile_options($<$<CONFIG:Debug,RelWithDebInfo>:-Wall>) | ||||||||
| elseif(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") | ||||||||
| if(WIN32) | ||||||||
| add_compile_options(/W3) | ||||||||
| add_compile_options($<$<CONFIG:Debug,RelWithDebInfo>:/W3>) | ||||||||
| else() | ||||||||
| add_compile_options(-w2) | ||||||||
| add_compile_options($<$<CONFIG:Debug,RelWithDebInfo>:-w2>) | ||||||||
| endif() | ||||||||
| elseif(CMAKE_CXX_COMPILER_ID STREQUAL NVHPC) | ||||||||
| add_compile_options(-a) | ||||||||
| elseif(MSVC) | ||||||||
| add_compile_options($<$<CONFIG:Debug,RelWithDebInfo>:/W3>) | ||||||||
| elseif(CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC") | ||||||||
| add_compile_options($<$<CONFIG:Debug,RelWithDebInfo>:-a>) | ||||||||
| endif() | ||||||||
|
|
||||||||
| add_executable(2048 ${SOURCES}) | ||||||||
|
|
@@ -33,8 +35,7 @@ endif() | |||||||
|
|
||||||||
| # --- install | ||||||||
|
|
||||||||
| install(TARGETS 2048 | ||||||||
| RUNTIME DESTINATION bin) | ||||||||
| install(TARGETS 2048) | ||||||||
|
||||||||
| install(TARGETS 2048) | |
| install(TARGETS 2048 | |
| RUNTIME DESTINATION bin) |
Copilot
AI
Mar 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| { | ||
| "version": 6, | ||
|
|
||
| "configurePresets": [ | ||
| { | ||
| "name": "default", | ||
| "binaryDir": "${sourceDir}/build", | ||
| "cacheVariables": { | ||
| "CMAKE_COMPILE_WARNING_AS_ERROR": true, | ||
| "CMAKE_LINK_WARNING_AS_ERROR": true | ||
| } | ||
| }, | ||
| { | ||
| "name": "multi", "inherits": "default", | ||
| "generator": "Ninja Multi-Config" | ||
| } | ||
| ], | ||
| "buildPresets": [ | ||
| { "name": "default", "configurePreset": "default" }, | ||
| { "name": "debug", "configurePreset": "multi", "configuration": "Debug" }, | ||
| { "name": "release", "configurePreset": "multi", "configuration": "Release" } | ||
| ], | ||
| "testPresets": [ | ||
| { | ||
| "name": "default", | ||
| "configurePreset": "default", | ||
| "output": { | ||
| "outputOnFailure": true, | ||
| "verbosity": "verbose" | ||
| }, | ||
| "execution": { | ||
| "noTestsAction": "error", | ||
| "scheduleRandom": true, | ||
| "stopOnFailure": false, | ||
| "timeout": 60 | ||
| } | ||
| }, | ||
| { "name": "debug", "inherits": "default", "configurePreset": "multi", "configuration": "Debug" }, | ||
| { "name": "release", "inherits": "default", "configurePreset": "multi", "configuration": "Release" } | ||
| ], | ||
| "workflowPresets": [ | ||
| { | ||
| "name": "default", | ||
| "steps": [ | ||
| { "type": "configure", "name": "default" }, | ||
| { "type": "build", "name": "default" }, | ||
| { "type": "test", "name": "default" } | ||
| ] | ||
| }, | ||
| { "name": "debug", | ||
| "steps": [ | ||
| { "type": "configure", "name": "multi" }, | ||
| { "type": "build", "name": "debug" }, | ||
| { "type": "test", "name": "debug" } | ||
| ] | ||
| }, | ||
| { | ||
| "name": "release", | ||
| "steps": [ | ||
| { "type": "configure", "name": "multi" }, | ||
| { "type": "build", "name": "release" }, | ||
| { "type": "test", "name": "release" } | ||
| ] | ||
| } | ||
| ] | ||
| } |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,11 @@ | ||
| #include "global.hpp" | ||
| #include "color.hpp" | ||
|
|
||
| #include <iostream> | ||
| #include <sstream> | ||
| #include <cstdlib> // for system | ||
| #include <system_error> | ||
| #include <cerrno> | ||
|
|
||
| #ifdef _WIN32 | ||
|
|
||
|
|
@@ -51,10 +55,12 @@ void wait_for_any_letter_input(std::istream &is) { | |
|
|
||
| void clearScreen() { | ||
| #ifdef _WIN32 | ||
| system("cls"); | ||
| 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"; | ||
| } | ||
|
Comment on lines
+58
to
+63
|
||
| }; | ||
|
|
||
| std::string secondsFormat(double sec) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
| #include <tuple> | ||
| #include <vector> | ||
|
|
||
| struct point2D_t; | ||
| class point2D_t; | ||
|
|
||
| namespace Game { | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The push path filter does not include
CMakePresets.json, so changes to presets/workflows won't trigger CI on push. AddCMakePresets.json(and any other build config files you rely on) to theon.push.pathslist if you want CI to validate those changes.