[CMake] ADD_DEFINITIONS safety

Brandon J. Van Every bvanevery at gmail.com
Tue Jun 6 19:44:15 EDT 2006


I erroneously had this code:

  CHECK_INCLUDE_FILE(winsock2.h HAVE_WINSOCK2_H)
  IF(HAVE_WINSOCK2_H)
    ADD_DEFINITIONS(HAVE_WINSOCK2_H)
  ENDIF(HAVE_WINSOCK2_H)

and of course CMakeSetup took it just fine because it thought I knew 
what I was doing.  When 'make' got around to .c compilation, gcc spewed 
a whole slew of really bizarre errors about HAVE_WINSOCK2_H not being a 
valid file.  Of course I should have used a -D

  CHECK_INCLUDE_FILE(winsock2.h HAVE_WINSOCK2_H)
  IF(HAVE_WINSOCK2_H)
    ADD_DEFINITIONS(-DHAVE_WINSOCK2_H)
  ENDIF(HAVE_WINSOCK2_H)

but it makes me think, if the purpose of the function is to add 
definitions, why not check whether those definitions are vaguely well 
formed?  Would it be difficult?  I mean, for any given generator, we 
know what -D or /D flags it takes.


Cheers,
Brandon Van Every




More information about the CMake mailing list