Skip to content

Commit eccd060

Browse files
committed
Check if -static-{libgcc,libstdc++} flags are supported before passing them
This fixes build on FreeBSD (with Clang).
1 parent f62e84f commit eccd060

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,25 @@ endif()
1414

1515
set(_target_name linuxdeploy-plugin-appimage)
1616

17+
include(CheckCXXCompilerFlag)
18+
check_cxx_compiler_flag(-static-libstdc++ STATIC_LIBSTDCXX_SUPPORTED)
19+
check_cxx_compiler_flag(-static-libgcc STATIC_LIBGCC_SUPPORTED)
20+
1721
# main executable
1822
add_executable(${_target_name} main.cpp)
1923

2024
target_link_libraries(${_target_name} args)
2125

2226
set(_cflags
2327
-static
24-
-static-libstdc++
25-
-static-libgcc
2628
-flto
2729
)
30+
if(STATIC_LIBSTDCXX_SUPPORTED)
31+
list(APPEND _cflags -static-libstdc++)
32+
endif()
33+
if(STATIC_LIBGCC_SUPPORTED)
34+
list(APPEND _cflags -static-libgcc)
35+
endif()
2836
target_compile_options(${_target_name} PUBLIC ${_cflags})
2937
target_link_options(${_target_name} PUBLIC ${_cflags})
3038

0 commit comments

Comments
 (0)