Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build/
/main
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.28)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not add the latest version as minimum required if there is no special reason: this might cause issues in older systems.


project(cmake_exercise)

find_package(Boost REQUIRED COMPONENTS filesystem)
find_package(deal.II REQUIRED)
find_package(yaml-cpp REQUIRED)

add_executable(main
main.cpp
filesystem/filesystem.cpp
flatset/flatset.cpp
fem/fem.cpp
yamlParser/yamlParser.cpp
)

target_link_libraries(main ${Boost_LIBRARIES} yaml-cpp)

deal_ii_setup_target(main)
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ubuntu:24.04

RUN apt-get update && apt-get install -y \
# Packages recommended by the exercise:
build-essential cmake unzip wget vim \
# Boost filesystem:
libboost-all-dev \
# deal.II:
libdeal.ii-dev

# yaml-cpp from apt:
# RUN apt-get update && apt-get install -y libyaml-cpp-dev

# yaml-cpp from source:
RUN mkdir yaml-cpp && cd yaml-cpp && \
wget https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.6.3.tar.gz && \
tar --extract -f yaml-cpp-0.6.3.tar.gz && \
cd yaml-cpp-yaml-cpp-0.6.3 && mkdir build && cd build && \
cmake -DYAML_BUILD_SHARED_LIBS=ON .. && make && make install && \
cd ../../.. && rm -rf yaml-cpp

WORKDIR /mnt/host/
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a WORKDIR defined, I would expect it to exist independently of the user-defined mount (e.g., with files copied).

52 changes: 26 additions & 26 deletions main.cpp
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;
}