From c7728e5c4c541147ae52e8cfc055700daa36c200 Mon Sep 17 00:00:00 2001 From: FabioTucciarone Date: Sun, 23 Nov 2025 20:04:46 +0100 Subject: [PATCH] Create Dockerfile, CMakeLists and uncomment code in main --- CMakeLists.txt | 15 +++++++++++++++ Dockerfile | 23 ++++++++++++++++++++++ main.cpp | 52 +++++++++++++++++++++++++------------------------- 3 files changed, 64 insertions(+), 26 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 Dockerfile diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7d1632e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.22) + +project(cmake-exercise) + +add_executable(main main.cpp fem/fem.cpp filesystem/filesystem.cpp flatset/flatset.cpp yamlParser/yamlParser.cpp) + +find_package(yaml-cpp 0.6.3 REQUIRED) +find_package(Boost 1.83 REQUIRED COMPONENTS filesystem container) +find_package(deal.II 9.5.1 REQUIRED) + +target_link_libraries(main ${Boost_LIBRARIES} yaml-cpp) +target_include_directories(main PRIVATE ${Boost_INCLUDE_DIR}) + +deal_ii_initialize_cached_variables() +deal_ii_setup_target(main) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..64a2ae8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM ubuntu:24.04 + +RUN apt-get update -y + +WORKDIR /usr/app + +# Install necessary tools and libraries for building +RUN apt-get install -y build-essential cmake wget +RUN apt-get install -y libboost-all-dev libdeal.ii-dev + +# Build yaml-cpp 0.6.3 from source +RUN wget https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.6.3.tar.gz +RUN tar -xzf yaml-cpp-0.6.3.tar.gz && rm yaml-cpp-0.6.3.tar.gz +WORKDIR /usr/app/yaml-cpp-yaml-cpp-0.6.3 +RUN mkdir build && \ + cd build && \ + cmake -DCMAKE_BUILD_TYPE=Release -DYAML_BUILD_SHARED_LIBS=on .. && \ + cmake --build . && \ + make install + +ENV LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH} + +WORKDIR /mnt/host 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; }