[CMake] Is there a way to group tests without polluting the cache?

Brad King brad.king at kitware.com
Mon Jul 31 13:46:16 EDT 2006


Alan W. Irwin wrote:
> I am in the process of emulating the autotools STDC_HEADERS macro which
> does
> the following:
> 
> # Specifically, this macro checks for stdlib.h', stdarg.h',
> # string.h', and float.h'; if the system has those, it probably
> # has the rest of the ANSI C header files.  This macro also checks
> # whether string.h' declares memchr' (and thus presumably the
> # other mem' functions), whether stdlib.h' declare free' (and
> # thus presumably malloc' and other related functions), and whether
> # the ctype.h' macros work on characters with the high bit set, as
> # ANSI C requires.
> 
> I want to store the result of the tests in one cached variable,
> STDC_HEADERS.  So far, I am using CHECK_INCLUDE_FILES, and a couple of
> instances of CHECK_PROTOTYPE_EXISTS (taken from the KDE
> CheckPrototypeExists.cmake since apparently cmake does not have this module
> yet).  Is there a way to re-use STDC_HEADERS for these different tests
> or do
> I have to pollute the cache with a bunch of different variables
> (STDC_HEADERS1, STDC_HEADERS2,....) from all the required tests and store
> the AND of them as STDC_HEADERS?

You don't actually have to use the CMake-provided macros to do the tests
one at a time.  You could call TRY_COMPILE directly and provide your own
source file that includes all four headers.  You could also use the
CHECK_C_SOURCE_COMPILES macro.

-Brad


More information about the CMake mailing list