Switching to static + musl

This commit is contained in:
Your Name
2025-05-03 11:22:32 +12:00
parent 3c5fc11065
commit dc6586388c
3 changed files with 18 additions and 5 deletions

View File

@@ -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
)

View File

@@ -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)

View File

@@ -1,4 +1,3 @@
#include <zlib.h>
#include <string>
#include <cstdint>