PROJECT(VITE CXX C)

CMAKE_MINIMUM_REQUIRED(VERSION 2.4)

IF(COMMAND CMAKE_POLICY)
  # CMP0003: add the link paths to the link command as with cmake 2.4
  CMAKE_POLICY(SET CMP0003 NEW)
ENDIF(COMMAND CMAKE_POLICY)

# A virer
FIND_PACKAGE(Qt4
   COMPONENTS QtCore QtGui REQUIRED)
INCLUDE(${QT_USE_FILE})

SET(SRC_DIR ../../src)
# Files needed by all the tests
SET(ALL_HDRS 
  trace/Trace.hpp
  trace/Container.hpp
  trace/ContainerType.hpp
  trace/Entity.hpp
  trace/EntityType.hpp
  trace/EntityValue.hpp
  trace/Event.hpp
  trace/EventType.hpp
  trace/State.hpp
  trace/StateChange.hpp
  trace/StateType.hpp
  trace/Link.hpp
  trace/LinkType.hpp
  trace/Variable.hpp
  trace/VariableType.hpp
  trace/values/Color.hpp
  trace/values/Date.hpp
  trace/values/Double.hpp
  trace/values/Hex.hpp
  trace/values/Integer.hpp
  trace/values/Name.hpp
  trace/values/String.hpp
  trace/values/Value.hpp
  trace/values/Values.hpp
  common/Tools.hpp
  common/Info.hpp
  common/Errors.hpp
  common/Memory.hpp
  common/Message.hpp
  common/Session.hpp             # A virer
  statistics/Statistic.hpp       # A virer
  parser/Parser.hpp
  render/Palette.hpp             # A virer
  )

SET(ALL_SRCS
  ${SRC_DIR}/trace/Trace.cpp
  ${SRC_DIR}/trace/Container.cpp
  ${SRC_DIR}/trace/ContainerType.cpp
  ${SRC_DIR}/trace/Entity.cpp
  ${SRC_DIR}/trace/EntityType.cpp
  ${SRC_DIR}/trace/EntityValue.cpp
  ${SRC_DIR}/trace/Event.cpp
  ${SRC_DIR}/trace/EventType.cpp
  ${SRC_DIR}/trace/State.cpp
  ${SRC_DIR}/trace/StateChange.cpp
  ${SRC_DIR}/trace/StateType.cpp
  ${SRC_DIR}/trace/Link.cpp
  ${SRC_DIR}/trace/LinkType.cpp
  ${SRC_DIR}/trace/Variable.cpp
  ${SRC_DIR}/trace/VariableType.cpp
  ${SRC_DIR}/trace/values/Color.cpp
  ${SRC_DIR}/trace/values/Date.cpp
  ${SRC_DIR}/trace/values/Double.cpp
  ${SRC_DIR}/trace/values/Hex.cpp
  ${SRC_DIR}/trace/values/Integer.cpp
  ${SRC_DIR}/trace/values/Name.cpp
  ${SRC_DIR}/trace/values/String.cpp
  ${SRC_DIR}/common/Tools.cpp
  ${SRC_DIR}/common/Info.cpp
  ${SRC_DIR}/common/Errors.cpp
  ${SRC_DIR}/common/Memory.cpp
  ${SRC_DIR}/common/Message.cpp
  ${SRC_DIR}/common/Session.cpp        # A virer
  ${SRC_DIR}/statistics/Statistic.cpp  # A virer
  ${SRC_DIR}/parser/Parser.cpp
  ${SRC_DIR}/render/Palette.cpp        # A virer
  )

# Specific Paje parser files
SET(PAJE_HDRS
  parser/PajeDefinition.hpp
  parser/ParserDefinitionPaje.hpp
  parser/ParserEventPaje.hpp
  parser/ParserPaje.hpp
  parser/PajeFileManager.hpp
  )
SET(PAJE_SRCS
  ${SRC_DIR}/parser/PajeDefinition.cpp
  ${SRC_DIR}/parser/ParserDefinitionPaje.cpp
  ${SRC_DIR}/parser/ParserEventPaje.cpp
  ${SRC_DIR}/parser/ParserPaje.cpp
  ${SRC_DIR}/parser/PajeFileManager.cpp
  )

