From f9578a5eda9a06a0be97f3df15b43d0f75ab6018 Mon Sep 17 00:00:00 2001 From: prasithbasky Date: Tue, 25 Nov 2025 23:29:13 +0100 Subject: [PATCH] New file CMakeLists.txt and Dockerfile is added with required contents and main.cpp is uncommented --- CMakeLists.txt | 32 +++++++++++++++++++++++++++++++ Dockerfile | 30 +++++++++++++++++++++++++++++ main.cpp | 52 +++++++++++++++++++++++++------------------------- 3 files changed, 88 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..8ce87f5 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.16) +project(cmake_excercise) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(Boost REQUIRED COMPONENTS filesystem) +find_package(deal.II REQUIRED) +find_package(yaml-cpp REQUIRED) + +add_executable(main main.cpp) + +target_sources(main PRIVATE + flatset/flatset.cpp + filesystem/filesystem.cpp + fem/fem.cpp + yamlParser/yamlParser.cpp +) + +target_include_directories(main PUBLIC + ${CMAKE_SOURCE_DIR}/flatset + ${CMAKE_SOURCE_DIR}/filesystem + ${CMAKE_SOURCE_DIR}/fem + ${CMAKE_SOURCE_DIR}/yamlParser +) + +target_link_libraries(main Boost::filesystem) + +DEAL_II_SETUP_TARGET(main) +target_link_libraries(main ${DEAL_II_LIBRARIES}) + +target_link_libraries(main yaml-cpp) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..57fbfab --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM ubuntu:24.04 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y \ + build-essential \ + cmake \ + git \ + wget \ + unzip \ + vim \ + libboost-all-dev \ + libdeal.ii-dev \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /tmp + +RUN wget https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.6.3.zip \ + && unzip yaml-cpp-0.6.3.zip \ + && cd yaml-cpp-yaml-cpp-0.6.3 \ + && mkdir build && cd build \ + && cmake -DYAML_BUILD_SHARED_LIBS=ON .. \ + && make install \ + && cd /tmp \ + && rm -rf yaml-cpp-yaml-cpp-0.6.3 yaml-cpp-0.6.3.zip + +ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + +WORKDIR /cmake-exercise +COPY . . 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; }