From 0de029c7143ed73e5ffb264307e80718491f9de1 Mon Sep 17 00:00:00 2001 From: Jannik Date: Fri, 21 Nov 2025 23:19:05 +0100 Subject: [PATCH] task done, wouldnt want to to this again all the dependencies and errors i have no clue how to handle and the insane build time of the docker files depending on the dependencies one tries to install to fix the errors one gets is crazy #badcommitmessage --- .dockerignore | 2 ++ CMakeLists.txt | 41 +++++++++++++++++++++++++++++++++++++++ Dockerfile | 37 +++++++++++++++++++++++++++++++++++ main.cpp | 52 +++++++++++++++++++++++++------------------------- 4 files changed, 106 insertions(+), 26 deletions(-) create mode 100644 .dockerignore create mode 100644 CMakeLists.txt create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..20cd66d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +build/ +.git/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..8de5d32 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.16) +project(cmake_exercise CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Find Boost +find_package(Boost REQUIRED COMPONENTS filesystem system container) + +# Find deal.II +find_package(deal.II REQUIRED) +deal_ii_initialize_cached_variables() + +# Find yaml-cpp +find_package(yaml-cpp REQUIRED) + +add_executable(main + main.cpp + flatset/flatset.cpp + filesystem/filesystem.cpp + fem/fem.cpp + yamlParser/yamlParser.cpp +) + +# Add your own include dirs +target_include_directories(main PRIVATE + flatset + filesystem + fem + yamlParser + ${YAML_CPP_INCLUDE_DIRS} +) + +deal_ii_setup_target(main) + +# Link external libs +target_link_libraries(main + Boost::filesystem + Boost::system + ${YAML_CPP_LIBRARIES} +) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cc3b4bb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +FROM ubuntu:24.04 + + +# Install build tools and dependencies +RUN apt-get update && apt-get install -y \ + build-essential \ + cmake \ + libboost-all-dev \ + libdeal.ii-dev \ + libopenmpi-dev \ + wget \ + unzip + + + + + +# Build yaml-cpp (version 0.6.3) +WORKDIR /tmp +RUN wget -q https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.6.3.zip \ + && unzip -q yaml-cpp-0.6.3.zip \ + && cd yaml-cpp-yaml-cpp-0.6.3 \ + && mkdir build && cd build \ + && cmake -DCMAKE_BUILD_TYPE=Release .. \ + && make -j$(nproc) && make install + + + +# Build application +WORKDIR /app +COPY . /app + +#enable execution of build_and_run.sh and run it +# RUN chmod +x /app/build_and_run.sh +# RUN /app/build_and_run.sh + +CMD ["./build/main","/app/yamlParser/config.yml"] \ No newline at end of file diff --git a/main.cpp b/main.cpp index 7588360..08bc4a9 100644 --- a/main.cpp +++ b/main.cpp @@ -1,39 +1,39 @@ -//#include "fem/fem.hpp" -//#include "flatset/flatset.hpp" -//#include "filesystem/filesystem.hpp" -//#include "yamlParser/yamlParser.hpp" +#include "fem/fem.hpp" +#include "flatset/flatset.hpp" +#include "filesystem/filesystem.hpp" +#include "yamlParser/yamlParser.hpp" #include int main(int argc, char *argv[]) { std::cout << "Let's fight with CMake, Docker, and some dependencies!" << std::endl << std::endl; - //std::cout << "Solve Poisson problem with FEM using deal.II" << std::endl; - //Fem fem; - //fem.run(); - //std::cout << std::endl; + std::cout << "Solve Poisson problem with FEM using deal.II" << std::endl; + Fem fem; + fem.run(); + std::cout << std::endl; - //std::cout << "Modify a flat set using boost container" << std::endl; - //modifyAndPrintSets(); - //std::cout << std::endl; + std::cout << "Modify a flat set using boost container" << std::endl; + modifyAndPrintSets(); + std::cout << std::endl; - //std::cout << "Inspect the current directory using boost filesystem" << std::endl; - //inspectDirectory(); - //std::cout << std::endl; + std::cout << "Inspect the current directory using boost filesystem" << std::endl; + inspectDirectory(); + std::cout << std::endl; - //if ( argc == 2 ) - //{ - // const std::string yamlFile( argv[1] ); - // std::cout << "Parse some yaml file with yaml-cpp" << std::endl; - // std::cout << " " << yamlFile << std::endl; - // parseConfig( yamlFile ); - //} - //else - //{ - // std::cout << "To parse a yaml file please specify file on command line" << std::endl; - // std::cout << " ./main YAMLFILE" << std::endl; - //} + if ( argc == 2 ) + { + const std::string yamlFile( argv[1] ); + std::cout << "Parse some yaml file with yaml-cpp" << std::endl; + std::cout << " " << yamlFile << std::endl; + parseConfig( yamlFile ); + } + else + { + std::cout << "To parse a yaml file please specify file on command line" << std::endl; + std::cout << " ./main YAMLFILE" << std::endl; + } return 0; }