[Cmake] Empty include and library variables

Chris Scharver scharver at evl . uic . edu
Mon, 20 Oct 2003 12:27:04 -0500


Hello,

I am trying to conditionally include a certain set of files. I have an OPTION to indicate whether the user needs to set include and library variables. If the option is on, set the variables, otherwise clear them. My current approach doesn't work (CMake 1.8-1 with MSVC6):

OPTION(USE_COIN_EVENTS "Use custom event library." OFF)
IF (USE_COIN_EVENTS)
  FIND_PATH( COINEVENTS_INCLUDE_DIR SbTrackerInfo.h ../coinevents
    DOC "Location for the SbTrackerInfo header.")
  FIND_LIBRARY( COINEVENTS_LIBRARY coinevents ${COINEVENTS_INCLUDE_DIR})
ELSE (USE_COIN_EVENTS)
  SET(COINEVENTS_INCLUDE_DIR " " STRING FORCE)
  SET(COINEVENTS_LIBRARY " " STRING FORCE)
ENDIF (USE_COIN_EVENTS)

INCLUDE_DIRECTORIES(
  ${MEDSLICE_SOURCE_DIR}
  ${CAVE_INCLUDE_DIR}
  ${INVENTOR_INCLUDE_DIR}
  ${COINEVENTS_INCLUDE_DIR}
  ${OPENGL_INCLUDE_DIR}
)

...

TARGET_LINK_LIBRARIES (medslice
  ${CAVE_LIBRARIES}
  ${INVENTOR_LIBRARIES}
  ${COINEVENTS_LIBRARY}
  ${OPENGL_LIBRARIES}
)

Am I just trying to make things too simple? The idea is that if USE_COIN_EVENTS is off, the variables will contain empty strings, and thus will not be included in the include or library build settings. However, when configuring to build with MSVC6, I get an error that " .lib" cannot be opened for linking. Or do I need to create the variables lists separately? It seems like CMake should detect an empty value and not try to append a new library or include entry.

This event library is conditional on the Inventor library being used, so maybe I should add some other variable that indicates the specific Inventor library type (eg. Coin3D, TGS, SGI) rather than try to control its inclusion manually.

Chris
--
Chris Scharver
Electronic Visualization Laboratory
The University of Illinois at Chicago
Ph: 312-996-3002   FAX: 312-413-7585
<http://www . evl . uic . edu/scharver/>