Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add CMake build, .gitignore, and polish README for Phase 1#1

Merged
clouds1729 merged 2 commits into
mainfrom
codex/clean-up-c++-sfml-tetris-game
May 17, 2026
Merged

Add CMake build, .gitignore, and polish README for Phase 1#1
clouds1729 merged 2 commits into
mainfrom
codex/clean-up-c++-sfml-tetris-game

Conversation

@clouds1729

Copy link
Copy Markdown
Owner

Motivation

  • Make the repository easy to build and inspect by adding a standard CMake build entrypoint and predictable runtime asset placement.
  • Improve project hygiene for portfolio presentation by excluding build artifacts and editor/OS files from version control.
  • Provide clear, accurate developer documentation (clone, dependencies, build/run, controls, and known limitations) so others can pick up the project quickly.

Description

  • Added CMakeLists.txt with C++17 settings, portable warning flags, a find_package(SFML 2.5 REQUIRED COMPONENTS graphics window system) call, and a post-build command to copy the images/ directory next to the executable.
  • Added a .gitignore tuned for C++/CMake projects to filter build directories, generated CMake files, common object/library artifacts, IDE folders, and OS files.
  • Rewrote README.md to include corrected clone instructions, explicit dependencies, example cmake build and run commands, controls, features, and a short list of known limitations.
  • Did not modify game logic in main.cpp; the change set is limited to build, docs, and repository hygiene.

Testing

  • Ran configuration and build with cmake -S . -B build && cmake --build build, and configuration failed because SFML development files/config (SFMLConfig.cmake or sfml-config.cmake) were not present in the environment, so the build did not complete.
  • No unit tests exist in the repository; the PR only includes the build configuration and documentation changes, so no additional automated tests were run.

Codex Task

@clouds1729

Copy link
Copy Markdown
Owner Author

@codex fix the Windows CMake workflow failure.

The GitHub Actions job "CMake on Windows" is failing during CMake configure because CMake cannot find SFML:

Could not find a package configuration file provided by "SFML"
SFMLConfig.cmake
sfml-config.cmake

Please inspect the repo's CMakeLists.txt and .github/workflows files and fix this in the smallest reliable way.

Goal:

  • Make the Windows GitHub Actions CMake build pass.
  • Keep local developer setup simple.
  • Do not rewrite the game.

Preferred fix:

  1. Use vcpkg in the Windows GitHub Actions workflow to install SFML.
  2. Configure CMake with the vcpkg toolchain file:
    -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
  3. Make sure CMakeLists.txt uses modern SFML package discovery:
    find_package(SFML CONFIG REQUIRED COMPONENTS Graphics Window System)
    or the correct SFML 2.x/3.x component names depending on installed version.
  4. Link the executable against the correct imported SFML targets.
  5. Remove or avoid brittle hardcoded SFML paths.
  6. Update README with Windows build instructions if needed.

Also add a note in the workflow comments explaining why vcpkg is used on Windows.

After the fix, summarize:

  • changed files
  • exact CMake commands used in CI
  • exact local Windows commands to reproduce

@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

  • Updated CMake to use modern SFML config-package discovery and imported targets, replacing the brittle module-style lookup/linking (find_package(SFML CONFIG REQUIRED COMPONENTS Graphics Window System) and SFML::... targets). CMakeLists.txtL15-L16
  • Added a Windows GitHub Actions workflow that bootstraps vcpkg, installs sfml:x64-windows, configures CMake with the vcpkg toolchain file, and builds Release. This directly addresses the CI failure to find SFMLConfig.cmake. .github/workflows/cmake-windows.ymlL1-L32
  • Added an inline workflow comment documenting why vcpkg is used on Windows (reliable SFML config discovery). .github/workflows/cmake-windows.ymlL23-L29
  • Updated README with exact local Windows (PowerShell) vcpkg-based build commands to keep developer setup straightforward and consistent with CI behavior. README.mdL26-L36

Requested command summaries

  • Exact CMake configure command used in CI:
    cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows. .github/workflows/cmake-windows.ymlL23-L29

  • Exact local Windows commands to reproduce (PowerShell):
    See README Windows section (vcpkg clone/bootstrap + CMake configure/build). README.mdL28-L36

Git/PR actions completed

  • Committed on current branch: 91aeb4d with message “Fix Windows CMake CI by using vcpkg SFML”.
  • Created follow-up PR message via make_pr tool as requested.

Testing

  • cmake -S . -B build (fails in this Linux container because SFML dev package/config is not installed here; expected and consistent with pre-existing environment limitation for non-vcpkg local Linux setup).

View task →

@clouds1729 clouds1729 merged commit 00dbd5c into main May 17, 2026
0 of 2 checks passed
@clouds1729

Copy link
Copy Markdown
Owner Author

@codex fix the Tetris CI properly.

The Windows workflow is still failing. Inspect the repo and repair the CI/build setup in the smallest reliable way.

Important:
The current .github/workflows/cmake-windows.yml and CMakeLists.txt appear to have been flattened into one-line files. Fix their formatting first.

Tasks:

  1. Reformat .github/workflows/cmake-windows.yml into valid readable YAML.
  2. Reformat CMakeLists.txt into valid readable multi-line CMake.
  3. Prefer a simple Ubuntu CI instead of Windows if Windows SFML/vcpkg keeps being brittle.
  4. Use this CI approach unless there is a strong reason not to:

name: CMake Build

on:
push:
branches: [main]
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
  - name: Checkout
    uses: actions/checkout@v4

  - name: Install dependencies
    run: |
      sudo apt-get update
      sudo apt-get install -y cmake g++ libsfml-dev

  - name: Configure
    run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release

  - name: Build
    run: cmake --build build --config Release
  1. Update CMakeLists.txt so it works with Linux apt-installed SFML.
  2. Keep the executable name as tetris unless the current README says otherwise.
  3. Do not rewrite main.cpp.
  4. Update README build instructions if needed.
  5. Summarize changed files and exact verification commands.

Goal: green GitHub Actions build, not perfect cross-platform packaging.

@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

  • Replaced the broken/flattened Windows workflow file with valid, readable YAML and switched CI to a simpler Ubuntu build job (apt + CMake), using the exact configure/build pattern you requested. .github/workflows/cmake-windows.ymlL1-L25
  • Rewrote CMakeLists.txt as valid multi-line CMake, kept executable name tetris, and updated SFML package/link settings for Linux package-manager installs (libsfml-dev style usage). CMakeLists.txtL1-L28
  • Updated README build instructions to use the same Release configure/build commands as CI, and added a short CI section documenting the Ubuntu approach. README.mdL45-L55
  • Left main.cpp unchanged, per instruction. (No edits to that file in this commit.)

Committed on current branch:

  • 6181491Switch CI to Ubuntu and fix CMake/SFML setup

Changed files

Exact verification commands

Testing

  • git status --short (before commit; confirmed only intended files changed)
  • cmake -S . -B build -DCMAKE_BUILD_TYPE=Release (fails in this container because SFML dev/config is not installed locally)
  • git add .github/workflows/cmake-windows.yml CMakeLists.txt README.md && git commit -m "Switch CI to Ubuntu and fix CMake/SFML setup"

View task →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant