diff --git a/CMakeLists.txt b/CMakeLists.txt index 72d570c..2964ec9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,18 @@ project(simple_object_storage) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -# Find required packages +# --- Static Linking & Musl Flags --- +# Prioritize static libraries (.a) +set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + +# General flags often used for static musl builds +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static") # Also for shared libs if any were built +# Optional: Force PIC for static libs if needed, though often handled by toolchain +# set(CMAKE_POSITION_INDEPENDENT_CODE ON) +# --- End Static Linking & Musl Flags --- + +# Find required packages (will now prefer .a files) find_package(SQLite3 REQUIRED) # Find all source files in src directory @@ -26,7 +37,7 @@ include_directories( # Create executable add_executable(simple_object_storage ${SOURCES}) -# Link libraries +# Link libraries (CMake should find static versions now) target_link_libraries(simple_object_storage SQLite::SQLite3 ) diff --git a/Dockerfile b/Dockerfile index 123a932..c386e9a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,14 +6,17 @@ RUN apk add --no-cache \ cmake \ git \ musl-dev \ - sqlite-dev + sqlite-dev \ + tar \ + gzip \ + zlib-dev # Copy source code COPY . /src WORKDIR /src # Build -RUN mkdir build && cd build && \ +RUN rm -rf build && mkdir build && cd build && \ cmake .. -DCMAKE_EXE_LINKER_FLAGS="-static" && \ make -j$(nproc) diff --git a/src/compress.hpp b/src/compress.hpp index 7b96ce3..7fe5452 100644 --- a/src/compress.hpp +++ b/src/compress.hpp @@ -1,4 +1,3 @@ -#include #include #include