[Cmake] Comments, questions from my first CMake'd app
Amitha Perera
perera at cs.rpi.edu
Tue Mar 18 18:03:04 EST 2003
On Tue 18 Mar 2003, Ian Main wrote:
> I had a few little problems with some things. The return from
>
> INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
> CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
>
> will set HAVE_SYS_TYPES_H to 1 if it exists, or nothing if it
> does not. This makes it hard to use in a config.h.in style
> arrangement, as you have to do funky #if stuff. I am
> currently using:
>
> #if 0 at HAVE_SYS_TYPES_H@
> #define HAVE_SYS_TYPES_H 1
> #endif
>
> which will make the first line '#if 0' or '#if 01' depending
> on the result. This works but it's a bit hackish. Note that
> you can't just do:
>
> #define HAVE_SYS_TYPES_H @HAVE_SYS_TYPES_H@ because then when
> you test for it you have to use #if still, and you end up
> with the same problem.
I think you can use #ifdef and #ifndef instead of the #if. Also, I'm
reasonably sure that
#if ABC
do abc
#else
do def
#endif
should do def if ABC is not a preprocessor macro (i.e., if it is not
#define'd). However, my experience is from the C++ preprocessor, and
this may somehow be subtly different from the C preprocessor.
The advantage of set to 1 or nothing is that you can both #if or
#ifdef will work.
Cheers,
Amitha.
More information about the CMake
mailing list