# CMake script for xtpcpp
# Author: Olivier Langella
# Created: 03/03/2015


SET(xtpcpp_RCCS xtpcpp.qrc)
# Appeler automatique le moc quand nécessaire
#SET(CMAKE_AUTOMOC ON)
# Les fichiers générés par le moc sont générés dans le dossier bin, dire à CMake de toujours 	
# inclure les entêtes de ce dossier
#SET(CMAKE_INCLUDE_CURRENT_DIR ON)


find_package( Qt5 COMPONENTS Core Gui Svg Xml PrintSupport Sql Network Concurrent REQUIRED )
qt5_add_resources(xtpcpp_RCC_SRCS ${xtpcpp_RCCS})

if(QCustomPlot_FOUND)
    MESSAGE("QCustomPlot_INCLUDES found ${QCustomPlot_INCLUDES}")
else(QCustomPlot_FOUND)
    FIND_PACKAGE( QCustomPlot REQUIRED )
endif(QCustomPlot_FOUND)


#sudo apt-get install libpappsomspp-dev

if(PappsoMSpp_FOUND)
else(PappsoMSpp_FOUND)
  message("PAPPSOms++ library not found")
  message("did you apt-get install libpappsomspp-dev ?")
endif(PappsoMSpp_FOUND)

if(PappsoMSppWidget_FOUND)
else(PappsoMSppWidget_FOUND)
  message("PAPPSOms++ widget library not found")
  message("did you apt-get install libpappsomspp-widget-dev ?")
endif(PappsoMSppWidget_FOUND)

message("PAPPSOms++ library : ${PappsoMSpp_LIBRARY}")

configure_file(${CMAKE_SOURCE_DIR}/src/config.h.cmake ${CMAKE_SOURCE_DIR}/src/config.h)

# File list
set(CPP_FILES
  core/automaticfilterparameters.cpp
  core/condor_process/condorprocess.cpp
  core/condor_process/condorqxmlsaxhandler.cpp
  core/identificationgroup.cpp
  core/identification_sources/identificationdatasource.cpp
  core/identification_sources/identificationmascotdatfile.cpp
  core/identification_sources/identificationpepxmlfile.cpp
  core/identification_sources/identificationpwizfile.cpp
  core/identification_sources/identificationxtandemfile.cpp
  core/labeling/label.cpp
  core/labeling/labelingmethod.cpp
  core/masschroq_run/masschroqbatchprocess.cpp
  core/masschroq_run/masschroqcondorprocess.cpp
  core/qvalue/computeqvalues.cpp
  core/tandem_run/tandembatchprocess.cpp
  core/tandem_run/tandemcondorprocess.cpp
  core/tandem_run/tandemparameters.cpp
  core/alignmentgroup.cpp
  core/msrun.cpp
  core/peptideevidence.cpp
  core/peptidematch.cpp
  core/peptidextp.cpp
  core/project.cpp
  core/proteinmatch.cpp
  core/proteinxtp.cpp
  core/sequencedatabase.cpp
  files/fastafile.cpp
  files/tandemparametersfile.cpp
  files/xpipfile.cpp
  grouping/groupingexperiment.cpp
  grouping/ptm/ptmacetylation.cpp
  grouping/ptm/ptminterface.cpp
  grouping/groupinggroup.cpp
  grouping/groupingpeptidemass.cpp
  grouping/ptm/ptmgroupingexperiment.cpp
  grouping/ptm/ptmisland.cpp
  grouping/ptm/ptmislandgroup.cpp
  grouping/ptm/ptmislandsubgroup.cpp
  grouping/ptm/ptmphospho.cpp
  grouping/ptm/ptmsamplescan.cpp
  input/mascot/mascotdatparser.cpp
  input/mascot/mimeparser.cpp
#  input/identificationpwizreader.cpp
  input/pepxmlsaxhandler.cpp
  input/xpipsaxhandler.cpp
  input/xtandemparamsaxhandler.cpp
  input/xtandemsaxhandler.cpp
  input/xtpxpipsaxhandler.cpp
  output/mcqr/mcqrscprotein.cpp
  output/mcqr/mcqrscpeptide.cpp
  output/ods/mass_delta/validmassdeltasheet.cpp
  output/ods/mass_delta/notvalidmassdeltasheet.cpp
  output/ods/ptm/ptmislandsheet.cpp
  output/ods/ptm/ptmspectrasheet.cpp
  output/ods/comparbasesheet.cpp
  output/ods/comparspecificspectrasheet.cpp
  output/ods/comparspectrabypeptide.cpp
  output/ods/comparspectrasheet.cpp
  output/ods/groupingsheet.cpp
  output/ods/infosheet.cpp
  output/ods/odsexport.cpp
  output/ods/peptidepossheet.cpp
  output/ods/peptidesheet.cpp
  output/ods/proteinsheet.cpp
  output/ods/qvaluessheet.cpp
  output/ods/samplesheet.cpp
  output/ods/simplesheet.cpp
  output/ods/spectrasheet.cpp
  output/ods/spectrasheetall.cpp
  output/ods/xicareasheet.cpp
  output/ods/xicinfosheet.cpp
  output/exportfastafile.cpp
  output/masschroqml.cpp
  output/masschroqprm.cpp
  output/mcqrspectralcount.cpp
  output/proticdbml.cpp
  output/xpip.cpp
  utils/fastafilestore.cpp
  utils/identificationdatasourcestore.cpp
  utils/groupstore.cpp
  utils/httpversion.cpp
  utils/msrunstatisticshandler.cpp
  utils/msrunstore.cpp
  utils/peptideevidencestore.cpp
  utils/peptidestore.cpp
  utils/proteinstore.cpp
  utils/ptmbuilder.cpp
  utils/utils.cpp
)

