From 07036b6678e4c5b2a0a5abf2932e1b27c552c9ab Mon Sep 17 00:00:00 2001 From: Simon Merkle Date: Mon, 24 Nov 2025 20:55:37 +0100 Subject: [PATCH 1/4] Added basic Dockerfile and CMakeLists.txt so --- CMakeLists.txt | 4 ++++ Dockerfile | 8 ++++++++ README.md | 10 ++++++++++ 3 files changed, 22 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 Dockerfile diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..37047a9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.16) +project(cmake-exercise) + +add_executable(main main.cpp) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..73999ac --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM ubuntu:24.04 + +RUN apt-get update && \ + apt-get install -y \ + build-essential \ + cmake + +WORKDIR /cmake-exercise \ No newline at end of file diff --git a/README.md b/README.md index 9e27f1f..3df5747 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,13 @@ # 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). + +# Build and Running +docker build -t cmake-exercise . +docker run -it --rm -v :/cmake-exercise cmake-exercise +//Statt dem directory auch ${PWD} + +mkdir build +cmake .. +make +./main From b8e057ca2b77248966fb012c1a7e94358b9a8737 Mon Sep 17 00:00:00 2001 From: Simon Merkle Date: Mon, 24 Nov 2025 21:22:43 +0100 Subject: [PATCH 2/4] Edited Dockerfile, CMakeCache.txt, main.cpp to include Boost --- CMakeLists.txt | 16 +++++++++++++++- Dockerfile | 3 ++- main.cpp | 16 ++++++++-------- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37047a9..b0424f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,18 @@ cmake_minimum_required(VERSION 3.16) project(cmake-exercise) -add_executable(main main.cpp) \ No newline at end of file +# Find Boost package +find_package(Boost REQUIRED COMPONENTS filesystem) + +# Source files +add_executable(main + main.cpp + flatset/flatset.cpp + filesystem/filesystem.cpp +) + +# Include directories so that main can find header files +target_include_directories(main PUBLIC ${CMAKE_SOURCE_DIR}) + +# Needed to link boost filesystem +target_link_libraries(main PRIVATE Boost::filesystem) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 73999ac..53467a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ FROM ubuntu:24.04 RUN apt-get update && \ apt-get install -y \ build-essential \ - cmake + cmake \ + libboost-all-dev WORKDIR /cmake-exercise \ No newline at end of file diff --git a/main.cpp b/main.cpp index 7588360..785748a 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,6 @@ //#include "fem/fem.hpp" -//#include "flatset/flatset.hpp" -//#include "filesystem/filesystem.hpp" +#include "flatset/flatset.hpp" +#include "filesystem/filesystem.hpp" //#include "yamlParser/yamlParser.hpp" #include @@ -13,13 +13,13 @@ int main(int argc, char *argv[]) //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 6de730e2b8f7ec09742834327aa86f9d465b101e Mon Sep 17 00:00:00 2001 From: Simon Merkle Date: Mon, 24 Nov 2025 21:58:45 +0100 Subject: [PATCH 3/4] Edited Dockerfile, CMakeLists.txt, main.cpp to include deal.ii --- CMakeLists.txt | 14 ++++++++++++-- Dockerfile | 3 ++- main.cpp | 10 +++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0424f1..b3aee98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,18 +1,28 @@ cmake_minimum_required(VERSION 3.16) project(cmake-exercise) -# Find Boost package +set(CMAKE_CXX_STANDARD 17) + +# Find Boost package for flatset and filesystem find_package(Boost REQUIRED COMPONENTS filesystem) +# Find deal for fem +find_package(deal.II REQUIRED) +deal_ii_initialize_cached_variables() + # Source files add_executable(main main.cpp flatset/flatset.cpp filesystem/filesystem.cpp + fem/fem.cpp ) # Include directories so that main can find header files target_include_directories(main PUBLIC ${CMAKE_SOURCE_DIR}) # Needed to link boost filesystem -target_link_libraries(main PRIVATE Boost::filesystem) \ No newline at end of file +target_link_libraries(main Boost::filesystem) + +# macro: https://dealii.org/current/users/cmake_user.html#cmakeauto +deal_ii_setup_target(main) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 53467a7..1327ec7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ RUN apt-get update && \ apt-get install -y \ build-essential \ cmake \ - libboost-all-dev + libboost-all-dev \ + libdeal.ii-dev WORKDIR /cmake-exercise \ No newline at end of file diff --git a/main.cpp b/main.cpp index 785748a..e183452 100644 --- a/main.cpp +++ b/main.cpp @@ -1,4 +1,4 @@ -//#include "fem/fem.hpp" +#include "fem/fem.hpp" #include "flatset/flatset.hpp" #include "filesystem/filesystem.hpp" //#include "yamlParser/yamlParser.hpp" @@ -8,10 +8,10 @@ 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(); From 545155ca72a6245ea45d45e305a35ae37c28a839 Mon Sep 17 00:00:00 2001 From: Simon Merkle Date: Mon, 24 Nov 2025 23:00:20 +0100 Subject: [PATCH 4/4] Edited Dockerfile, CMakeLists.txt, main.cpp to include yaml --- CMakeLists.txt | 7 +++++++ Dockerfile | 22 +++++++++++++++++++++- main.cpp | 26 +++++++++++++------------- 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b3aee98..ef192b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,12 +10,16 @@ find_package(Boost REQUIRED COMPONENTS filesystem) find_package(deal.II REQUIRED) deal_ii_initialize_cached_variables() +# Find yaml +find_package(yaml-cpp REQUIRED) + # Source files add_executable(main main.cpp flatset/flatset.cpp filesystem/filesystem.cpp fem/fem.cpp + yamlParser/yamlParser.cpp ) # Include directories so that main can find header files @@ -24,5 +28,8 @@ target_include_directories(main PUBLIC ${CMAKE_SOURCE_DIR}) # Needed to link boost filesystem target_link_libraries(main Boost::filesystem) +# Needed to link yaml +target_link_libraries(main yaml-cpp) + # macro: https://dealii.org/current/users/cmake_user.html#cmakeauto deal_ii_setup_target(main) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 1327ec7..5bd3186 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,26 @@ RUN apt-get update && \ build-essential \ cmake \ libboost-all-dev \ - libdeal.ii-dev + libdeal.ii-dev \ + wget \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +# Download yaml 0.6.3 +WORKDIR /tmp +RUN wget https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.6.3.zip +RUN unzip yaml-cpp-0.6.3.zip + +# Building yaml +WORKDIR /tmp/yaml-cpp-yaml-cpp-0.6.3/build +RUN cmake .. -DYNAML_BUILD_SHARED_LIBS=ON && \ + make && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /tmp/yaml-cpp* + +ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH 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; }