From 9ccd9dc1b388227b142486ddc9a1975dba61fcaa Mon Sep 17 00:00:00 2001 From: Zara Zlatanova Date: Wed, 26 Nov 2025 07:13:39 +0100 Subject: [PATCH 1/4] feat: add Dockerfile, CMakeLists file and modify main.cpp --- CMakeLists.txt | 22 ++++++++++++++++++++++ Dockerfile | 8 ++++++++ main.cpp | 26 +++++++++++++------------- 3 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 Dockerfile diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4e6d90a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.12) + +project(cmake-exercise) + +find_package(Boost 1.36.0 REQUIRED COMPONENTS container filesystem) +include_directories(${Boost_INCLUDE_DIRS}) + +find_package(deal.II 9.5.0 REQUIRED + HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} + ) +deal_ii_initialize_cached_variables() + +add_executable(main + main.cpp + flatset/flatset.cpp + filesystem/filesystem.cpp + fem/fem.cpp +) + +deal_ii_setup_target(main) + +target_link_libraries(main ${Boost_LIBRARIES}) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..93a1a89 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM ubuntu:24.04 + +RUN apt update -y && \ + apt install -y build-essential cmake libboost-all-dev libdeal.ii-dev + +WORKDIR /cmake-exercise + +COPY . . diff --git a/main.cpp b/main.cpp index 7588360..e183452 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,6 @@ -//#include "fem/fem.hpp" -//#include "flatset/flatset.hpp" -//#include "filesystem/filesystem.hpp" +#include "fem/fem.hpp" +#include "flatset/flatset.hpp" +#include "filesystem/filesystem.hpp" //#include "yamlParser/yamlParser.hpp" #include @@ -8,18 +8,18 @@ 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 ) From 170663ef437df0e5377796114758fda7bf476e8f Mon Sep 17 00:00:00 2001 From: Zara Zlatanova Date: Wed, 26 Nov 2025 08:07:22 +0100 Subject: [PATCH 2/4] feat: add optional yaml task --- CMakeLists.txt | 5 ++++- Dockerfile | 19 +++++++++++++++++-- main.cpp | 26 +++++++++++++------------- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e6d90a..3209bce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,13 +10,16 @@ find_package(deal.II 9.5.0 REQUIRED ) deal_ii_initialize_cached_variables() +find_package(yaml-cpp REQUIRED) + add_executable(main main.cpp flatset/flatset.cpp filesystem/filesystem.cpp fem/fem.cpp + yamlParser/yamlParser.cpp ) deal_ii_setup_target(main) -target_link_libraries(main ${Boost_LIBRARIES}) \ No newline at end of file +target_link_libraries(main ${Boost_LIBRARIES} yaml-cpp) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 93a1a89..66d8696 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,23 @@ FROM ubuntu:24.04 RUN apt update -y && \ - apt install -y build-essential cmake libboost-all-dev libdeal.ii-dev + apt install -y build-essential cmake unzip wget libboost-all-dev libdeal.ii-dev WORKDIR /cmake-exercise -COPY . . +RUN wget https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.6.3.tar.gz -O yaml-cpp.tar.gz && \ + tar -xzf yaml-cpp.tar.gz && \ + YAML_DIR=$(ls -d yaml-cpp-*) && \ + cd $YAML_DIR && \ + mkdir build && \ + cd build && \ + cmake .. && \ + make && \ + make install && \ + cd /cmake-exercise && \ + rm -rf yaml-cpp.tar.gz $YAML_DIR + +ENV LD_LIBRARY_PATH=/usr/local/lib + +WORKDIR /cmake-exercise + \ No newline at end of file diff --git a/main.cpp b/main.cpp index e183452..08bc4a9 100644 --- a/main.cpp +++ b/main.cpp @@ -1,7 +1,7 @@ #include "fem/fem.hpp" #include "flatset/flatset.hpp" #include "filesystem/filesystem.hpp" -//#include "yamlParser/yamlParser.hpp" +#include "yamlParser/yamlParser.hpp" #include int main(int argc, char *argv[]) @@ -22,18 +22,18 @@ int main(int argc, char *argv[]) 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; } From 1db0f28a4536b91f77501bcbd33667de95ec9e27 Mon Sep 17 00:00:00 2001 From: Zara Zlatanova Date: Wed, 26 Nov 2025 08:11:53 +0100 Subject: [PATCH 3/4] feat: extend readme file with instructions --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 9e27f1f..0626f07 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ # Let's Fight With CMake, Docker, and Some Dependencies Repository for the [CMake exercise](https://github.com/Simulation-Software-Engineering/Lecture-Material/blob/main/03_building_and_packaging/cmake_exercise.md). + +1. Build a docker image + +```bash +docker buildx build --tag sse-cmake-image . +``` + +2. Create and run docker container in interactive mode + +```bash +docker run -it --mount type=bind,src=.,dst=/cmake-exercise sse-cmake-image:latest +``` + +3. Once inside the container, you are inside the `cmake-exercise` directory, and can run + +```bash +./build_and_run.sh` +``` \ No newline at end of file From 46b8c25cd242730cf3021e4c738fab0f69281762 Mon Sep 17 00:00:00 2001 From: Zara Zlatanova Date: Wed, 26 Nov 2025 08:12:52 +0100 Subject: [PATCH 4/4] fix: remove typo from readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0626f07..08e9bea 100644 --- a/README.md +++ b/README.md @@ -17,5 +17,5 @@ docker run -it --mount type=bind,src=.,dst=/cmake-exercise sse-cmake-image:lates 3. Once inside the container, you are inside the `cmake-exercise` directory, and can run ```bash -./build_and_run.sh` +./build_and_run.sh ``` \ No newline at end of file