Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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'
30 changes: 19 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@ 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)
if(MSVC)
add_compile_options(/W4)
else()
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# Добавляем include-директории
include_directories(${CMAKE_SOURCE_DIR}/libs)
Expand All @@ -31,3 +25,17 @@ file(GLOB_RECURSE SRC_FILES CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/src/*.cpp)
# Создаём исполняемый файл
add_executable(cpp_calc ${SRC_FILES})

# --- Копировать compile_commands.json в корень проекта ---
# 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()
# ----------------------------------------------------------