# we need this to be able to include headers produced by uic in our code
#(CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake)

set(XTPCPP_SRCS
  ./gui/about_dialog/aboutdialog.cpp
  ./gui/choose_modification_dialog/choosemodificationdialog.cpp
  ./gui/edit/edit_label_methods/editlabelmethods.cpp
  ./gui/edit/edit_modifications/editmodifications.cpp
  ./gui/edit/edit_settings/editsettings.cpp
  ./gui/edit/edit_tandem_preset_dialog/edittandempresetdialog.cpp
  ./gui/export/export_spreadsheet_dialog/exportspreadsheetdialog.cpp
  ./gui/load_results_dialog/loadresultsdialog.cpp
  ./gui/lists/ms_identification_run_list_view/msidentificationlistwindow.cpp
  ./gui/lists/ms_identification_run_list_view/msidentificationtablemodel.cpp
  ./gui/lists/ms_identification_run_list_view/msidentificationtableproxymodel.cpp
  ./gui/lists/ms_identification_run_list_view/ms_identification_worker/msidlistworkerstatus.cpp
  ./gui/lists/ms_identification_run_list_view/engine_detail_view/enginedetailwindow.cpp
  ./gui/masschroq_run_dialog/masschroqrundialog.cpp
  ./gui/masschroq_run_dialog/masschroqfileparameters.cpp
  ./gui/mainwindow.cpp
  ./gui/peptide_detail_view/peptidewindow.cpp
  ./gui/peptide_list_view/peptidelistwindow.cpp
  ./gui/peptide_list_view/peptidetablemodel.cpp
  ./gui/peptide_list_view/peptidetableproxymodel.cpp
  ./gui/project_view/identification_group_widget/identificationgroupwidget.cpp
  ./gui/project_view/projectwindow.cpp
  ./gui/protein_view/proteinwindow.cpp
  ./gui/protein_list_view/proteinlistwindow.cpp
  ./gui/protein_list_view/proteintablemodel.cpp
  ./gui/protein_list_view/proteintableproxymodel.cpp
  ./gui/ptm_island_list_view/ptmislandlistwindow.cpp
  ./gui/ptm_island_list_view/ptmislandtablemodel.cpp
  ./gui/ptm_island_list_view/ptmislandproxymodel.cpp
  ./gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp
  ./gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp
  ./gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.cpp
  ./gui/ptm_peptide_list_view/ptmsequencedelegate.cpp
  ./gui/tandem_run_dialog/tandemrundialog.cpp
  ./gui/waiting_message_dialog/waitingmessagedialog.cpp
  ./gui/widgets/Alignment_group_menu/alignmentgroupmenu.cpp
  ./gui/widgets/automatic_filter_widget/automaticfilterwidget.cpp
  ./gui/widgets/engines_view/xtandemparamwidget.cpp
  ./gui/widgets/engines_view/noengineparamwidget.cpp
  ./gui/widgets/contaminant_widget/contaminantwidget.cpp
  ./gui/widgets/decoy_widget/decoywidget.cpp
  ./gui/widgets/xic_extraction_method_widget/xicextractionmethodwidget.cpp
  ./gui/widgets/massitemdelegate.cpp
  ./gui/xic_view/xic_box/xicbox.cpp
  ./gui/xic_view/xic_widgets/zivydialog.cpp
  ./gui/xic_view/xic_widgets/zivywidget.cpp
  ./gui/xic_view/xic_widgets/xicexportparam.cpp
  ./gui/xic_view/xicwindow.cpp
  ./gui/xic_view/xicworkerthread.cpp
  ./gui/workerthread.cpp
  ./utils/workmonitor.cpp
)

