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.
This commit is contained in:
Rolf Eike Beer 2015-09-22 05:23:12 +02:00 committed by Brad King
parent a27bc0ccac
commit 9924a212f6
1 changed files with 15 additions and 3 deletions

View File

@ -39,7 +39,7 @@
#============================================================================= #=============================================================================
# Copyright 2002-2009 Kitware, Inc. # Copyright 2002-2009 Kitware, Inc.
# Copyright 2011-2014 Rolf Eike Beer <eike@sf-mail.de> # Copyright 2011-2015 Rolf Eike Beer <eike@sf-mail.de>
# #
# Distributed under the OSI-approved BSD License (the "License"); # Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details. # see accompanying file Copyright.txt for details.
@ -51,15 +51,23 @@
# (To distribute this file outside of CMake, substitute the full # (To distribute this file outside of CMake, substitute the full
# License text for the above reference.) # License text for the above reference.)
include (CheckIncludeFiles)
include (CheckLibraryExists) include (CheckLibraryExists)
include (CheckSymbolExists) include (CheckSymbolExists)
set(Threads_FOUND FALSE) set(Threads_FOUND FALSE)
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
set(CMAKE_REQUIRED_QUIET ${Threads_FIND_QUIETLY}) 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? # Do we have sproc?
if(CMAKE_SYSTEM_NAME MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD) 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) CHECK_INCLUDE_FILES("sys/types.h;sys/prctl.h" CMAKE_HAVE_SPROC_H)
endif() endif()
@ -120,7 +128,11 @@ if(CMAKE_HAVE_SPROC_H AND NOT CMAKE_THREAD_PREFER_PTHREAD)
set(CMAKE_USE_SPROC_INIT 1) set(CMAKE_USE_SPROC_INIT 1)
else() else()
# Do we have pthreads? # 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) if(CMAKE_HAVE_PTHREAD_H)
# #