From 3ce89fa05608b97949aee68a7509debd46d2e473 Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Tue, 10 Oct 2023 21:06:06 +0200 Subject: [PATCH] Added CPP Part --- .gitignore | 3 ++- cpp/CMakeLists.txt | 22 ++++++++++++++++++++++ cpp/day1/src/main.cpp | 7 +++++++ cpp/run.bat | 5 +++++ cpp/run.sh | 4 ++++ {day1 => rust/day1}/Cargo.lock | 0 {day1 => rust/day1}/Cargo.toml | 0 {day1 => rust/day1}/elves | 0 {day1 => rust/day1}/src/elves.rs | 0 {day1 => rust/day1}/src/main.rs | 0 10 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 cpp/CMakeLists.txt create mode 100644 cpp/day1/src/main.cpp create mode 100644 cpp/run.bat create mode 100644 cpp/run.sh rename {day1 => rust/day1}/Cargo.lock (100%) rename {day1 => rust/day1}/Cargo.toml (100%) rename {day1 => rust/day1}/elves (100%) rename {day1 => rust/day1}/src/elves.rs (100%) rename {day1 => rust/day1}/src/main.rs (100%) diff --git a/.gitignore b/.gitignore index 1de5659..beb2254 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -target \ No newline at end of file +target +build \ No newline at end of file diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt new file mode 100644 index 0000000..01ab754 --- /dev/null +++ b/cpp/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.22) +# Global Variables +set(TARGET aoc2022) +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# Set the etape value +set(DAY "1" CACHE STRING "Enter the day to compile.") + +# Get the sources and headers +file(GLOB SOURCES "${PROJECT_SOURCE_DIR}/day${DAY}/src/*.cpp") +add_executable(${TARGET} ${SOURCES}) +target_include_directories(${TARGET} PUBLIC "${PROJECT_SOURCE_DIR}/day${DAY}/include/") + +# Adding compilation option depending on the OS +if(MSVC) + target_compile_options(${TARGET} PUBLIC /W3 /WX /DEBUG ) +else() + target_compile_options(${TARGET} PUBLIC -Wall -Wextra -Wpedantic -Werror -lstdc++) +endif() + diff --git a/cpp/day1/src/main.cpp b/cpp/day1/src/main.cpp new file mode 100644 index 0000000..e84a10b --- /dev/null +++ b/cpp/day1/src/main.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + std::cout << "Bonjour Monde!" << std::endl; + return 0; +} \ No newline at end of file diff --git a/cpp/run.bat b/cpp/run.bat new file mode 100644 index 0000000..2d4c39f --- /dev/null +++ b/cpp/run.bat @@ -0,0 +1,5 @@ +echo off +cmake --build build +cd build/Debug +aoc2022.exe +cd ../.. \ No newline at end of file diff --git a/cpp/run.sh b/cpp/run.sh new file mode 100644 index 0000000..6034433 --- /dev/null +++ b/cpp/run.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cmake --build build +"./build/aoc2022" \ No newline at end of file diff --git a/day1/Cargo.lock b/rust/day1/Cargo.lock similarity index 100% rename from day1/Cargo.lock rename to rust/day1/Cargo.lock diff --git a/day1/Cargo.toml b/rust/day1/Cargo.toml similarity index 100% rename from day1/Cargo.toml rename to rust/day1/Cargo.toml diff --git a/day1/elves b/rust/day1/elves similarity index 100% rename from day1/elves rename to rust/day1/elves diff --git a/day1/src/elves.rs b/rust/day1/src/elves.rs similarity index 100% rename from day1/src/elves.rs rename to rust/day1/src/elves.rs diff --git a/day1/src/main.rs b/rust/day1/src/main.rs similarity index 100% rename from day1/src/main.rs rename to rust/day1/src/main.rs