-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ec5bf38
Showing
17 changed files
with
549 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: C++ CI with CMake Presets | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
# Installe les dépendances nécessaires | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y cmake ninja-build g++ gcc git | ||
# Clone vcpkg repository and install with bootstrap script | ||
- name: Set up vcpkg | ||
run: | | ||
git clone https://github.com/microsoft/vcpkg.git | ||
./vcpkg/bootstrap-vcpkg.sh -disableMetrics | ||
./vcpkg/vcpkg integrate install | ||
# Configure the project using CMake Preset | ||
- name: Configure CMake Project | ||
run: cmake --preset default | ||
|
||
# Build the project using CMake Preset | ||
- name: Build Project | ||
run: cmake --build --preset default | ||
|
||
# Run tests using CMake Preset | ||
- name: Test Project | ||
run: ctest --preset run-all-tests | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Prerequisites | ||
*.d | ||
build/ | ||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
build/ | ||
log/ | ||
# Precompiled Headers | ||
# Dossiers | ||
/build/ | ||
/bin/ | ||
/lib/ | ||
/out/ | ||
# vcpkg.json | ||
# Fichiers | ||
*.exe | ||
*.dll | ||
*.so | ||
*.dylib | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
*.smod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "vcpkg"] | ||
path = vcpkg | ||
url = https://github.com/microsoft/vcpkg.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# ********************************************************** | ||
# 2024 : Arthur JEULIN | ||
# Copyright (c) Arthur JEULIN | ||
# Created by Arthur JEULIN on 06/22/2024. | ||
# ********************************************************** | ||
cmake_minimum_required(VERSION 3.27.5) | ||
|
||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
# Indiquez à CMake d'utiliser les outils de vcpkg | ||
if(UNIX) | ||
endif() | ||
if(WIN32) | ||
set(CMAKE_GENERATOR_TOOLSET "v142") | ||
endif() | ||
|
||
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake" | ||
CACHE STRING "Vcpkg toolchain file") | ||
|
||
|
||
project(template | ||
DESCRIPTION "Template Project Library " | ||
LANGUAGES CXX | ||
) | ||
|
||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | ||
|
||
option(BUILD_SHARED_LIBS "Build shared libraries" OFF) | ||
|
||
|
||
include(FetchContent) | ||
FetchContent_Declare( | ||
googletest | ||
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip | ||
) | ||
# For Windows: Prevent overriding the parent project's compiler/linker settings | ||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
FetchContent_MakeAvailable(googletest) | ||
enable_testing() #to discover tests in test explorer | ||
|
||
include_directories(include) | ||
include_directories( "${PROJECT_SOURCE_DIR}/build/vcpkg_installed/x64-windows/include") | ||
|
||
add_subdirectory(src) | ||
add_subdirectory(example) | ||
add_subdirectory(test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
{ | ||
"version": 6, | ||
"cmakeMinimumRequired": { | ||
"major": 3, | ||
"minor": 27, | ||
"patch": 0 | ||
}, | ||
"configurePresets": [ | ||
{ | ||
"name": "ninja-multi-vcpkg", | ||
"displayName": "Ninja Multi-Config", | ||
"description": "Configure with vcpkg toolchain and generate Ninja project files for all configurations", | ||
"binaryDir": "${sourceDir}/build", | ||
"generator": "Ninja Multi-Config", | ||
"toolchainFile": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake" | ||
}, | ||
{ | ||
"name": "default", | ||
"displayName": "Construction par défaut", | ||
"description": "préréglage pour une construction par défaut avec Unix Makefiles", | ||
"binaryDir": "${sourceDir}/build", | ||
"generator": "Unix Makefiles", | ||
"toolchainFile": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake", | ||
"cacheVariables": { | ||
"CMAKE_CXX_COMPILER": "g++", | ||
"CMAKE_C_COMPILER": "gcc", | ||
"CMAKE_EXPORT_COMPILE_COMMANDS": "YES", | ||
"BUILD_SHARED_LIBS": "OFF", | ||
"CMAKE_CXX_STANDARD": "20" | ||
} | ||
}, | ||
{ | ||
"name": "x64-windows", | ||
"displayName": "Windows x64", | ||
"description": "Configure with Visual Studio 16 2019 on Windows", | ||
"generator": "Visual Studio 16 2019", | ||
"toolchainFile": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake", | ||
"binaryDir": "${sourceDir}/build", | ||
"architecture": { | ||
"value": "x64", | ||
"strategy": "external" | ||
}, | ||
"cacheVariables": { | ||
"BUILD_SHARED_LIBS": "OFF", | ||
"CMAKE_EXPORT_COMPILE_COMMANDS": "TRUE", | ||
"CMAKE_SYSTEM_VERSION": "11.0", | ||
"VCPKG_PLATFORM_TOOLSET": "v142" | ||
} | ||
} | ||
], | ||
"buildPresets": [ | ||
{ | ||
"name": "ninja-vcpkg-debug", | ||
"configurePreset": "ninja-multi-vcpkg", | ||
"displayName": "Build (Debug)", | ||
"description": "Build with Ninja/vcpkg (Debug)", | ||
"configuration": "Debug" | ||
}, | ||
{ | ||
"name": "ninja-vcpkg-release", | ||
"configurePreset": "ninja-multi-vcpkg", | ||
"displayName": "Build (Release)", | ||
"description": "Build with Ninja/vcpkg (Release)", | ||
"configuration": "Release" | ||
}, | ||
{ | ||
"name": "ninja-vcpkg", | ||
"configurePreset": "ninja-multi-vcpkg", | ||
"displayName": "Build", | ||
"description": "Build with Ninja/vcpkg" | ||
}, | ||
{ | ||
"name": "build-windows", | ||
"configurePreset": "x64-windows", | ||
"configuration": "Release", | ||
"displayName": "Build (Release)", | ||
"description": "Build with Visual Studio 16 2019", | ||
"jobs": 22, | ||
"targets": [ | ||
"ALL_BUILD" | ||
] | ||
}, | ||
{ | ||
"name": "build-windows-debug", | ||
"configurePreset": "x64-windows", | ||
"configuration": "Debug", | ||
"jobs": 22, | ||
"targets": [ | ||
"ALL_BUILD" | ||
] | ||
} | ||
], | ||
"testPresets": [ | ||
{ | ||
"name": "test-ninja-vcpkg", | ||
"configurePreset": "ninja-multi-vcpkg", | ||
"hidden": true | ||
}, | ||
{ | ||
"name": "test-debug", | ||
"description": "Test (Debug)", | ||
"displayName": "Test (Debug)", | ||
"configuration": "Debug", | ||
"inherits": [ | ||
"test-ninja-vcpkg" | ||
] | ||
}, | ||
{ | ||
"name": "test-release", | ||
"description": "Test (Release)", | ||
"displayName": "Test (Release)", | ||
"configuration": "Release", | ||
"inherits": [ | ||
"test-ninja-vcpkg" | ||
] | ||
}, | ||
{ | ||
"name": "run-all-tests", | ||
"description": "Test (Debug)", | ||
"displayName": "Test (Debug)", | ||
"configuration": "Debug", | ||
"configurePreset": "default", | ||
"output": { | ||
"outputOnFailure": true | ||
} | ||
}, | ||
{ | ||
"name": "test-windows", | ||
"description": "Test Windows", | ||
"displayName": "Test Windows", | ||
"configurePreset": "x64-windows", | ||
"output": { | ||
"outputOnFailure": true | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# ********************************************************** | ||
# 2024 : Arthur JEULIN | ||
# Copyright (c) Arthur JEULIN | ||
# Created by Arthur JEULIN on 06/22/2024. | ||
# ********************************************************** | ||
# | ||
# Module : Create an environment do build the project | ||
# | ||
|
||
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-22.04 | ||
#FROM ubuntu:22.04 | ||
|
||
RUN echo "Building Environment" | ||
RUN echo "Updating Ubuntu" | ||
RUN apt-get update && apt-get upgrade -y | ||
|
||
RUN echo "Installing dependencies..." | ||
RUN apt install -y \ | ||
ccache \ | ||
cppcheck \ | ||
cmake \ | ||
curl \ | ||
doxygen \ | ||
gcc \ | ||
git \ | ||
graphviz \ | ||
make \ | ||
ninja-build \ | ||
python3 \ | ||
python3-pip \ | ||
tar \ | ||
unzip \ | ||
vim | ||
|
||
RUN echo "Installing dependencies not found in the package repos..." | ||
|
||
RUN apt install -y wget tar build-essential libssl-dev && \ | ||
wget https://github.com/Kitware/CMake/releases/download/v3.27.5/cmake-3.27.5.tar.gz && \ | ||
tar -zxvf cmake-3.27.5.tar.gz && \ | ||
cd cmake-3.27.5 && \ | ||
./bootstrap && \ | ||
make && \ | ||
make install | ||
|
||
|
||
RUN git clone https://github.com/microsoft/vcpkg -b 2020.06 && \ | ||
cd vcpkg && \ | ||
./bootstrap-vcpkg.sh -disableMetrics -useSystemBinaries | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Template Project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# ********************************************************** | ||
# 2024 : Arthur JEULIN | ||
# Copyright (c) Arthur JEULIN | ||
# Created by Arthur JEULIN on 06/22/2024. | ||
# ********************************************************** | ||
|
||
cmake_minimum_required(VERSION 3.27.5) | ||
|
||
set(POSITION_INDEPENDENT_CODE ON) | ||
|
||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/example) | ||
|
||
# Find all example cpp files in the example directory | ||
file(GLOB EXAMPLE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp") | ||
|
||
foreach(example_source ${EXAMPLE_SOURCES}) | ||
# Get a human readable name | ||
get_filename_component(example_name ${example_source} NAME_WE) | ||
|
||
# Add executable for this example | ||
add_executable(${example_name} ${example_source}) | ||
|
||
|
||
target_include_directories(${example_name} PUBLIC | ||
${PROJECT_SOURCE_DIR}/include | ||
) | ||
|
||
target_link_libraries(${example_name} PRIVATE | ||
my_library | ||
) | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-fpermissive) | ||
endif() | ||
|
||
target_compile_features(${example_name} PRIVATE cxx_std_17) | ||
|
||
install(TARGETS ${example_name}) | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "my_library.h" | ||
|
||
int main() | ||
{ | ||
HelloWorld(); | ||
return 0; | ||
} |
Oops, something went wrong.