From 67174a9140f78895810d3ed2eb3dddb4c3e30913 Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Fri, 28 Oct 2016 20:24:08 +0800 Subject: [PATCH] add pthreads to sample executables, fixes #75 --- samples/CMakeLists.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 113ce8a5..038449bf 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -5,11 +5,20 @@ if(NOT COMBINED_PROJECT) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../source ${CMAKE_CURRENT_BINARY_DIR}/source) endif() -add_executable(sample-basic ${CMAKE_CURRENT_SOURCE_DIR}/samples/sample.cpp) +include_directories(${LIBRARY_INCLUDE_DIR}) + +add_executable(sample-basic ${CMAKE_CURRENT_SOURCE_DIR}/sample.cpp) target_link_libraries(sample-basic ${LIBRARY_NAME}) -add_executable(sample-decrypt ${CMAKE_CURRENT_SOURCE_DIR}/samples/decrypt.cpp) +add_executable(sample-decrypt ${CMAKE_CURRENT_SOURCE_DIR}/decrypt.cpp) target_link_libraries(sample-decrypt ${LIBRARY_NAME}) +if(NOT MSVC) + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) + target_link_libraries(sample-basic Threads::Threads) + target_link_libraries(sample-decrypt Threads::Threads) +endif() + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin) + DESTINATION ${CMAKE_BINARY_DIR}/bin)