[CMake] CHECK_INCLUDE_FILES

Bill Hoffman bill.hoffman at kitware.com
Thu Jul 31 15:32:02 EDT 2008


George Neill wrote:
> Bill,
> 
>> I must be missing something (or there's a bug in CheckIncludeFiles.cmake)
>>
>> CHECK_INCLUDE_FILES(sys/types.h;netinet/tcp.h HAVE_NETINET_TCP_H)
>> SET(HAVE_NETINET_TCP_H ${HAVE_NETINET_TCP_H} CACHE INTERNAL "netinet/tcp.h")
>> .
>> .
>> .
>> -- Looking for include files netinet/tcp.h
>> -- Looking for include files netinet/tcp.h - found
>> -- Looking for include files HAVE_SYS_SYSTEMINFO_H
>> -- Looking for include files HAVE_SYS_SYSTEMINFO_H - found
>>
>> I have tried
>>
>> CHECK_INCLUDE_FILES(sys/types.h;netinet/tcp.h HAVE_NETINET_TCP_H)
>>
>> and
>>
>> LIST(APPEND NETINET sys/types.h netinet/tcp.h)
>> CHECK_INCLUDE_FILES(${NETINET} HAVE_NETINET_TCP_H)
>>
>> and
>>
>> LIST(APPEND NETINET sys/types.h)
>> LIST(APPEND NETINET netinet/tcp.h)
>> CHECK_INCLUDE_FILES(${NETINET} HAVE_NETINET_TCP_H)
>>
>> all three of these provide the same results as above (I am using 2.4.8)
> 
> I am tempted to write a macro with an interface like this,
> 
> CHECK_INCLUDES( FILES sys/types.h netinet.h VARIABLE HAVE_NETINET_TCP_H)
> 
> I suspect that might be better (for me anyhow) ... Thoughts?   it
> looks like the list passed in to check_include_files is getting
> exploded in to three arguments.
> 

You have to use double quotes.

 From CMake/Utilities/cmcurl/CMakeLists.txt:

MACRO(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE)
   CHECK_INCLUDE_FILES("${CURL_INCLUDES};${FILE}" ${VARIABLE})
   IF(${VARIABLE})
     SET(CURL_INCLUDES ${CURL_INCLUDES} ${FILE})
   ENDIF(${VARIABLE})
ENDMACRO(CHECK_INCLUDE_FILE_CONCAT)

So, this would work:

CHECK_INCLUDE_FILES("sys/types.h;netinet/tcp.h" HAVE_NETINET_TCP_H)

-Bill

-- 
Bill Hoffman
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065
bill.hoffman at kitware.com
http://www.kitware.com
518-371-3971 (phone and fax)


More information about the CMake mailing list