#
# This file is part of the ViTE project.
#
# This software is governed by the CeCILL-A license under French law
# and abiding by the rules of distribution of free software. You can
# use, modify and/or redistribute the software under the terms of the
# CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
# URL: "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided
# only with a limited warranty and the software's author, the holder of
# the economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards
# their requirements in conditions enabling the security of their
# systems and/or data to be ensured and, more generally, to use and
# operate it in the same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL-A license and that you accept its terms.
#
# ViTE developers are (for version 0.* to 1.0):
#
#        - COULOMB Kevin
#        - FAVERGE Mathieu
#        - JAZEIX Johnny
#        - LAGRASSE Olivier
#        - MARCOUEILLE Jule
#        - NOISETTE Pascal
#        - REDONDY Arthur
#        - VUCHENER Clment
#        - (RICHART Nicolas)
#
#

SET(VITE_HDRS
  common/common.hpp
  common/Message.hpp
  common/Errors.hpp
  common/Tools.hpp
  common/info.hpp
  common/Session.hpp
  common/trace.h
  common/Memory.hpp
  # Data structure headers
  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
  trace/tree/BinaryTree.hpp
  trace/tree/Node.hpp
  trace/tree/Interval.hpp
  trace/ContainerType.hpp
  trace/EntityType.hpp
  trace/EventType.hpp
  trace/StateType.hpp
  trace/LinkType.hpp
  trace/VariableType.hpp
  trace/EntityTypes.hpp
  trace/EntityValue.hpp
  trace/Container.hpp
  trace/Entity.hpp
  trace/Event.hpp
  trace/State.hpp
  trace/StateChange.hpp
  trace/Link.hpp
  trace/Entitys.hpp
  trace/Variable.hpp
  trace/DrawTrace.hpp
  trace/DrawTree.hpp
  trace/Trace.hpp
  # Render headers
  render/Render.hpp
  render/Geometry.hpp
  render/Hook_event.hpp
  render/Render_opengl.hpp
  render/Render_svg.hpp
  render/render_stats.hpp
  render/render_stats_opengl.hpp
  render/render_stats_svg.hpp
  render/Ruler.hpp
  # Interface headers
  interface/resource.hpp
  interface/parsing_thread.hpp
  interface/Interface.hpp
  interface/Interface_graphic.hpp
  # Core header
  core/Core.hpp
  # Parser headers
  parser/Definition.hpp
  parser/Line.hpp
  parser/Parser.hpp
  parser/ParserDefinitionPaje.hpp
  parser/ParserEventPaje.hpp
  parser/ParserPaje.hpp
  parser/ParserVite.hpp
  parser/File.hpp
  # Statistics headers
  statistics/Stats_window.hpp
  statistics/Statistic.hpp
  statistics/DrawStats.hpp
  statistics/DrawVDiagram.hpp
  statistics/DrawHDiagram.hpp
  statistics/DrawCounter.hpp
  # Plugin header
  plugin/Command_window.hpp
)

SET(VITE_UIS
  interface/info_window.ui
  interface/main_window.ui
  interface/option_export_window.ui
  interface/stats_viewer.ui
  interface/global_cmd.ui
  interface/list_of_counter_to_export.ui
)

