diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ce90b2e --- /dev/null +++ b/CMakeLists.txt @@ -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() diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..20eaece --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/build_and_run.sh b/build_and_run.sh index 60c4293..d263094 100755 --- a/build_and_run.sh +++ b/build_and_run.sh @@ -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 .. 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 )