diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..1d3aea1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.16) +project(sse_cmake_exercise) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(Boost REQUIRED COMPONENTS filesystem system) +find_package(deal.II REQUIRED) +find_package(yaml-cpp REQUIRED) + +set(SOURCE_FILES + fem/fem.cpp + flatset/flatset.cpp + filesystem/filesystem.cpp + yamlParser/yamlParser.cpp +) + +add_executable(${PROJECT_NAME} main.cpp ${SOURCE_FILES}) + +target_link_libraries(${PROJECT_NAME} + ${Boost_LIBRARIES} + yaml-cpp +) + +DEAL_II_SETUP_TARGET(${PROJECT_NAME}) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c7aa6bc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM ubuntu:24.04 +RUN sed -i 's|http://ports.ubuntu.com/ubuntu-ports|http://mirrors.edge.kernel.org/ubuntu|g' /etc/apt/sources.list +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y \ + build-essential cmake git wget unzip \ + libdeal.ii-dev libboost-all-dev libopenmpi-dev + +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 .. -DCMAKE_BUILD_TYPE=Release && \ + make -j$(nproc) && make install + + +ENV LD_LIBRARY_PATH=/usr/local/lib + + +WORKDIR /cmake-exercise +COPY . /cmake-exercise + +CMD ["/bin/bash"] diff --git a/build_and_run.sh b/build_and_run.sh old mode 100755 new mode 100644 index 60c4293..b01702e --- a/build_and_run.sh +++ b/build_and_run.sh @@ -1,7 +1,11 @@ -#!/usr/bin/env bash +#!/bin/bash +set -e +rm -rf build mkdir build cd build -cmake -DCMAKE_BUILD_TYPE=Debug .. -make -./main ../yamlParser/config.yml + +cmake -DCMAKE_BUILD_TYPE=Release .. +make -j + +./sse_cmake_exercise ../yamlParser/config.yml diff --git a/main.cpp b/main.cpp index 7588360..ba913dc 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; }