
CMAKE_MINIMUM_REQUIRED (VERSION 2.8)

PROJECT (EGAMMA CXX)

# Declare semantic versioning for FILVAL
SET(FILVAL_VERSION_MAJOR 0)
SET(FILVAL_VERSION_MINOR 1)
SET(FILVAL_VERSION_PATCH 0)
SET(CMAKE_BUILD_TYPE "Release")

CONFIGURE_FILE (
  "${PROJECT_SOURCE_DIR}/filval/filval.hpp"
  "${PROJECT_BINARY_DIR}/filval/filval.hpp"
  )


SET( EGAMMA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
SET( EGAMMA_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )

# Setup clang as the project compiler
SET (CMAKE_CXX_COMPILER             "/usr/bin/clang++")
SET (CMAKE_CXX_FLAGS                "-Wall")
SET (CMAKE_CXX_FLAGS_DEBUG          "-g")
SET (CMAKE_CXX_FLAGS_MINSIZEREL     "-Os -DNDEBUG")
SET (CMAKE_CXX_FLAGS_RELEASE        "-Ofast -DNDEBUG")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")

SET (CMAKE_AR      "/usr/bin/llvm-ar")
SET (CMAKE_LINKER  "/usr/bin/llvm-ld")
SET (CMAKE_NM      "/usr/bin/llvm-nm")
SET (CMAKE_OBJDUMP "/usr/bin/llvm-objdump")
SET (CMAKE_RANLIB  "/usr/bin/llvm-ranlib")

LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake )

FIND_PACKAGE(Jupyter)
IF(NBCONVERT_FOUND)
    ADD_CUSTOM_TARGET(notebook-docs
        ${CMAKE_CURRENT_SOURCE_DIR}/cmake/convert_nb ${NBCONVERT_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen_site
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
        COMMENT "Converting Jupyter Notebooks to HTML" VERBATIM
    )

    ADD_CUSTOM_TARGET(notebooks
        ${CMAKE_CURRENT_SOURCE_DIR}/cmake/convert_nb ${NBCONVERT_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen_site --update
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
        COMMENT "Re-Running notebooks and converting to HTML" VERBATIM
    )
ENDIF(NBCONVERT_FOUND)

FIND_PACKAGE(ROOT REQUIRED)
INCLUDE_DIRECTORIES( SYSTEM ${ROOT_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})

# Adds the dictionary library for addiitonal type serialization
SET( CLINGDICTFILE ${CMAKE_CURRENT_BINARY_DIR}/clingdict.cpp )
ROOT_GENERATE_DICTIONARY( "" ${CMAKE_CURRENT_SOURCE_DIR}/filval/root/LinkDef.hpp ${CLINGDICTFILE} "" )
ADD_LIBRARY( filval SHARED ${CLINGDICTFILE} )

# Compiles main analysis routine
ADD_EXECUTABLE(tracking_validation ${CMAKE_CURRENT_SOURCE_DIR}/analysis/tracking_validation.cpp)
TARGET_LINK_LIBRARIES( tracking_validation filval ${ROOT_LIBRARIES} )