# Specific ViTE parser files
SET(VITE_HDRS
  ${PAJE_HDRS}
  parser/ParserVite.hpp
  )
SET(VITE_SRCS
  ${PAJE_SRCS}
  ${SRC_DIR}/parser/ParserVite.cpp
  )

# Specific Tau parser files
OPTION(ENABLE_TAU "Enable the support of TAU file format." OFF)
IF(ENABLE_TAU)
  INCLUDE(../../cmake/FindTAU.cmake)
  ADD_DEFINITIONS(-DWITH_TAU)
  
  SET(TAU_HDRS
    parser/ParserTau.hpp
    parser/TauStructs.hpp
    ${TAU_INCLUDE_DIR}
    )
  SET(TAU_SRCS
    ${SRC_DIR}parser/ParserTau.cpp
    )
  
  ADD_EXECUTABLE(TimeMemoryTest_Tau TimeMemoryTest_Tau.cpp ${ALL_SRCS} ${TAU_SRCS})
  
  TARGET_LINK_LIBRARIES(TimeMemoryTest_Tau
    ${QT_LIBRARIES}
    ${TAU_LIBRARY}
    rt
    )
ENDIF(ENABLE_TAU)


# Specific OTF parser files
OPTION(ENABLE_OTF "Enable the support of OTF file format." OFF)
IF(ENABLE_OTF)
  INCLUDE(../../cmake/FindOTF.cmake)
  ADD_DEFINITIONS(-DWITH_OTF)

  SET(OTF_HDRS
    parser/ParserDefinitionOTF.hpp
    parser/ParserEventOTF.hpp
    parser/ParserOTF.hpp
    ${OTF_INCLUDE_DIR}
    )
  
  SET(OTF_SRCS
    ${SRC_DIR}/parser/ParserDefinitionOTF.cpp
    ${SRC_DIR}/parser/ParserEventOTF.cpp
    ${SRC_DIR}/parser/ParserOTF.cpp
    )
  
  ADD_EXECUTABLE(TimeMemoryTest_OTF TimeMemoryTest_OTF.cpp ${ALL_SRCS} ${OTF_SRCS})
  
  TARGET_LINK_LIBRARIES(TimeMemoryTest_OTF
    ${QT_LIBRARIES}
    ${OTF_LIBRARY}
    rt
    )

ENDIF(ENABLE_OTF)

INCLUDE_DIRECTORIES(${SRC_DIR})

ADD_DEFINITIONS(-DMEMORY_USAGE)
ADD_DEFINITIONS(-DMEMORY_TRACE)
ADD_DEFINITIONS(-DDBG_PARSER_PAJE)
ADD_DEFINITIONS(-DDBG_PARSER_VITE)
#ADD_DEFINITIONS(-DDBG_PARSER_OTF)
#ADD_DEFINITIONS(-DDBG_PARSER_TAU)
ADD_DEFINITIONS(-DWITHOUT_QT)
ADD_DEFINITIONS(-O0 -Wall -g3)

ADD_EXECUTABLE(TimeMemoryTest_Paje TimeMemoryTest_Paje.cpp ${ALL_SRCS} ${PAJE_SRCS})
ADD_EXECUTABLE(TimeMemoryTest_Vite TimeMemoryTest_Vite.cpp ${ALL_SRCS} ${VITE_SRCS})
ADD_EXECUTABLE(TestParsers TestParsers.cpp ${ALL_SRCS} ${PAJE_SRCS} ${VITE_SRCS} ${OTF_SRCS} ${TAU_SRCS})

TARGET_LINK_LIBRARIES(TimeMemoryTest_Paje
  ${QT_LIBRARIES}
  rt
  )

TARGET_LINK_LIBRARIES(TimeMemoryTest_Vite
  ${QT_LIBRARIES}
  rt
  )

TARGET_LINK_LIBRARIES(TestParsers
  ${QT_LIBRARIES}
  ${TAU_LIBRARY}
  ${OTF_LIBRARY}
  rt
  )
