From eccd0600edf0b3ea499d6679f0e0aa5b8644229f Mon Sep 17 00:00:00 2001 From: Gleb Popov <6yearold@gmail.com> Date: Sun, 3 May 2026 18:12:24 +0300 Subject: [PATCH] Check if -static-{libgcc,libstdc++} flags are supported before passing them This fixes build on FreeBSD (with Clang). --- src/CMakeLists.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5b369ac..e0894b2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,6 +14,10 @@ endif() set(_target_name linuxdeploy-plugin-appimage) +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag(-static-libstdc++ STATIC_LIBSTDCXX_SUPPORTED) +check_cxx_compiler_flag(-static-libgcc STATIC_LIBGCC_SUPPORTED) + # main executable add_executable(${_target_name} main.cpp) @@ -21,10 +25,14 @@ target_link_libraries(${_target_name} args) set(_cflags -static - -static-libstdc++ - -static-libgcc -flto ) +if(STATIC_LIBSTDCXX_SUPPORTED) + list(APPEND _cflags -static-libstdc++) +endif() +if(STATIC_LIBGCC_SUPPORTED) + list(APPEND _cflags -static-libgcc) +endif() target_compile_options(${_target_name} PUBLIC ${_cflags}) target_link_options(${_target_name} PUBLIC ${_cflags})