Skip to content
Open
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
60 changes: 60 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Set the minimum required version of CMake
cmake_minimum_required(VERSION 3.10)

# Set the project name
project(exercise)

# Set the C++ standard (adjust if needed)
set(CMAKE_CXX_STANDARD 14)


# Part 1
# Boost libraries
find_package(Boost 1.71 REQUIRED COMPONENTS filesystem)

# Include Boost headers
include_directories(${Boost_INCLUDE_DIRS})

# flatset
set(FLATSET_SOURCES flatset/flatset.cpp)

# Include directories for the flatset module
include_directories(flatset)

# Part 2
# deal II
find_package(deal.II REQUIRED HINTS ${DEAL_II_DIR}
PATHS /usr/lib/cmake/deal.II)

# Add the source file for the Fem class
set(FEM_SOURCES fem/fem.cpp)

# Include directories for the fem module
include_directories(fem)


# Part 3
# Filesystem
set(FILESYSTEM_SOURCES filesystem/filesystem.cpp)

# Include directories for the filesystem module
include_directories(filesystem)

# Add the source files to the executable
add_executable(main main.cpp ${FEM_SOURCES} ${FLATSET_SOURCES} ${FILESYSTEM_SOURCES})

# Link Boost Filesystem
target_link_libraries(main Boost::filesystem)


# Link deal.II to the executable
deal_ii_setup_target(main)

# If you need specific libraries or include directories, add them here:
# target_include_directories(main PRIVATE /path/to/headers)
# target_link_libraries(main PRIVATE /path/to/library)

# Optionally set debugging options
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Building in Debug mode")
endif()
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ubuntu:24.04

# apt-get installs basics
RUN apt-get update
RUN apt-get install build-essential cmake unzip wget vim -y
# boost
RUN apt-get install libboost-all-dev -y
# deal II
RUN apt-get install libdeal.ii-dev -y


# no more used, now use mount
WORKDIR /cmake-exercise
COPY . /cmake-exercise

# change the encoding of shell to remove '\r'
RUN sed -i 's/\r$//' build_and_run.sh
CMD ["/bin/bash"]
8 changes: 8 additions & 0 deletions build_and_run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Normalize line endings to LF
sed -i 's/\r$//' "$0"

#!/usr/bin/env bash

# Clean up the build directory if it exists
if [ -d "build" ]; then
rm -rf build
fi

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
Expand Down
26 changes: 13 additions & 13 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
//#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 <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 )
Expand Down