use workaround for segfaults with statically-linked builds on Linux

master
Daniel Bryant 2019-11-25 14:08:48 +00:00
parent ec15888829
commit 9c32ab12c9
1 changed files with 11 additions and 5 deletions

View File

@ -67,6 +67,7 @@ if(TSMUXER_STATIC_BUILD)
else() else()
set (CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static") set (CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
endif() endif()
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
endif() endif()
function(pkg_check_modules_with_static prefix req_or_opt package) function(pkg_check_modules_with_static prefix req_or_opt package)
@ -91,11 +92,16 @@ target_include_directories(tsmuxer PRIVATE
"${PROJECT_SOURCE_DIR}/../libmediation" "${PROJECT_SOURCE_DIR}/../libmediation"
${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}
) )
target_link_libraries(tsmuxer
mediation # this part looks messy as it is working around a bug in pthread when static linking
Threads::Threads SET(THREADSLIB Threads::Threads)
${ZLIB_LIBRARIES} if(TSMUXER_STATIC_BUILD)
) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
message("-- Static Linux build, will link whole pthread!")
SET(THREADSLIB -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive)
endif()
endif()
target_link_libraries(tsmuxer mediation ${THREADSLIB} ${ZLIB_LIBRARIES})
if (WIN32) if (WIN32)
target_sources(tsmuxer PRIVATE osdep/textSubtitlesRenderWin32.cpp) target_sources(tsmuxer PRIVATE osdep/textSubtitlesRenderWin32.cpp)