[CMake] Help with libintl/configure tests

Bill Hoffman bill.hoffman at kitware.com
Fri Apr 25 08:40:06 EDT 2008


Tim Holy wrote:
> Hi Bill,
> 
> OK, I think I understand better. The whole problem can be illustrated with 
> this simple CMakeLists.txt file:
> 
> include(CheckTypeSize)
> include(CheckIncludeFile)
> 
> # Block_begin
> check_include_file(sys/types.h HAVE_SYS_TYPES_H)
> check_include_file(stdint.h HAVE_STDINT_H)
> check_include_file(stddef.h HAVE_STDDEF_H)
> # Block_end
> 
> check_include_file(inttypes.h HAVE_INTTYPES_H)
> check_type_size(intmax_t INTMAX_T)
> message("HIT ${HAVE_INTMAX_T}, IT ${INTMAX_T}")
> 
...
> Thanks for the tips; just as you suggested, I figured it out by looking at the 
> CheckSymbolExists.c file. I don't understand _why_ it fails sporadically, but 
> at least I know how to keep it from doing so.
> 
> Would it be sensible to have CMake issue a warning in case you're compiling a 
> test for which a #define variable has not been set?
> 

OK, I get it now...

The checktypesize.c file has this code in it:

#ifdef HAVE_SYS_TYPES_H
#  include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */

#ifdef HAVE_STDINT_H
#  include <stdint.h>
#endif /* HAVE_STDINT_H */

#ifdef HAVE_STDDEF_H
#  include <stddef.h>
#endif /* HAVE_STDDEF_H */

So, I see a few solutions:

1. call these directly in check_type_size:
  check_include_file(sys/types.h HAVE_SYS_TYPES_H)
  check_include_file(stdint.h HAVE_STDINT_H)
  check_include_file(stddef.h HAVE_STDDEF_H)

2. Update the documentation for check_type_size to tell people that they 
need those checks.

3. Try to see if those have been called and issue a warning if they have 
not.


I am thinking 1 is the best solution and will avoid confusion.  I don't 
think it will hurt because duplicate calls will be ignored (the test 
won't be done multiple times unless a different variable name is used, 
but in that case the check type size will not have worked anyway.

-Bill


More information about the CMake mailing list