PROJECT(UNICORN)

CMAKE_MINIMUM_REQUIRED(VERSION 2.4.0)
IF(COMMAND CMAKE_POLICY)
  CMAKE_POLICY(SET CMP0003 NEW)
ENDIF(COMMAND CMAKE_POLICY)

IF(APPLE)
  EXECUTE_PROCESS(
    COMMAND sw_vers -productVersion
    OUTPUT_VARIABLE OSX_VERSION
    OUTPUT_STRIP_TRAILING_WHITESPACE)
  MESSAGE(STATUS "OSX_VERSION='${OSX_VERSION}'")
  IF(${OSX_VERSION} MATCHES "^10\\.[012345]\\.?")
    MESSAGE(STATUS "OSX < 10.6")
  ELSE(${OSX_VERSION} MATCHES "^10\\.[012345]\\.?")
    SET(CMAKE_OSX_ARCHITECTURES "i386;ppc") # for QT4.5 32bits on snow leopard
  ENDIF(${OSX_VERSION} MATCHES "^10\\.[012345]\\.?")
ENDIF(APPLE)

SET(CMAKE_C_FLAGS_DEBUG             "-g -Wall" CACHE STRING "Debug options." FORCE)
SET(CMAKE_CXX_FLAGS_DEBUG           "-g -Wall" CACHE STRING "Debug options." FORCE)
#SET(CMAKE_LINKER_FLAGS_DEBUG        "-pg"          CACHE STRING "Debug options." FORCE)
#SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "-pg"          CACHE STRING "Debug options." FORCE)
#SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "-pg"          CACHE STRING "Debug options." FORCE)
#SET(CMAKE_EXE_LINKER_FLAGS_DEBUG    "-pg"          CACHE STRING "Debug options." FORCE)

IF(COMMAND CMAKE_POLICY)
  CMAKE_POLICY(SET CMP0003 NEW)
ENDIF(COMMAND CMAKE_POLICY)

# This macro has to be included in all the tools CMakeLists.txt as it's
# the sole means of localizing other tools/projects.
MACRO(SETUP_PROJECT_PATHS project)
  IF( NOT("$ENV{${project}_USER_TOP}" STREQUAL "") )
    MESSAGE("-- ${project}_USER_TOP is set to $ENV{${project}_USER_TOP}")
    SET(PROJECT_MODULE_PATH   "$ENV{${project}_USER_TOP}/share/cmake_modules/")
    LIST(FIND CMAKE_MODULE_PATH "${PROJECT_MODULE_PATH}" DIR_INDEX)
    IF( DIR_INDEX LESS 0)
      LIST(INSERT CMAKE_MODULE_PATH 0 "${PROJECT_MODULE_PATH}")
    ENDIF( DIR_INDEX LESS 0)
  ENDIF( NOT("$ENV{${project}_USER_TOP}" STREQUAL "") )
  
  IF( NOT("$ENV{${project}_TOP}" STREQUAL "") )
    MESSAGE("-- ${project}_TOP is set to $ENV{${project}_TOP}")
    SET(PROJECT_MODULE_PATH "$ENV{${project}_TOP}/share/cmake_modules/")
    LIST(FIND CMAKE_MODULE_PATH "${PROJECT_MODULE_PATH}" DIR_INDEX)
    IF( DIR_INDEX LESS 0)
      LIST(INSERT CMAKE_MODULE_PATH 0 "${PROJECT_MODULE_PATH}")
    ENDIF( DIR_INDEX LESS 0)
  ENDIF( NOT("$ENV{${project}_TOP}" STREQUAL "") )
ENDMACRO(SETUP_PROJECT_PATHS project)

SETUP_PROJECT_PATHS(IO)
SETUP_PROJECT_PATHS(CORIOLIS)

SET(QT_USE_QTXML "true")

FIND_PACKAGE(Boost 1.33.1 COMPONENTS program_options REQUIRED)
FIND_PACKAGE(Qt4 REQUIRED) # find and setup Qt4 for this project
FIND_PACKAGE(LEFDEF REQUIRED)
FIND_PACKAGE(IO REQUIRED)
FIND_PACKAGE(HURRICANE REQUIRED)
FIND_PACKAGE(CORIOLIS REQUIRED)
FIND_PACKAGE(KNIK REQUIRED)
FIND_PACKAGE(KATABATIC REQUIRED)
FIND_PACKAGE(KITE REQUIRED)
#FIND_PACKAGE(EQUINOX REQUIRED)
#FIND_PACKAGE(SOLSTICE REQUIRED)

SET_LIB_LINK_MODE()

ADD_SUBDIRECTORY(src)
