project(SpliceHunter CXX)
cmake_minimum_required (VERSION 2.8.2)

if(NOT DEFINED SEQAN_INCLUDE_PATH)
message( FATAL_ERROR "ERROR: \${SEQAN_INCLUDE_PATH} variable is not defined. Please define it.")    
endif(NOT DEFINED SEQAN_INCLUDE_PATH)

if(NOT DEFINED CMAKE_SEQAN_MODULE_PATH)
get_filename_component(seqanParent ${SEQAN_INCLUDE_PATH} PATH)
set(CMAKE_SEQAN_MODULE_PATH "${seqanParent}/util/cmake")
message(STATUS "\${CMAKE_SEQAN_MODULE_PATH} variable not defined. Assuming FindSeqan.cmake to be located at: ${CMAKE_SEQAN_MODULE_PATH}")
endif(NOT DEFINED CMAKE_SEQAN_MODULE_PATH)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SEQAN_MODULE_PATH} "${CMAKE_HOME_DIRECTORY}/cmake/Modules/")

set(local_dir ${CMAKE_HOME_DIRECTORY})

# set this here otherwise seqan find module will complain    
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set (SEQAN_FIND_DEPENDENCIES ZLIB BZip2)
find_package (SeqAn REQUIRED)

if (NOT ${SEQAN_HAS_ZLIB})
message(FATAL_ERROR "MISSING ZLIB")
endif(NOT ${SEQAN_HAS_ZLIB})

if (NOT ${SEQAN_HAS_BZip2})
message(FATAL_ERROR "MISSING ZLIB")
endif(NOT ${SEQAN_HAS_BZip2})

# Add flags for SeqAn (and its dependencies).
add_definitions (${SEQAN_DEFINITIONS})

find_package(Boost 1.36 COMPONENTS program_options REQUIRED)

if(NOT DEFINED BAMTOOLS_ROOT)
message( FATAL_ERROR "ERROR: \${BAMTOOLS_ROOT} variable is not defined. Please define it.")    
endif(NOT DEFINED BAMTOOLS_ROOT)

include_directories(
"${local_dir}/include/"
${SEQAN_INCLUDE_DIRS}
${Boost_INCLUDE_DIR}
"${BAMTOOLS_ROOT}/include/"
)

link_directories("${BAMTOOLS_ROOT}/lib")

set(header_files
    ./include/FastaReader.h
    ./include/GtfReader.h
    ./include/NamedDnaSequence.h
    ./include/NovelTrans.h
    ./include/PacBioBamReader.h
)

set(sources
    source/NamedDnaSequence.cpp
    source/PacBioBamReader.cpp
    source/Parameters.cpp
    source/NovelTrans.cpp
    source/GtfReader.cpp
    ${header_files}
    )

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "./bin")

#set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE Release)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fexceptions -DIL_STD -Wall -Wextra -Wno-variadic-macros -pedantic")

add_executable(SpliceHunter ./source/novel.cpp ${sources})

link_directories("${BAMTOOLS_ROOT}/lib")
target_link_libraries(SpliceHunter bamtools ${Boost_LIBRARIES} ${SEQAN_LIBRARIES} "-lm -pthread")

#### end
