docs: Update 3 files
This commit is contained in:
@ -52,6 +52,9 @@ Two HTTP client approaches are available:
|
|||||||
|
|
||||||
**Simple approach (recommended for new base images):**
|
**Simple approach (recommended for new base images):**
|
||||||
```cmake
|
```cmake
|
||||||
|
# Add module path for FindCPRStatic
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "/usr/local/share/cmake/Modules")
|
||||||
|
|
||||||
find_package(nlohmann_json REQUIRED)
|
find_package(nlohmann_json REQUIRED)
|
||||||
find_package(CPRStatic REQUIRED)
|
find_package(CPRStatic REQUIRED)
|
||||||
|
|
||||||
|
@ -158,77 +158,6 @@ RUN curl -LO https://curl.se/download/curl-${CURL_VERSION}.tar.gz && \
|
|||||||
make install && \
|
make install && \
|
||||||
cd / && rm -rf /tmp/curl-${CURL_VERSION} /tmp/curl-${CURL_VERSION}.tar.gz
|
cd / && rm -rf /tmp/curl-${CURL_VERSION} /tmp/curl-${CURL_VERSION}.tar.gz
|
||||||
|
|
||||||
# Build CPR (C++ Requests) library statically
|
|
||||||
ARG CPR_VERSION=1.10.5
|
|
||||||
WORKDIR /tmp
|
|
||||||
RUN curl -LO https://github.com/libcpr/cpr/archive/refs/tags/${CPR_VERSION}.tar.gz && \
|
|
||||||
tar xzf ${CPR_VERSION}.tar.gz && \
|
|
||||||
cd cpr-${CPR_VERSION} && \
|
|
||||||
mkdir build && cd build && \
|
|
||||||
cmake .. \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
|
||||||
-DBUILD_SHARED_LIBS=OFF \
|
|
||||||
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
|
|
||||||
-DCMAKE_INSTALL_PREFIX=/usr/local \
|
|
||||||
-DCPR_USE_SYSTEM_CURL=ON \
|
|
||||||
-DCPR_ENABLE_SSL=ON \
|
|
||||||
-DCURL_INCLUDE_DIR=/usr/local/include \
|
|
||||||
-DCURL_LIBRARY=/usr/local/lib/libcurl.a \
|
|
||||||
-DOPENSSL_ROOT_DIR=/usr/local \
|
|
||||||
-DOPENSSL_USE_STATIC_LIBS=TRUE \
|
|
||||||
-DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \
|
|
||||||
-DZLIB_LIBRARY=/usr/lib/libz.a \
|
|
||||||
-Dzstd_LIBRARY=/usr/lib/libzstd.a && \
|
|
||||||
make -j$(nproc) && \
|
|
||||||
make install && \
|
|
||||||
cd / && rm -rf /tmp/cpr-${CPR_VERSION} /tmp/${CPR_VERSION}.tar.gz
|
|
||||||
|
|
||||||
# Create a CMake module for easy CPR static linking
|
|
||||||
RUN mkdir -p /usr/local/share/cmake/Modules
|
|
||||||
RUN cat > /usr/local/share/cmake/Modules/FindCPRStatic.cmake << 'EOF'
|
|
||||||
# FindCPRStatic.cmake - Easy CPR static linking for dropshell-build projects
|
|
||||||
#
|
|
||||||
# This module provides cpr::cpr_static target with all dependencies handled automatically.
|
|
||||||
# It works across all architectures by dynamically finding OpenSSL library paths.
|
|
||||||
#
|
|
||||||
# Usage in CMakeLists.txt:
|
|
||||||
# find_package(CPRStatic REQUIRED)
|
|
||||||
# target_link_libraries(${PROJECT_NAME} PRIVATE cpr::cpr_static)
|
|
||||||
|
|
||||||
# Find OpenSSL libraries (path varies by architecture)
|
|
||||||
find_library(OPENSSL_SSL_LIB NAMES ssl PATHS /usr/local/lib64 /usr/local/lib NO_DEFAULT_PATH)
|
|
||||||
find_library(OPENSSL_CRYPTO_LIB NAMES crypto PATHS /usr/local/lib64 /usr/local/lib NO_DEFAULT_PATH)
|
|
||||||
|
|
||||||
if(NOT OPENSSL_SSL_LIB OR NOT OPENSSL_CRYPTO_LIB)
|
|
||||||
message(FATAL_ERROR "OpenSSL libraries not found. Expected in /usr/local/lib64 or /usr/local/lib")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Create the CPR static target
|
|
||||||
if(NOT TARGET cpr::cpr_static)
|
|
||||||
add_library(cpr::cpr_static STATIC IMPORTED)
|
|
||||||
set_target_properties(cpr::cpr_static PROPERTIES
|
|
||||||
IMPORTED_LOCATION "/usr/local/lib/libcpr.a"
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "/usr/local/include"
|
|
||||||
INTERFACE_LINK_LIBRARIES "/usr/local/lib/libcurl.a;${OPENSSL_SSL_LIB};${OPENSSL_CRYPTO_LIB};/usr/lib/libz.a;/usr/lib/libzstd.a;lzma;dl"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Provide an alias for convenience
|
|
||||||
add_library(cpr::static ALIAS cpr::cpr_static)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Mark as found
|
|
||||||
set(CPRStatic_FOUND TRUE)
|
|
||||||
|
|
||||||
# Provide some useful variables
|
|
||||||
set(CPRStatic_LIBRARY "/usr/local/lib/libcpr.a")
|
|
||||||
set(CPRStatic_INCLUDE_DIR "/usr/local/include")
|
|
||||||
set(CPRStatic_SSL_LIBRARY "${OPENSSL_SSL_LIB}")
|
|
||||||
set(CPRStatic_CRYPTO_LIBRARY "${OPENSSL_CRYPTO_LIB}")
|
|
||||||
|
|
||||||
mark_as_advanced(CPRStatic_LIBRARY CPRStatic_INCLUDE_DIR CPRStatic_SSL_LIBRARY CPRStatic_CRYPTO_LIBRARY)
|
|
||||||
EOF
|
|
||||||
|
|
||||||
|
|
||||||
ARG MARIADB_CONNECTOR_VERSION=3.4.5
|
ARG MARIADB_CONNECTOR_VERSION=3.4.5
|
||||||
WORKDIR /tmp
|
WORKDIR /tmp
|
||||||
RUN curl -LO https://downloads.mariadb.com/Connectors/c/connector-c-${MARIADB_CONNECTOR_VERSION}/mariadb-connector-c-${MARIADB_CONNECTOR_VERSION}-src.tar.gz && \
|
RUN curl -LO https://downloads.mariadb.com/Connectors/c/connector-c-${MARIADB_CONNECTOR_VERSION}/mariadb-connector-c-${MARIADB_CONNECTOR_VERSION}-src.tar.gz && \
|
||||||
@ -342,6 +271,77 @@ RUN curl -LO https://github.com/nlohmann/json/archive/refs/tags/v${NLOHMANN_JSON
|
|||||||
make install && \
|
make install && \
|
||||||
cd / && rm -rf /tmp/json-${NLOHMANN_JSON_VERSION} /tmp/v${NLOHMANN_JSON_VERSION}.tar.gz
|
cd / && rm -rf /tmp/json-${NLOHMANN_JSON_VERSION} /tmp/v${NLOHMANN_JSON_VERSION}.tar.gz
|
||||||
|
|
||||||
|
# Build CPR (C++ Requests) library statically
|
||||||
|
ARG CPR_VERSION=1.10.5
|
||||||
|
WORKDIR /tmp
|
||||||
|
RUN curl -LO https://github.com/libcpr/cpr/archive/refs/tags/${CPR_VERSION}.tar.gz && \
|
||||||
|
tar xzf ${CPR_VERSION}.tar.gz && \
|
||||||
|
cd cpr-${CPR_VERSION} && \
|
||||||
|
mkdir build && cd build && \
|
||||||
|
cmake .. \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DBUILD_SHARED_LIBS=OFF \
|
||||||
|
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=/usr/local \
|
||||||
|
-DCPR_USE_SYSTEM_CURL=ON \
|
||||||
|
-DCPR_ENABLE_SSL=ON \
|
||||||
|
-DCURL_INCLUDE_DIR=/usr/local/include \
|
||||||
|
-DCURL_LIBRARY=/usr/local/lib/libcurl.a \
|
||||||
|
-DOPENSSL_ROOT_DIR=/usr/local \
|
||||||
|
-DOPENSSL_USE_STATIC_LIBS=TRUE \
|
||||||
|
-DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \
|
||||||
|
-DZLIB_LIBRARY=/usr/lib/libz.a \
|
||||||
|
-Dzstd_LIBRARY=/usr/lib/libzstd.a && \
|
||||||
|
make -j$(nproc) && \
|
||||||
|
make install && \
|
||||||
|
cd / && rm -rf /tmp/cpr-${CPR_VERSION} /tmp/${CPR_VERSION}.tar.gz
|
||||||
|
|
||||||
|
# Create a CMake module for easy CPR static linking
|
||||||
|
RUN mkdir -p /usr/local/share/cmake/Modules
|
||||||
|
RUN cat > /usr/local/share/cmake/Modules/FindCPRStatic.cmake << 'EOF'
|
||||||
|
# FindCPRStatic.cmake - Easy CPR static linking for dropshell-build projects
|
||||||
|
#
|
||||||
|
# This module provides cpr::cpr_static target with all dependencies handled automatically.
|
||||||
|
# It works across all architectures by dynamically finding OpenSSL library paths.
|
||||||
|
#
|
||||||
|
# Usage in CMakeLists.txt:
|
||||||
|
# find_package(CPRStatic REQUIRED)
|
||||||
|
# target_link_libraries(${PROJECT_NAME} PRIVATE cpr::cpr_static)
|
||||||
|
|
||||||
|
# Find OpenSSL libraries (path varies by architecture)
|
||||||
|
find_library(OPENSSL_SSL_LIB NAMES ssl PATHS /usr/local/lib64 /usr/local/lib NO_DEFAULT_PATH)
|
||||||
|
find_library(OPENSSL_CRYPTO_LIB NAMES crypto PATHS /usr/local/lib64 /usr/local/lib NO_DEFAULT_PATH)
|
||||||
|
|
||||||
|
if(NOT OPENSSL_SSL_LIB OR NOT OPENSSL_CRYPTO_LIB)
|
||||||
|
message(FATAL_ERROR "OpenSSL libraries not found. Expected in /usr/local/lib64 or /usr/local/lib")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Create the CPR static target
|
||||||
|
if(NOT TARGET cpr::cpr_static)
|
||||||
|
add_library(cpr::cpr_static STATIC IMPORTED)
|
||||||
|
set_target_properties(cpr::cpr_static PROPERTIES
|
||||||
|
IMPORTED_LOCATION "/usr/local/lib/libcpr.a"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "/usr/local/include"
|
||||||
|
INTERFACE_LINK_LIBRARIES "/usr/local/lib/libcurl.a;${OPENSSL_SSL_LIB};${OPENSSL_CRYPTO_LIB};/usr/lib/libz.a;/usr/lib/libzstd.a;lzma;dl"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Provide an alias for convenience
|
||||||
|
add_library(cpr::static ALIAS cpr::cpr_static)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Mark as found
|
||||||
|
set(CPRStatic_FOUND TRUE)
|
||||||
|
|
||||||
|
# Provide some useful variables
|
||||||
|
set(CPRStatic_LIBRARY "/usr/local/lib/libcpr.a")
|
||||||
|
set(CPRStatic_INCLUDE_DIR "/usr/local/include")
|
||||||
|
set(CPRStatic_SSL_LIBRARY "${OPENSSL_SSL_LIB}")
|
||||||
|
set(CPRStatic_CRYPTO_LIBRARY "${OPENSSL_CRYPTO_LIB}")
|
||||||
|
|
||||||
|
mark_as_advanced(CPRStatic_LIBRARY CPRStatic_INCLUDE_DIR CPRStatic_SSL_LIBRARY CPRStatic_CRYPTO_LIBRARY)
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
# Install upx
|
# Install upx
|
||||||
COPY opt /opt
|
COPY opt /opt
|
||||||
RUN /opt/install_upx.sh
|
RUN /opt/install_upx.sh
|
||||||
|
@ -34,23 +34,12 @@ target_include_directories(${PROJECT_NAME} PRIVATE
|
|||||||
${CMAKE_CURRENT_BINARY_DIR}/src/autogen
|
${CMAKE_CURRENT_BINARY_DIR}/src/autogen
|
||||||
src)
|
src)
|
||||||
|
|
||||||
|
# Add module path for FindCPRStatic
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "/usr/local/share/cmake/Modules")
|
||||||
|
|
||||||
# Find packages
|
# Find packages
|
||||||
find_package(nlohmann_json REQUIRED)
|
find_package(nlohmann_json REQUIRED)
|
||||||
|
find_package(CPRStatic REQUIRED)
|
||||||
# Try the new CPRStatic module first, fall back to manual setup
|
|
||||||
find_package(CPRStatic QUIET)
|
|
||||||
if(NOT CPRStatic_FOUND)
|
|
||||||
# Fallback for older base images
|
|
||||||
find_library(OPENSSL_SSL_LIB NAMES ssl PATHS /usr/local/lib64 /usr/local/lib NO_DEFAULT_PATH)
|
|
||||||
find_library(OPENSSL_CRYPTO_LIB NAMES crypto PATHS /usr/local/lib64 /usr/local/lib NO_DEFAULT_PATH)
|
|
||||||
|
|
||||||
add_library(cpr::cpr_static STATIC IMPORTED)
|
|
||||||
set_target_properties(cpr::cpr_static PROPERTIES
|
|
||||||
IMPORTED_LOCATION "/usr/local/lib/libcpr.a"
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "/usr/local/include"
|
|
||||||
INTERFACE_LINK_LIBRARIES "/usr/local/lib/libcurl.a;${OPENSSL_SSL_LIB};${OPENSSL_CRYPTO_LIB};/usr/lib/libz.a;/usr/lib/libzstd.a;lzma;dl"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Link libraries
|
# Link libraries
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||||
|
Reference in New Issue
Block a user