diff --git a/CMakeLists.txt b/CMakeLists.txt index 270ef5131..b757b7016 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,6 +142,12 @@ add_executable(ProofOfSpace ${BLAKE3_SRC} ) +option(BUILD_PROOF_OF_SPACE_STATICALLY "Build ProofOfSpace target statically" OFF) +IF (BUILD_PROOF_OF_SPACE_STATICALLY) + message("Statically build ProofOfSpace") + target_link_libraries(ProofOfSpace -static -Wl,--whole-archive -lrt -lpthread -Wl,--no-whole-archive) +ENDIF() + add_executable(RunTests tests/test-main.cpp tests/test.cpp diff --git a/Dockerfile b/Dockerfile index 1d6e76b2d..064a7a3eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM ubuntu:20.04 as builder ARG DEBIAN_FRONTEND=noninteractive +ARG BUILD_PROOF_OF_SPACE_STATICALLY=OFF RUN apt-get update -y @@ -20,7 +21,7 @@ COPY . . RUN mkdir -p build WORKDIR /app/build -RUN cmake ../ +RUN cmake -DBUILD_PROOF_OF_SPACE_STATICALLY=${BUILD_PROOF_OF_SPACE_STATICALLY} ../ RUN cmake --build . -- -j `nproc` @@ -29,4 +30,3 @@ FROM ubuntu:20.04 COPY --from=builder /app/build /app CMD ["/app/ProofOfSpace"] - diff --git a/README.md b/README.md index 87ff9570b..e031362d1 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,14 @@ cmake ../ cmake --build . -- -j 6 ``` +## Static Compilation With glibc +### Statically compile ProofOfSpace +```bash +mkdir -p build && cd build +cmake -DBUILD_PROOF_OF_SPACE_STATICALLY=ON ../ +cmake --build . -- -j 6 +``` + ### Run tests ```bash