[CMake] CheckIncludeFiles.cmake Question

Rolf Eike Beer eike at sf-mail.de
Wed Apr 30 15:08:53 EDT 2014


Jack Morrison wrote:
> The conditional here:
> 
> https://github.com/Kitware/CMake/blob/master/Modules/CheckIncludeFiles.cmake
> #L42
> 
> causes me issues when called with CMAKE_HAVE_PTHREAD_H in FindThreads. It
> evaluates to false, leaving pthread.h to not be found and FindThreads to
> fail.
> 
> What is the purpose of this conditional and why would it cause this
> FindThreads call to fail?

The idea is to check if whatever is given in variable is not already defined.

So: VARIABLE contains the name of the target variable that should be set with 
the test result. If you call check_influde_files(pthread.h PTHR) then 
${VARIABLE} will contains "PTHR".

Now if you have
   if ("${VARIABLE}" …
this will become 
  if (PTHR …

because of the explicit expansion. If the variable PTHR has already been set, 
then this will be implicitely expanded by CMake again. So, if PTHR contains 
TRUE, then this whole line would be finally expanded to
  if (TRUE MATCHES "^PTHR$")
which is false, so the block will not be executed again.

And now I wonder why the whole thing isn't turned into a function ;)

Eike
-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140430/1406efdc/attachment.sig>


More information about the CMake mailing list