[CMake] CHECK_INCLUDE_FILES

George Neill georgen at neillnet.com
Thu Jul 31 15:17:06 EDT 2008


Bill,

On Thu, Jul 31, 2008 at 10:20 AM, Bill Hoffman <bill.hoffman at kitware.com> wrote:
> George Neill wrote:
>>
>> Bill,
>>
>>>> I have ran into a problem on Solaris (v10/SS12) with
>>>> CHECK_INCLUDE_FILES.  I believe this is actually a bug in the header
>>>> file I am checking for but none-the-less it's a problem for me.  I am
>>>> using cmake 2.4.8.
>>>>
>>>> CHECK_INCLUDE_FILES(netinet/tcp.h HAVE_NETINET_TCP_H)
>>>>
>>>> here's a quick test program i wrote to mock up what
>>>> CHECK_INCLUDE_FILES() is doing ...
>>>>
>>>> -bash-3.00$ cat test.c
>>>> #include <netinet/tcp.h>
>>>>
>>>> int main()
>>>> {
>>>> return 0;
>>>> }
>>>>
>>>> Here's the compiler results,
>>>>
>>>> -bash-3.00$ cc test.c
>>>> "/usr/include/netinet/tcp.h", line 40: syntax error before or at: uint_t
>>>> cc: acomp failed for test.c
>>>>
>>>>
>>>> It's obvious to me the netinet/tcp.h header file should have included
>>>> sys/types.h
>>>>
>>>> My question is, is there a way to solve this without creating my own
>>>> check_include_files macro()?
>>>
>>> set(CMAKE_REQUIRED_INCLUDES "sys/types.h")
>>> CHECK_INCLUDE_FILES(netinet/tcp.h HAVE_NETINET_TCP_H)
>>>
>>> ./bin/cmake --help-module CheckIncludeFiles
>>>    The following variables may be set before calling this macro to modify
>>>      the way the check is run:
>>>
>>>        CMAKE_REQUIRED_FLAGS = string of compile command line flags
>>>        CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
>>>        CMAKE_REQUIRED_INCLUDES = list of include directories
>>
>> Well crap, I saw CMAKE_REQUIRED_INCLUDES, but read it as a -I (include
>> directory) not a specific file to include.   I'll give that a try.
>>
>
> Opps, My bad...  You just need to pass it in...
>
> CHECK_INCLUDE_FILES(netinet/tcp.h;netinet/tcp.h HAVE_NETINET_TCP_H)

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)

TIA,
George.


More information about the CMake mailing list