Seems to be fully statically built now.
Some checks failed
Dropshell Test / Build_and_Test (push) Failing after 1m15s

This commit is contained in:
Your Name
2025-05-25 23:47:12 +12:00
parent 08794e6480
commit 1b35f74bfe
6 changed files with 57 additions and 104 deletions

View File

@ -1,6 +1,15 @@
cmake_minimum_required(VERSION 3.10)
project(dropshell VERSION 1.0.0 LANGUAGES CXX)
# Force static linking globally
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries" FORCE)
set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
set(ZLIB_USE_STATIC_LIBS "ON")
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_C_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -89,7 +98,8 @@ FetchContent_Declare(
GIT_TAG v2.1.5
)
FetchContent_MakeAvailable(libassert)
include(FetchContent)
# Add cpptrace
FetchContent_Declare(
cpptrace
GIT_REPOSITORY https://github.com/jeremy-rifkin/cpptrace.git
@ -97,14 +107,6 @@ FetchContent_Declare(
)
FetchContent_MakeAvailable(cpptrace)
# Add cpp-httplib
FetchContent_Declare(
cpp-httplib
GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git
GIT_TAG v0.14.1
)
FetchContent_MakeAvailable(cpp-httplib)
# Add nlohmann/json
FetchContent_Declare(
nlohmann_json
@ -113,25 +115,16 @@ FetchContent_Declare(
)
FetchContent_MakeAvailable(nlohmann_json)
# Find zlib
find_package(ZLIB REQUIRED)
# Force static linking for zlib
set(ZLIB_USE_STATIC_LIBS TRUE)
set(ZLIB_LIBRARIES z)
# Link libraries
target_link_libraries(dropshell PRIVATE
libassert::assert
cpptrace::cpptrace
httplib::httplib
nlohmann_json::nlohmann_json
${ZLIB_LIBRARIES}
)
# Set static linking flags
set_target_properties(dropshell PROPERTIES
LINK_FLAGS "-static-libstdc++ -static-libgcc -Wl,-Bstatic -lz -Wl,-Bdynamic"
LINK_FLAGS "-static"
)
# Install targets