From 7964f129520f4121cd808a228f9ecb9c43b2d755 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Oct 2025 19:36:22 +0000 Subject: [PATCH 1/5] Initial plan From c58ac35260e2db802f188c0cc2d2cc63ab4f6d6c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Oct 2025 19:39:07 +0000 Subject: [PATCH 2/5] Add GitHub Actions CI workflow for CMake project Co-authored-by: phoenixofhp <64036649+phoenixofhp@users.noreply.github.com> --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c716e28 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + build_type: [Release, Debug] + + steps: + - uses: actions/checkout@v4 + + - name: Configure CMake + run: cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + + - name: Build + run: cmake --build build --config ${{ matrix.build_type }} + + - name: Test Run + run: ./build/cpp_calc --test + if: runner.os != 'Windows' + + - name: Test Run (Windows) + run: .\build\${{ matrix.build_type }}\cpp_calc.exe --test + if: runner.os == 'Windows' From 9cd1bbcb7ea861135080740966b1f7c9aafe66a0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Oct 2025 19:44:20 +0000 Subject: [PATCH 3/5] Fix Windows build failure by reordering CMake targets Co-authored-by: phoenixofhp <64036649+phoenixofhp@users.noreply.github.com> --- CMakeLists.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f766df..80e5de6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,16 +9,6 @@ set(CMAKE_CXX_EXTENSIONS OFF) # Всегда экспортировать compile_commands.json set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -# --- Копировать compile_commands.json в корень проекта --- -add_custom_target(copy_compile_commands ALL - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${CMAKE_BINARY_DIR}/compile_commands.json - ${CMAKE_SOURCE_DIR}/compile_commands.json - DEPENDS ${CMAKE_BINARY_DIR}/compile_commands.json - COMMENT "Copying compile_commands.json to project root" -) -# ---------------------------------------------------------- - # Добавляем флаги компиляции add_compile_options(-Wall -Wextra -Wpedantic) @@ -31,3 +21,13 @@ file(GLOB_RECURSE SRC_FILES CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/src/*.cpp) # Создаём исполняемый файл add_executable(cpp_calc ${SRC_FILES}) +# --- Копировать compile_commands.json в корень проекта --- +add_custom_target(copy_compile_commands ALL + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_BINARY_DIR}/compile_commands.json + ${CMAKE_SOURCE_DIR}/compile_commands.json + DEPENDS cpp_calc + COMMENT "Copying compile_commands.json to project root" +) +# ---------------------------------------------------------- + From 8458c3daee9366d5c68297d8f14cb31326ebc93d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Oct 2025 19:49:37 +0000 Subject: [PATCH 4/5] Fix MSVC compiler flag compatibility for Windows builds Co-authored-by: phoenixofhp <64036649+phoenixofhp@users.noreply.github.com> --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80e5de6..be1536e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,11 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Добавляем флаги компиляции -add_compile_options(-Wall -Wextra -Wpedantic) +if(MSVC) + add_compile_options(/W4) +else() + add_compile_options(-Wall -Wextra -Wpedantic) +endif() # Добавляем include-директории include_directories(${CMAKE_SOURCE_DIR}/libs) From 5a8375b21279f4c5b3b1073e60160c72d242e1e6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Oct 2025 19:53:57 +0000 Subject: [PATCH 5/5] Skip compile_commands.json copy on MSVC to fix Windows builds Co-authored-by: phoenixofhp <64036649+phoenixofhp@users.noreply.github.com> --- CMakeLists.txt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be1536e..5ede894 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,12 +26,16 @@ file(GLOB_RECURSE SRC_FILES CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/src/*.cpp) add_executable(cpp_calc ${SRC_FILES}) # --- Копировать compile_commands.json в корень проекта --- -add_custom_target(copy_compile_commands ALL - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${CMAKE_BINARY_DIR}/compile_commands.json - ${CMAKE_SOURCE_DIR}/compile_commands.json - DEPENDS cpp_calc - COMMENT "Copying compile_commands.json to project root" -) +# Note: Visual Studio generators don't generate compile_commands.json +# Only copy if the file exists (for Makefile/Ninja generators) +if(NOT MSVC) + add_custom_command(TARGET cpp_calc POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_BINARY_DIR}/compile_commands.json + ${CMAKE_SOURCE_DIR}/compile_commands.json + COMMENT "Copying compile_commands.json to project root" + VERBATIM + ) +endif() # ----------------------------------------------------------