Switching to static + musl
This commit is contained in:
@@ -4,7 +4,18 @@ project(simple_object_storage)
|
|||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
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_package(SQLite3 REQUIRED)
|
||||||
|
|
||||||
# Find all source files in src directory
|
# Find all source files in src directory
|
||||||
@@ -26,7 +37,7 @@ include_directories(
|
|||||||
# Create executable
|
# Create executable
|
||||||
add_executable(simple_object_storage ${SOURCES})
|
add_executable(simple_object_storage ${SOURCES})
|
||||||
|
|
||||||
# Link libraries
|
# Link libraries (CMake should find static versions now)
|
||||||
target_link_libraries(simple_object_storage
|
target_link_libraries(simple_object_storage
|
||||||
SQLite::SQLite3
|
SQLite::SQLite3
|
||||||
)
|
)
|
||||||
|
@@ -6,14 +6,17 @@ RUN apk add --no-cache \
|
|||||||
cmake \
|
cmake \
|
||||||
git \
|
git \
|
||||||
musl-dev \
|
musl-dev \
|
||||||
sqlite-dev
|
sqlite-dev \
|
||||||
|
tar \
|
||||||
|
gzip \
|
||||||
|
zlib-dev
|
||||||
|
|
||||||
# Copy source code
|
# Copy source code
|
||||||
COPY . /src
|
COPY . /src
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
RUN mkdir build && cd build && \
|
RUN rm -rf build && mkdir build && cd build && \
|
||||||
cmake .. -DCMAKE_EXE_LINKER_FLAGS="-static" && \
|
cmake .. -DCMAKE_EXE_LINKER_FLAGS="-static" && \
|
||||||
make -j$(nproc)
|
make -j$(nproc)
|
||||||
|
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
#include <zlib.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user