Use Threads::Threads and DL_LIBRARY for greater portability

master
Jos van den Oever 2017-09-03 16:24:23 +02:00
parent 543ba3a71a
commit d60d4cd5ee
3 changed files with 5 additions and 3 deletions

View File

@ -21,13 +21,15 @@ include(ECMPoQmTools)
find_package(Cargo REQUIRED)
find_package(Rust REQUIRED)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
# Runtime information library -- dl on Debian, execinfo on FreeBSD.
# This quiets a warning from rustc about linking to native artifacts.
if (CMAKE_SYSTEM MATCHES "FreeBSD")
find_library(DL_LIBRARY execinfo)
else()
find_library(DL_LIBRARY dl)
find_library(DL_LIBRARY ${CMAKE_DL_LIBS})
endif()
# It would be neater to use set_package_properties() here and to

View File

@ -25,7 +25,7 @@ add_custom_command(
add_custom_target(rust_target DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/rust/${RUST_TARGET_DIR}/librust.a")
list(APPEND DemoLibs "${CMAKE_CURRENT_SOURCE_DIR}/rust/${RUST_TARGET_DIR}/librust.a")
list(APPEND DemoLibs Qt5::Widgets Qt5::Svg pthread ${DL_LIBRARY})
list(APPEND DemoLibs Qt5::Widgets Qt5::Svg Threads::Threads ${DL_LIBRARY})
if (Qt5Quick_FOUND)
list(APPEND DemoLibs Qt5::Quick)
endif()

View File

@ -40,7 +40,7 @@ function(rust_test NAME DIRECTORY)
Qt5::Core
Qt5::Test
"${DIR}/${RUST_TARGET_DIR}/librust.a"
pthread ${DL_LIBRARY}
Threads::Threads ${DL_LIBRARY}
)
set_property(TARGET ${NAME}
APPEND PROPERTY AUTOGEN_TARGET_DEPENDS "${SRC}/${NAME}_rust.h"