Skip to content

Commit

Permalink
CI: ci init
Browse files Browse the repository at this point in the history
  • Loading branch information
devansh-srv committed Feb 22, 2025
1 parent 81047bb commit 0c9f856
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CMake on multiple platforms

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
include:
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
- os: windows-latest
c_compiler: cl
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang

steps:
- uses: actions/checkout@v4

# - name: Install CMake (Ubuntu)
# if: matrix.os == 'ubuntu-latest'
# run: |
# sudo apt-get update
# sudo apt-get install -y cmake
- name: Configure CMake
run: |
cmake -B build -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -S ${{ github.workspace }}
- name: Build
shell: bash
run: |
if [["${{runner.os}}" == "Windows"]]; then
cmake --build build --config ${{ matrix.build_type }}
else
cmake --build build
fi
- name: Test
working-directory: build
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
ctest -C "${{ matrix.build_type }}"
else
ctest
fi
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.10)
project(FileVault CXX)

# Set the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /Zi")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -g")
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build)
set(CMAKE_OBJECTS_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build)
include_directories(${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/include)
file(GLOB SOURCES "src/*.cpp")
add_executable(${PROJECT_NAME} ${SOURCES})
set_target_properties(${PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build
CMAKE_OBJECTS_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build
)
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cmake -B build
cmake --build build

0 comments on commit 0c9f856

Please sign in to comment.