From 9924a212f671dfcc2b20d2a29da23bc440247f19 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Tue, 22 Sep 2015 05:23:12 +0200 Subject: [PATCH] FindThreads: replace CheckIncludeFiles by CheckIncludeFile While at it, also add a branch using CheckIncludeFileCXX. Also give a better error message if no supported language is enabled. C++ support isn't working yet, but it has never worked. --- Modules/FindThreads.cmake | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index a0bc4d133..88da7c510 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -39,7 +39,7 @@ #============================================================================= # Copyright 2002-2009 Kitware, Inc. -# Copyright 2011-2014 Rolf Eike Beer +# Copyright 2011-2015 Rolf Eike Beer # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -51,15 +51,23 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -include (CheckIncludeFiles) include (CheckLibraryExists) include (CheckSymbolExists) set(Threads_FOUND FALSE) set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) set(CMAKE_REQUIRED_QUIET ${Threads_FIND_QUIETLY}) +if(CMAKE_C_COMPILER_LOADED) + include (CheckIncludeFile) +elseif(CMAKE_CXX_COMPILER_LOADED) + include (CheckIncludeFileCXX) +else() + message(FATAL_ERROR "FindThreads only works if either C or CXX language is enabled") +endif() + # Do we have sproc? if(CMAKE_SYSTEM_NAME MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD) + include (CheckIncludeFiles) CHECK_INCLUDE_FILES("sys/types.h;sys/prctl.h" CMAKE_HAVE_SPROC_H) endif() @@ -120,7 +128,11 @@ if(CMAKE_HAVE_SPROC_H AND NOT CMAKE_THREAD_PREFER_PTHREAD) set(CMAKE_USE_SPROC_INIT 1) else() # Do we have pthreads? - CHECK_INCLUDE_FILES("pthread.h" CMAKE_HAVE_PTHREAD_H) + if(CMAKE_C_COMPILER_LOADED) + CHECK_INCLUDE_FILE("pthread.h" CMAKE_HAVE_PTHREAD_H) + else() + CHECK_INCLUDE_FILE_CXX("pthread.h" CMAKE_HAVE_PTHREAD_H) + endif() if(CMAKE_HAVE_PTHREAD_H) #