From 98c1c2fbf2c483efd4a84b907d2195bcdf948bf6 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 12 Aug 2012 16:18:59 +0200 Subject: [PATCH] Added threading support to CMake files. --- CMakeLists.txt | 6 ++++++ tests/CMakeLists.txt | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27a609a6..842612e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,12 @@ option(BUILD_SHARED_LIBS "Build shared libraries" OFF) find_package(OpenGL REQUIRED) +set(CMAKE_THREAD_PREFER_PTHREADS YES) +find_package(Threads) +if (CMAKE_THREAD_LIBS_INIT) + list(APPEND glfw_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) +endif() + #-------------------------------------------------------------------- # Enable all warnings on GCC, regardless of OS #-------------------------------------------------------------------- diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9be1c1cd..e2d2a825 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -31,6 +31,10 @@ add_executable(peter peter.c) add_executable(reopen reopen.c) add_executable(threads threads.c ${TINYCTHREAD}) +if (BUILD_SHARED_LIBS) + target_link_libraries(threads ${CMAKE_THREAD_LIBS_INIT}) +endif() + add_executable(accuracy WIN32 MACOSX_BUNDLE accuracy.c) set_target_properties(accuracy PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Accuracy")