SET(VITE_SRCS
  # Messages & Errors 
  common/Message.cpp
  common/Errors.cpp
  common/Tools.cpp
  common/info.cpp
  common/Session.cpp
  common/Memory.cpp
  # Data structure code files
  trace/values/Color.cpp
  trace/values/Date.cpp
  trace/values/Double.cpp
  trace/values/Hex.cpp
  trace/values/Integer.cpp
  trace/values/Name.cpp
  trace/values/String.cpp
  trace/tree/Interval.cpp
  trace/EntityValue.cpp
  trace/ContainerType.cpp
  trace/EntityType.cpp
  trace/EventType.cpp
  trace/StateType.cpp
  trace/LinkType.cpp
  trace/VariableType.cpp
  trace/Entity.cpp
  trace/Event.cpp
  trace/State.cpp
  trace/StateChange.cpp
  trace/Link.cpp
  trace/Variable.cpp
  trace/Container.cpp
  trace/Trace.cpp
  # Render code files
  render/Geometry.cpp
  render/Hook_event.cpp
  render/Render.hpp
  render/Render_opengl.cpp
  render/Render_svg.cpp
  render/render_stats_opengl.cpp
  render/render_stats_svg.cpp
  render/Ruler.cpp

  # Parser code files
  parser/Definition.cpp
  parser/Line.cpp
  parser/File.cpp
  parser/ParserDefinitionPaje.cpp
  parser/ParserEventPaje.cpp
  parser/ParserPaje.cpp
  parser/ParserVite.cpp
  # Statistics code files
  statistics/Statistic.cpp
  statistics/Stats_window.cpp
  # Interface code files
  interface/parsing_thread.cpp
  interface/Interface_graphic.cpp
  # Plugin code file
  plugin/Command_window.cpp
  # Core code files
  core/Core.cpp
  # Main
  main.cpp
  )

SET(VITE_RCCS
  interface/vite.qrc
  )

IF(VITE_ENABLE_VBO)
  ADD_DEFINITIONS(-DWITH_VBO)

  SET(VITE_HDRS
    ${VITE_HDRS}
    render/vbo.hpp
    render/Render_alternate.hpp
    )

  SET(VITE_SRCS
    ${VITE_SRCS}
    render/vbo.cpp
    render/Render_alternate.cpp
    )  
ENDIF(VITE_ENABLE_VBO)



IF(VITE_ENABLE_OTF)
  ADD_DEFINITIONS(-DWITH_OTF)

  SET(VITE_HDRS
    ${VITE_HDRS}
    parser/ParserDefinitionOTF.hpp
    parser/ParserEventOTF.hpp
    parser/ParserOTF.hpp
    )

  SET(VITE_SRCS
    ${VITE_SRCS}
    parser/ParserDefinitionOTF.cpp
    parser/ParserEventOTF.cpp
    parser/ParserOTF.cpp
    )

  INCLUDE_DIRECTORIES(${OTF_INCLUDE_DIR})

ENDIF(VITE_ENABLE_OTF)

# ADD_DEFINITIONS(-DMEMORY_USAGE -DMEMORY_TRACE)

QT4_AUTOMOC(${VITE_SRCS})
FOREACH(_hdrs_file ${VITE_HDRS})
  GET_FILENAME_COMPONENT(_abs_file ${_hdrs_file} ABSOLUTE)
  FILE(READ ${_abs_file} _contents)
  STRING(REGEX MATCHALL "Q_OBJECT" _match "${_contents}")
  IF(_match)
    SET(VITE_MOC_HDRS ${VITE_MOC_HDRS} ${_hdrs_file})
  ENDIF(_match)
ENDFOREACH(_hdrs_file ${VITE_HDRS})

QT4_WRAP_UI(VITE_UIS_H ${VITE_UIS})
QT4_WRAP_CPP(VITE_MOC ${VITE_UIS_H} ${VITE_MOC_HDRS})
QT4_ADD_RESOURCES(VITE_RCC_SRCS ${VITE_RCCS})

ADD_DEFINITIONS(-DQT_NO_DEBUG)

INCLUDE_DIRECTORIES(
  ${CMAKE_CURRENT_BINARY_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}
)

ADD_EXECUTABLE(vite ${VITE_SRCS} ${VITE_MOC} ${VITE_RCC_SRCS})
TARGET_LINK_LIBRARIES(vite
  ${QT_LIBRARIES}
#  ${GLUT_LIBRARIES}
  )

IF(VITE_ENABLE_VBO)
  TARGET_LINK_LIBRARIES(vite
    ${GLEW_LIBRARY}
    )
ENDIF(VITE_ENABLE_VBO)

IF(VITE_ENABLE_OTF)
  TARGET_LINK_LIBRARIES(vite
    ${OTF_LIBRARY}
    )
ENDIF(VITE_ENABLE_OTF)

INSTALL_TARGETS(/bin vite)
