diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 69141ea..94caf0d 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -116,18 +116,22 @@ 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::ZLIB + ${ZLIB_LIBRARIES} ) # Set static linking flags set_target_properties(dropshell PROPERTIES - LINK_FLAGS "-static-libstdc++ -static-libgcc -Wl,-Bstatic -Wl,-Bdynamic" + LINK_FLAGS "-static-libstdc++ -static-libgcc -Wl,-Bstatic -lz -Wl,-Bdynamic" ) # Install targets diff --git a/source/build.sh b/source/build.sh index e47af93..cb5b460 100755 --- a/source/build.sh +++ b/source/build.sh @@ -17,7 +17,6 @@ if command -v nproc >/dev/null 2>&1; then JOBS=$(nproc) fi - # Function to print status messages print_status() { echo -e "${GREEN}[*] $1${NC}" @@ -49,20 +48,25 @@ if ! command -v cmake &> /dev/null; then exit 1 fi -# Check if make is installed -if ! command -v make &> /dev/null; then - print_error "Make is not installed. Please install Make first." +# Check if Ninja is installed +if ! command -v ninja &> /dev/null; then + print_error "Ninja is not installed. Please install Ninja first." exit 1 fi +# Check if ccache is installed +if ! command -v ccache &> /dev/null; then + print_warning "ccache is not installed. Builds will be slower without it." + print_warning "Consider installing ccache for faster builds." +fi + # Configure with CMake print_status "Configuring with CMake..." -cmake .. -DCMAKE_BUILD_TYPE=Debug -#cmake .. -DCMAKE_BUILD_TYPE=Release +cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache # Build the project print_status "Building project..." -make -j"$JOBS" +ninja -j"$JOBS" # Check if build was successful if [ $? -eq 0 ]; then diff --git a/source/install_build_prerequisites.sh b/source/install_build_prerequisites.sh index da6f6cf..2e6ed3a 100755 --- a/source/install_build_prerequisites.sh +++ b/source/install_build_prerequisites.sh @@ -85,7 +85,7 @@ done # Install other required packages -apt install -y musl-tools wget tar +apt install -y musl-tools wget tar ccache ninja-build # Set install directory if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then