Merge pull request #38 from justdan96/bug-static-segfault

use workaround for segfaults with statically-linked builds on Linux
master
Dan 2019-11-25 14:10:44 +00:00 committed by GitHub
commit aa01ba5719
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 5 deletions

View File

@ -67,6 +67,7 @@ if(TSMUXER_STATIC_BUILD)
else()
set (CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
endif()
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
endif()
function(pkg_check_modules_with_static prefix req_or_opt package)
@ -91,11 +92,16 @@ target_include_directories(tsmuxer PRIVATE
"${PROJECT_SOURCE_DIR}/../libmediation"
${ZLIB_INCLUDE_DIRS}
)
target_link_libraries(tsmuxer
mediation
Threads::Threads
${ZLIB_LIBRARIES}
)
# this part looks messy as it is working around a bug in pthread when static linking
SET(THREADSLIB Threads::Threads)
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)
target_sources(tsmuxer PRIVATE osdep/textSubtitlesRenderWin32.cpp)