From b6f3b7614bf79c9609abc3258e7f651d762112fb Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Sun, 3 Apr 2016 11:05:12 +0200 Subject: [PATCH] Fix compilation of multithreading example on Debian with CMake 3.5.1 Compilation of the multithreading example on Debian with CMake 3.5.1 would fail with the following error because ${PTHREAD} was not set: [ 61%] Linking CXX executable bin/multithreading /usr/bin/ld: CMakeFiles/multithreading.dir/multithreading/multithreading.cpp.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5' This patch uses ${CMAKE_THREAD_LIB_INIT} [1] instead, initialized using find_package(Threads REQUIRED). [1] https://cmake.org/cmake/help/v2.8.12/cmake.html#module:FindThreads --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89b7dd93..b1c39bef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ ELSE(WIN32) find_library(VULKAN_LIB NAMES libvulkan.so PATHS ${CMAKE_SOURCE_DIR}/libs/vulkan) find_package(ASSIMP REQUIRED) find_package(XCB REQUIRED) + find_package(Threads REQUIRED) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_USE_PLATFORM_XCB_KHR") # Todo : android? ENDIF(WIN32) @@ -44,7 +45,7 @@ function(buildExample EXAMPLE_NAME) target_link_libraries(${EXAMPLE_NAME} ${VULKAN_LIB} ${ASSIMP_LIBRARIES} ${WINLIBS}) else(WIN32) add_executable(${EXAMPLE_NAME} ${EXAMPLE_NAME}/${EXAMPLE_NAME}.cpp ${SOURCE}) - target_link_libraries(${EXAMPLE_NAME} ${VULKAN_LIB} ${ASSIMP_LIBRARIES} ${PTHREAD}) + target_link_libraries(${EXAMPLE_NAME} ${VULKAN_LIB} ${ASSIMP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) endif(WIN32) endfunction(buildExample)