diff --git a/CMakeLists.txt b/CMakeLists.txt index 94d6c2c..5aa9ca0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,3 +20,26 @@ target_link_libraries(cpackexamplelib Boost::filesystem ${YAML_CPP_LIBRARIES}) DEAL_II_SETUP_TARGET("${PROJECT_NAME}") DEAL_II_SETUP_TARGET(cpackexamplelib) + +# Install the executable to /bin/ +install(TARGETS "${PROJECT_NAME}" + RUNTIME DESTINATION bin +) + +# Install the library to /lib/ +install(TARGETS cpackexamplelib + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib +) + +# Install header files to /include/cpackexamplelib/ +install(FILES + fem/fem.hpp + filesystem/filesystem.hpp + flatset/flatset.hpp + yamlParser/yamlParser.hpp + DESTINATION include/cpackexamplelib +) + +# Include CPack configuration +include(cmake/CPackConfig.cmake) diff --git a/Dockerfile b/Dockerfile index bd5207d..6fb1881 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -From ubuntu:24.04 +FROM ubuntu:24.04 # Install a few dependencies RUN apt-get -qq update && \ @@ -12,7 +12,10 @@ RUN apt-get -qq update && \ vim \ tree \ lintian \ - unzip + tree \ + lintian \ + unzip \ + rsync # Get, unpack, build, and install yaml-cpp RUN mkdir software && cd software && \ @@ -25,4 +28,31 @@ ENV LIBRARY_PATH $LIBRARY_PATH:/usr/local/lib/ ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/local/lib/ ENV PATH $PATH:/usr/local/bin/ -CMD ["/bin/bash"] +# Create entrypoint script inside the image +RUN echo '#!/bin/bash' > /entrypoint.sh && \ + echo 'set -e' >> /entrypoint.sh && \ + echo 'SOURCE_DIR="/mnt/cpack-exercise"' >> /entrypoint.sh && \ + echo 'BUILD_DIR="/tmp/build"' >> /entrypoint.sh && \ + echo 'if [ ! -d "$SOURCE_DIR" ]; then' >> /entrypoint.sh && \ + echo ' echo "Error: Source directory $SOURCE_DIR not found. Did you mount the volume?"' >> /entrypoint.sh && \ + echo ' exit 1' >> /entrypoint.sh && \ + echo 'fi' >> /entrypoint.sh && \ + echo 'echo "Setting up build environment..."' >> /entrypoint.sh && \ + echo 'mkdir -p "$BUILD_DIR"' >> /entrypoint.sh && \ + echo 'rsync -av --exclude "build" "$SOURCE_DIR/" "$BUILD_DIR/"' >> /entrypoint.sh && \ + echo 'cd "$BUILD_DIR"' >> /entrypoint.sh && \ + echo 'echo "Configuring project..."' >> /entrypoint.sh && \ + echo 'cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON .' >> /entrypoint.sh && \ + echo 'echo "Building project..."' >> /entrypoint.sh && \ + echo 'cmake --build build' >> /entrypoint.sh && \ + echo 'echo "Creating packages..."' >> /entrypoint.sh && \ + echo 'cd build' >> /entrypoint.sh && \ + echo 'cpack -G TGZ' >> /entrypoint.sh && \ + echo 'cpack -G DEB' >> /entrypoint.sh && \ + echo 'echo "Copying packages to host..."' >> /entrypoint.sh && \ + echo 'cp *.tar.gz "$SOURCE_DIR/"' >> /entrypoint.sh && \ + echo 'cp *.deb "$SOURCE_DIR/"' >> /entrypoint.sh && \ + echo 'echo "Done! Packages are available in $SOURCE_DIR"' >> /entrypoint.sh && \ + chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"]