PROJECT(NeL CXX C)

IF(WITH_STATIC_DRIVERS)
  ADD_DEFINITIONS(-DNL_STATIC)
ENDIF(WITH_STATIC_DRIVERS)

# On Windows we need to find DirectInput for NLMISC.
# This is how we get events.
IF(WIN32)
  FIND_PACKAGE(DirectXSDK REQUIRED)

  # On Win32 we can also build the MAX plugins.
  IF(WITH_NEL_MAXPLUGIN)
    FIND_PACKAGE(3dsMaxSDK)
  ENDIF(WITH_NEL_MAXPLUGIN)
ENDIF(WIN32)

IF(WITH_3D)
  FIND_PACKAGE(FreeType)

  IF(WITH_NEL_CEGUI)
    FIND_PACKAGE(CEGUI)
  ENDIF(WITH_NEL_CEGUI)

ENDIF(WITH_3D)

IF(WITH_SOUND)
  FIND_PACKAGE(Ogg)
  FIND_PACKAGE(Vorbis)

  IF(WITH_DRIVER_OPENAL)
    FIND_PACKAGE(OpenAL)
  ENDIF(WITH_DRIVER_OPENAL)

  IF(WITH_DRIVER_FMOD)
    FIND_PACKAGE(FMOD)
  ENDIF(WITH_DRIVER_FMOD)
ENDIF(WITH_SOUND)

IF(WITH_GTK)
  FIND_PACKAGE(GTK2)
ENDIF(WITH_GTK)

IF(WITH_LIBOVR)
  FIND_PACKAGE(LibOVR)
ENDIF(WITH_LIBOVR)

IF(WITH_LIBVR)
  FIND_PACKAGE(LibVR)
ENDIF(WITH_LIBVR)

IF(WITH_INSTALL_LIBRARIES)
  IF(UNIX)
    SET(prefix ${CMAKE_INSTALL_PREFIX})
    SET(exec_prefix ${NL_BIN_ABSOLUTE_PREFIX})
    SET(libdir ${NL_LIB_ABSOLUTE_PREFIX})
    SET(includedir ${CMAKE_INSTALL_PREFIX}/include)
    SET(enable_ligo ${WITH_LIGO})
    SET(enable_logic ${WITH_LOGIC})
    SET(enable_georges ${WITH_GEORGES})
    SET(enable_net ${WITH_NET})
    SET(enable_3d ${WITH_3D})
    SET(enable_pacs ${WITH_PACS})
    SET(enable_sound ${WITH_SOUND})
    CONFIGURE_FILE(nel-config.in ${CMAKE_CURRENT_BINARY_DIR}/nel-config)

    INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/nel-config DESTINATION ${NL_BIN_PREFIX})
  ENDIF(UNIX)

  ADD_SUBDIRECTORY(include)
ENDIF(WITH_INSTALL_LIBRARIES)

ADD_SUBDIRECTORY(src)

IF(WITH_NEL_SAMPLES)
  ADD_SUBDIRECTORY(samples)
ENDIF(WITH_NEL_SAMPLES)

# Allow to compile only max plugins without other tools.
IF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN)
  IF(WITH_NEL_TOOLS)
    FIND_PACKAGE(Squish)
  ENDIF(WITH_NEL_TOOLS)
  ADD_SUBDIRECTORY(tools)
ENDIF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN)