diff --git a/cmake/modules/CheckCXX11Features.cmake b/cmake/modules/CheckCXX11Features.cmake index 3f6b8e2e3ca455f4dfba286170084435cf0521fe..5a3a7b852888fea255d244e8d81bdbc074435e42 100644 --- a/cmake/modules/CheckCXX11Features.cmake +++ b/cmake/modules/CheckCXX11Features.cmake @@ -278,8 +278,16 @@ if(${CMAKE_VERSION} VERSION_LESS "3.1") else() find_package(Threads) endif() -set(STDTHREAD_LINK_FLAGS "${CMAKE_THREAD_LIBS_INIT}" - CACHE STRING "Linker flags needed to get working C++11 threads support") + +# see whether threading needs -no-as-needed +if(EXISTS /etc/dpkg/origins/ubuntu) + set(NO_AS_NEEDED "-Wl,-no-as-needed") +else(EXISTS /etc/dpkg/origins/ubuntu) + set(NO_AS_NEEDED "") +endif(EXISTS /etc/dpkg/origins/ubuntu) + +set(STDTHREAD_LINK_FLAGS "${NO_AS_NEEDED} ${CMAKE_THREAD_LIBS_INIT}" + CACHE STRING "Linker flags needed to get working C++11 threads support. On Ubuntu it may be necessary to include -Wl,-no-as-needed (see FS#1650).") # set linker flags #