From 1cc6114bca16b0e8c229bd3b7c86bda2f6fe495b Mon Sep 17 00:00:00 2001 From: "Amine B. Hassouna" Date: Sun, 3 Feb 2019 09:26:15 +0100 Subject: [PATCH] Mark 'Threads' as a required dependency for SDL2 --- FindSDL2.cmake | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/FindSDL2.cmake b/FindSDL2.cmake index 92add4a..44d25a9 100644 --- a/FindSDL2.cmake +++ b/FindSDL2.cmake @@ -44,7 +44,7 @@ This module responds to the following cache variables: only applications need main(). Otherwise, it is assumed you are building an application and this module will attempt to locate and set the proper link flags - as part of the returned SDL_LIBRARIES variable. + as part of the returned SDL2_LIBRARIES variable. Don't forget to include SDLmain.h and SDLmain.m in your project for the @@ -71,6 +71,7 @@ Created by Amine Ben Hassouna: Adapt FindSDL.cmake to SDL2 (FindSDL2.cmake). Add cache variables for more flexibility: SDL2_PATH, SDL2_NO_DEFAULT_PATH (for details, see doc above). + Mark 'Threads' as a required dependency for non-OSX systems. Original FindSDL.cmake module: @@ -185,7 +186,19 @@ endif() # frameworks may already provide it. # But for non-OSX systems, I will use the CMake Threads package. if(NOT APPLE) - find_package(Threads) + find_package(Threads QUIET) + if(NOT CMAKE_THREAD_LIBS_INIT) + set(SDL2_THREADS_NOT_FOUND "Could NOT find Threads (Threads is required by SDL2).") + if(SDL2_FIND_REQUIRED) + message(FATAL_ERROR ${SDL2_THREADS_NOT_FOUND}) + else() + if(NOT SDL2_FIND_QUIETLY) + message(STATUS ${SDL2_THREADS_NOT_FOUND}) + endif() + return() + endif() + unset(SDL2_THREADS_NOT_FOUND) + endif() endif() # MinGW needs an additional link flag, -mwindows