-
Notifications
You must be signed in to change notification settings - Fork 33
Add building and container recipes #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| cmake_minimum_required(VERSION "3.12") | ||
|
|
||
| project("main") | ||
|
|
||
| find_package(Boost REQUIRED COMPONENTS filesystem) | ||
| find_package(deal.II REQUIRED) | ||
| find_package(yaml-cpp REQUIRED) | ||
|
|
||
| deal_ii_initialize_cached_variables() | ||
|
|
||
| add_executable(main main.cpp filesystem/filesystem.cpp fem/fem.cpp flatset/flatset.cpp yamlParser/yamlParser.cpp) | ||
|
|
||
| deal_ii_setup_target(main) | ||
|
|
||
| target_link_libraries(main Boost::filesystem yaml-cpp) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| FROM ubuntu:24.04 | ||
|
|
||
| # Dependencies | ||
| RUN apt-get update | ||
| RUN apt install -y build-essential | ||
| RUN apt install -y cmake | ||
| RUN apt install -y unzip | ||
| RUN apt install -y wget | ||
| RUN apt install -y vim | ||
| RUN apt install -y libboost-all-dev | ||
| Run apt install -y libdeal.ii-dev | ||
|
Comment on lines
+10
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While uppercase/lowercase does not matter, I would stick to one (typically uppercase in Dockerfiles). Similarly for CMake (lowercase). |
||
|
|
||
| # Yaml | ||
| 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 | ||
| RUN cd yaml-cpp-yaml-cpp-0.6.3 && mkdir build && cd build && cmake .. && make && make install | ||
| ENV LD_LIBRARY_PATH = /usr/local/bin | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This leads to the Use either By the way, the value should be |
||
|
|
||
| WORKDIR mnt/host | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
|
||
| # Execute default command | ||
| #CMD ["/bin/bash"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,55 @@ | ||
| # 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). | ||
|
|
||
| # Instructions | ||
|
|
||
| The imageName has to be chosen! ("cmakeFight" could be a fitting name) | ||
|
|
||
| 1. Build the image via (getting all dependencies will take some time) | ||
| ```shell | ||
| docker buildx build -t <imageName> . | ||
| ``` | ||
|
|
||
| 2. Run the container | ||
|
|
||
| ```shell | ||
| docker run -it --mount type=bind,src=.,dst=/mnt/host/cmake-exercise <imageName> | ||
| ``` | ||
|
|
||
| 3. Change directory into the repo | ||
|
|
||
| ```shell | ||
| cd cmake-exercise | ||
| ``` | ||
|
|
||
| 4. Run the shell script (build folder should not exist beforehand!) | ||
|
|
||
| ```shell | ||
| ./build_and_run.sh | ||
| ``` | ||
|
|
||
| Expected output: | ||
|
|
||
| ```markdown | ||
| Let's fight with CMake, Docker, and some dependencies! | ||
|
|
||
| Solve Poisson problem with FEM using deal.II | ||
| FEM results available in `solution.vtk`. Try visualizing with Paraview. | ||
|
|
||
| Modify a flat set using boost container | ||
| Elements in s1: 1 2 3 4 | ||
|
|
||
| Inspect the current directory using boost filesystem | ||
| "." is a directory containing: | ||
| "CMakeCache.txt" | ||
| "CMakeFiles" | ||
| "Makefile" | ||
| "cmake_install.cmake" | ||
| "main" | ||
| "solution.vtk" | ||
|
|
||
| Parse some yaml file with yaml-cpp | ||
| ../yamlParser/config.yml | ||
| Version: 1.2.3 | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 <iostream> | ||
|
|
||
| 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; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, this can also be different from the name of the executable (and is typically something more descriptive).