From 9bc7e4aecbbaf8cd3f473179ba13ce85a4e764d8 Mon Sep 17 00:00:00 2001 From: Christoph Heiss Date: Thu, 8 Mar 2018 09:21:19 +0100 Subject: [PATCH] Fix compilation under Linux. Apparently, on macOS the threads libraries are automatically linked, but not on Linux. --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 306ce83..5bd188d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,8 @@ project(resply VERSION 0.1.0 DESCRIPTION "Modern redis client for C++") set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +find_package(Threads REQUIRED) + option(BUILD_DOC "Build documentation using doxygen" ON) add_definitions(-DASIO_STANDALONE) @@ -92,7 +94,7 @@ install(FILES include/resply.h DESTINATION include) # cli add_executable(resply-cli src/resply-cli.cc) -target_link_libraries(resply-cli resply-static) +target_link_libraries(resply-cli resply-static ${CMAKE_THREAD_LIBS_INIT}) add_executable(proto-cli src/proto-cli.cc ${GENERATED_PROTOBUF_FILES}) target_link_libraries(proto-cli ${PROTOBUF_LIBRARIES}) @@ -112,7 +114,7 @@ foreach (test_source ${tests_source}) set(tests ${tests} ${name}) add_executable(${name} ${test_source}) - target_link_libraries(${name} resply-static) + target_link_libraries(${name} resply-static ${CMAKE_THREAD_LIBS_INIT}) set_target_properties(${name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) endforeach ()