set(GUI_UIS
  ./gui/about_dialog/about_dialog.ui
  ./gui/choose_modification_dialog/choose_modification_dialog.ui
  ./gui/edit/edit_alignment_param/masschroq_param_view.ui
  ./gui/edit/edit_label_methods/edit_label_methods.ui
  ./gui/edit/edit_modifications/edit_modifications.ui
  ./gui/edit/edit_settings/edit_settings.ui
  ./gui/edit/edit_tandem_preset_dialog/edit_tandem_preset_dialog.ui
  ./gui/export/export_spreadsheet_dialog/export_spreadsheet_dialog.ui
  ./gui/lists/ms_identification_run_list_view/ms_identification_run_view.ui
  ./gui/lists/ms_identification_run_list_view/engine_detail_view/engine_detail_view.ui
  ./gui/load_results_dialog/load_results_dialog.ui
  ./gui/masschroq_run_dialog/masschroq_run_dialog.ui
  ./gui/main.ui
  ./gui/peptide_detail_view/peptide_detail_view.ui
  ./gui/peptide_list_view/peptide_view.ui
  ./gui/project_view/identification_group_widget/identification_group_widget.ui
  ./gui/project_view/project_view.ui
  ./gui/protein_list_view/protein_view.ui
  ./gui/protein_view/protein_detail_view.ui
  ./gui/ptm_island_list_view/ptm_island_list_view.ui
  ./gui/ptm_peptide_list_view/ptm_peptide_list_view.ui
  ./gui/tandem_run_dialog/tandem_run_dialog.ui
  ./gui/waiting_message_dialog/waiting_message_dialog.ui
  ./gui/widgets/automatic_filter_widget/automatic_filter_widget.ui
  ./gui/widgets/engines_view/xtandem_view_widget.ui
  ./gui/widgets/engines_view/no_engine_view_widget.ui
  ./gui/widgets/contaminant_widget/contaminant_widget.ui
  ./gui/widgets/decoy_widget/decoy_widget.ui
  ./gui/xic_view/xic_box/xic_box.ui
  ./gui/xic_view/xic_widgets/zivy_widget.ui
  ./gui/xic_view/xic_widgets/xic_export_param.ui
  ./gui/xic_view/xic_window.ui
)


# this will run uic on .ui files:
qt5_wrap_ui( GUI_UI_HDRS ${GUI_UIS} )


message("XTPCPP_SRCS:  ${XTPCPP_SRCS}")


add_executable(xtpcpp main.cpp ${CPP_FILES} ${XTPCPP_SRCS} ${GUI_UI_HDRS} ${xtpcpp_RCC_SRCS})

target_include_directories(xtpcpp PUBLIC
    ${Quazip5_INCLUDE_DIRS}
    ${QCustomPlot_INCLUDE_DIR}
)

if(MXE)
    target_compile_options(
        xtpcpp PRIVATE -mwindows
    )
    set_target_properties(xtpcpp PROPERTIES LINK_FLAGS "-Wl,--subsystem,windows ${CMAKE_EXE_LINKER_FLAGS}")
endif(MXE)

target_link_libraries(xtpcpp
    OdsStream::Core
    PappsoMSpp::Core
    PappsoMSpp::Widget
    Qt5::Core
    Qt5::Gui
    Qt5::Xml
    Qt5::Svg
    Qt5::PrintSupport
    Qt5::Network
    Qt5::Sql
    Qt5::Concurrent
    ZLIB::ZLIB
    ${QCustomPlot_LIBRARIES}
    ${Quazip5_LIBRARY}
)




install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/xtpcpp DESTINATION bin)

#configure_file(${CMAKE_SOURCE_DIR}/templates/share/applications/pt-peptideviewer.desktop.cmake ${CMAKE_BINARY_DIR}/templates/share/applications/pt-peptideviewer.desktop)

