# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)


###############################################################################################
# Setup application name and defines
###############################################################################################

STRING(TOLOWER ${PROJECT_NAME} APPLICATION_NAME)

# and other funny defines -> maybe config.h is a better place for that
add_definitions(-DROUTINO_XML_PATH=${ROUTINO_XML_PATH})

###############################################################################################
# All source files needed to compile
###############################################################################################

set( SRCS
    CAbout.cpp
    CMainWindow.cpp
    CSingleInstanceProxy.cpp
    canvas/CCanvas.cpp
    canvas/CCanvasSetup.cpp
    canvas/CCanvasSelect.cpp
    canvas/IDrawContext.cpp
    canvas/IDrawObject.cpp
    dem/CDemDraw.cpp
    dem/CDemItem.cpp
    dem/CDemList.cpp
    dem/CDemPathSetup.cpp
    dem/CDemPropSetup.cpp
    dem/CDemVRT.cpp
    dem/CDemWCS.cpp
    dem/IDem.cpp
    dem/IDemProp.cpp
    device/CDeviceGarmin.cpp
    device/CDeviceGarminArchive.cpp
    device/CDeviceTwoNav.cpp
    device/IDevice.cpp
    device/IDeviceWatcher.cpp
    gis/CGisDatabase.cpp
    gis/CGisDraw.cpp
    gis/CWksItemDelegate.cpp
    gis/CDBItemDelegate.cpp
    gis/CGisItemRate.cpp
    gis/CGisListDB.cpp
    gis/CGisListWks.cpp
    gis/CGisWorkspace.cpp
    gis/CSelDevices.cpp
    gis/CSetupWorkspace.cpp
    gis/IGisItem.cpp
    gis/IGisLine.cpp
    gis/IWksItem.cpp
    gis/IDBItem.cpp
    gis/db/CDBFolderGroup.cpp
    gis/db/CDBFolderLostFound.cpp
    gis/db/CDBFolderMysql.cpp
    gis/db/CDBFolderOther.cpp
    gis/db/CDBFolderProject.cpp
    gis/db/CDBFolderSqlite.cpp
    gis/db/CDBItem.cpp
    gis/db/CDBProject.cpp
    gis/db/CExportDatabase.cpp
    gis/db/CExportDatabaseThread.cpp
    gis/db/CLostFoundProject.cpp
    gis/db/CResolveDatabaseConflict.cpp
    gis/db/CSearchDatabase.cpp
    gis/db/CSelectDBFolder.cpp
    gis/db/CSelectSaveAction.cpp
    gis/db/CSetupDatabase.cpp
    gis/db/CSetupFolder.cpp    
    gis/db/IDB.cpp
    gis/db/IDBFolder.cpp
    gis/db/IDBFolderSql.cpp
    gis/db/IDBMysql.cpp
    gis/db/IDBSqlite.cpp
    gis/fit2/CFit2Project.cpp
    gis/gpx/CGpxProject.cpp
    gis/gpx/serialization.cpp
    gis/ovl/CDetailsOvlArea.cpp
    gis/ovl/CGisItemOvlArea.cpp
    gis/ovl/CScrOptOvlArea.cpp
    gis/prj/CDetailsPrj.cpp
    gis/prj/IGisProject.cpp
    gis/qlb/CQlbProject.cpp
    gis/qms/CQmsProject.cpp
    gis/qms/serialization.cpp
    gis/rte/CCreateRouteFromWpt.cpp
    gis/rte/CDetailsRte.cpp
    gis/rte/CGisItemRte.cpp
    gis/rte/CScrOptRte.cpp
    gis/rte/router/CRouterBRouter.cpp
    gis/rte/router/CRouterOptimization.cpp
    gis/rte/router/CRouterRoutino.cpp
    gis/rte/router/CRouterSetup.cpp
    gis/rte/router/IRouter.cpp
    gis/rte/router/brouter/CRouterBRouterDownloadPage.cpp
    gis/rte/router/brouter/CRouterBRouterInfo.cpp
    gis/rte/router/brouter/CRouterBRouterLocal.cpp
    gis/rte/router/brouter/CRouterBRouterSetup.cpp
    gis/rte/router/brouter/CRouterBRouterSetupPage.cpp
    gis/rte/router/brouter/CRouterBRouterSetupWizard.cpp
    gis/rte/router/brouter/CRouterBRouterTilesPage.cpp
    gis/rte/router/brouter/CRouterBRouterTilesSelect.cpp
    gis/rte/router/brouter/CRouterBRouterTilesSelectArea.cpp
    gis/rte/router/brouter/CRouterBRouterToolShell.cpp
    gis/rte/router/routino/CRouterRoutinoPathSetup.cpp
    gis/search/CGeoSearch.cpp
    gis/search/CGeoSearchConfig.cpp
    gis/search/CGeoSearchConfigDialog.cpp
    gis/search/CProjectFilterItem.cpp
    gis/search/CSearchExplanationDialog.cpp
    gis/search/CSearchLineEdit.cpp
    gis/search/CGeoSearchWeb.cpp
    gis/search/CGeoSearchWebConfigDialog.cpp
    gis/slf/CSlfProject.cpp
    gis/slf/CSlfReader.cpp
    gis/summary/CGisSummary.cpp
    gis/summary/CGisSummaryDropZone.cpp
    gis/summary/CGisSummarySetup.cpp
    gis/suunto/CLogProject.cpp
    gis/suunto/CSmlProject.cpp
    gis/suunto/ISuuntoProject.cpp
    gis/tcx/CTcxProject.cpp
    gis/tcx/serialization.cpp
    gis/tnv/CTwoNavProject.cpp
    gis/tnv/serialization.cpp
    gis/trk/CActivityTrk.cpp
    gis/trk/CCombineTrk.cpp
    gis/trk/CCutTrk.cpp
    gis/trk/CDetailsTrk.cpp
    gis/trk/CEnergyCycling.cpp
    gis/trk/CEnergyCyclingDialog.cpp
    gis/trk/CGisItemTrk.cpp
    gis/trk/CInvalidTrk.cpp
    gis/trk/CKnownExtension.cpp
    gis/trk/CListTrkPts.cpp
    gis/trk/CPropertyTrk.cpp
    gis/trk/CScrOptTrk.cpp
    gis/trk/CSelectActivityColor.cpp
    gis/trk/CTableTrk.cpp
    gis/trk/CTableTrkInfo.cpp
    gis/trk/CTrkToAreaDialog.cpp
    gis/trk/CTrkToRteDialog.cpp
    gis/trk/CTrackData.cpp
    gis/trk/filter/CFilterChangeStartPoint.cpp
    gis/trk/filter/CFilterDelete.cpp
    gis/trk/filter/CFilterDeleteExtension.cpp
    gis/trk/filter/CFilterDouglasPeuker.cpp
    gis/trk/filter/CFilterInterpolateElevation.cpp
    gis/trk/filter/CFilterInvalid.cpp
    gis/trk/filter/CFilterLoopsCut.cpp
    gis/trk/filter/CFilterMedian.cpp
    gis/trk/filter/CFilterNewDate.cpp
    gis/trk/filter/CFilterObscureDate.cpp
    gis/trk/filter/CFilterOffsetElevation.cpp
    gis/trk/filter/CFilterReplaceElevation.cpp
    gis/trk/filter/CFilterReset.cpp
    gis/trk/filter/CFilterSpeed.cpp
    gis/trk/filter/CFilterSpeedConst.cpp
    gis/trk/filter/CFilterSpeedCycle.cpp
    gis/trk/filter/CFilterSpeedHike.cpp
    gis/trk/filter/CFilterSplitSegment.cpp
    gis/trk/filter/CFilterSplitTrack.cpp
    gis/trk/filter/CFilterSubPt2Pt.cpp
    gis/trk/filter/CFilterTerrainSlope.cpp
    gis/trk/filter/CFilterZeroSpeedDriftCleaner.cpp
    gis/trk/filter/filter.cpp
    gis/wpt/CDetailsGeoCache.cpp
    gis/wpt/CDetailsWpt.cpp
    gis/wpt/CGisItemWpt.cpp
    gis/wpt/CProjWpt.cpp
    gis/wpt/CScrOptWpt.cpp
    gis/wpt/CScrOptWptRadius.cpp
    gis/wpt/CSetupIconAndName.cpp
    grid/CGrid.cpp
    grid/CGridSetup.cpp
    grid/CProjWizard.cpp
    grid/mitab.cpp
    helpers/CDraw.cpp
    helpers/CElevationDialog.cpp
    gis/search/CSearch.cpp
    helpers/CInputDialog.cpp
    helpers/CLimit.cpp
    helpers/CLinksDialog.cpp
    helpers/CMapIconSizesSetup.cpp
    helpers/CPhotoViewer.cpp
    helpers/CPositionDialog.cpp
    helpers/CProgressDialog.cpp
    helpers/CSelectCopyAction.cpp
    helpers/CSelectProjectDialog.cpp
    helpers/CThread.cpp
    helpers/CTimeDialog.cpp
    helpers/CToolBarConfig.cpp
    helpers/CToolBarSetupDialog.cpp
    helpers/CValue.cpp
    helpers/CWptIconDialog.cpp
    helpers/CWptIconManager.cpp
    main.cpp
    map/CMapDraw.cpp
    map/CMapGEMF.cpp
    map/CMapIMG.cpp
    map/CMapItem.cpp
    map/CMapItemDelegate.cpp
    map/CMapJNX.cpp
    map/CMapList.cpp
    map/CMapMAP.cpp
    map/CMapPathSetup.cpp
    map/CMapPropSetup.cpp
    map/CMapRMAP.cpp
    map/CMapTMS.cpp
    map/CMapVRT.cpp
    map/CMapWMTS.cpp
    map/IMap.cpp
    map/IMapOnline.cpp
    map/IMapProp.cpp
    map/cache/CDiskCache.cpp
    map/garmin/CGarminPoint.cpp
    map/garmin/CGarminPolygon.cpp
    map/garmin/CGarminStrTbl6.cpp
    map/garmin/CGarminStrTbl8.cpp
    map/garmin/CGarminStrTblUtf8.cpp
    map/garmin/CGarminTyp.cpp
    map/garmin/IGarminStrTbl.cpp
    map/mapsforge/types.cpp
    misc.h
    mouse/CMouseAdapter.cpp
    mouse/CMouseDummy.cpp
    mouse/CMouseEditArea.cpp
    mouse/CMouseEditRte.cpp
    mouse/CMouseEditTrk.cpp
    mouse/CMouseMoveWpt.cpp
    mouse/CMouseNormal.cpp
    mouse/CMousePrint.cpp
    mouse/CMouseRadiusWpt.cpp
    mouse/CMouseRangeTrk.cpp
    mouse/CMouseRuler.cpp
    mouse/CMouseSelect.cpp
    mouse/CMouseWptBubble.cpp
    mouse/CScrOptPrint.cpp
    mouse/range/CActionSelect.cpp
    mouse/range/CRangeToolSetup.cpp
    mouse/range/CScrOptRangeTool.cpp
    mouse/range/CScrOptRangeTrk.cpp
    mouse/CScrOptRuler.cpp
    mouse/CScrOptSelect.cpp
    mouse/CScrOptSemaphoreLocker.cpp
    mouse/CScrOptUnclutter.cpp
    mouse/IMouse.cpp
    mouse/IMouseSelect.cpp
    mouse/IScrOpt.cpp
    mouse/line/CLineOpAddPoint.cpp
    mouse/line/CLineOpDeletePoint.cpp
    mouse/line/CLineOpMovePoint.cpp
    mouse/line/CLineOpSelectRange.cpp
    mouse/line/CScrOptEditLine.cpp
    mouse/line/CScrOptRangeLine.cpp
    mouse/line/ILineOp.cpp
    mouse/line/IMouseEditLine.cpp
    plot/CPlot.cpp
    plot/CPlotAxis.cpp
    plot/CPlotAxisTime.cpp
    plot/CPlotData.cpp
    plot/CPlotProfile.cpp
    plot/CPlotTrack.cpp
    plot/IPlot.cpp
    plot/ITrack.cpp
    poi/CPoiCategory.cpp
    poi/CPoiDraw.cpp
    poi/CPoiFileItem.cpp
    poi/CPoiFilePOI.cpp
    poi/CPoiFilePOI_TagMap.cpp
    poi/CPoiIconCategory.cpp
    poi/CPoiItemPOI.cpp
    poi/CPoiList.cpp
    poi/CPoiPathSetup.cpp
    poi/CPoiPropSetup.cpp
    poi/CPoiTreeWidgetCategories.cpp
    poi/IPoiFile.cpp
    poi/IPoiProp.cpp
    print/CPrintDialog.cpp
    print/CScreenshotDialog.cpp
    qlgt/CQlb.cpp
    qlgt/CQlgtDb.cpp
    qlgt/CQlgtDiary.cpp
    qlgt/CQlgtFolder.cpp
    qlgt/CQlgtRoute.cpp
    qlgt/CQlgtTrack.cpp
    qlgt/CQlgtWpt.cpp
    qlgt/CQmsDb.cpp
    qlgt/IItem.cpp
    qlgt/IQlgtOverlay.cpp
    qlgt/converter.cpp
    realtime/CRtDraw.cpp
    realtime/CRtSelectSource.cpp
    realtime/CRtWorkspace.cpp
    realtime/IRtInfo.cpp
    realtime/IRtRecord.cpp
    realtime/IRtSource.cpp
    realtime/gpstether/CRtGpsTether.cpp
    realtime/gpstether/CRtGpsTetherInfo.cpp
    realtime/gpstether/CRtGpsTetherRecord.cpp
    realtime/ais/CRtAis.cpp
    realtime/ais/CRtAisInfo.cpp
    realtime/ais/CRtAisRecord.cpp
    realtime/opensky/CRtOpenSky.cpp
    realtime/opensky/CRtOpenSkyInfo.cpp
    realtime/opensky/CRtOpenSkyRecord.cpp
    setup/CAppSetupLinux.cpp
    setup/CAppSetupMac.cpp
    setup/CAppSetupWin.cpp
    setup/CCommandProcessor.cpp
    setup/CLogHandler.cpp
    setup/IAppSetup.cpp
    tool/CImportDatabase.cpp
    tool/CMapVrtBuilder.cpp
    tool/CRoutinoDatabaseBuilder.cpp
    tool/IToolShell.cpp
    units/CCoordFormatSetup.cpp
    units/CTimeZoneSetup.cpp
    units/CUnitImperial.cpp
    units/CUnitMetric.cpp
    units/CUnitNautic.cpp
    units/CUnitAviation.cpp
    units/CUnitsSetup.cpp
    units/IUnit.cpp
    widgets/CColorLegend.cpp
    widgets/CDateTimeEditor.cpp
    widgets/CDoubleSpinBox.cpp
    widgets/CFadingIcon.cpp
    widgets/CFadingLabel.cpp
    widgets/CHistoryListWidget.cpp
    widgets/CIconGrid.cpp
    widgets/CLedIndicator.cpp
    widgets/CLineEdit.cpp
    widgets/CPhotoAlbum.cpp
    widgets/CSelectDoubleListWidget.cpp
    widgets/CScaleWidget.cpp
    widgets/CTemplateWidget.cpp
    widgets/CTextEdit.cpp
    widgets/CTextEditWidget.cpp
    widgets/CTextEditWidgetSelMenu.cpp
    widgets/CTinySpinBox.cpp
    widgets/CWptIconSelectWidget.cpp
    ../common/help/CHelp.cpp
    ../common/help/CHelpBrowser.cpp
    ../common/help/CHelpIndex.cpp
    ../common/help/CHelpSearch.cpp
    ../common/gis/GeoMath.cpp
    ../common/gis/proj_x.cpp
)


if(Qt6DBus_FOUND)
set( SRCS
    ${SRCS}
    device/IDeviceAccess.cpp
    device/CDeviceWatcherLinux.cpp
    device/CDeviceAccessKMtp.cpp
    device/CDeviceAccessGvfsMtp.cpp
    device/CDeviceGarminMtp.cpp
    device/CDeviceGarminArchiveMtp.cpp
    device/CDeviceGenericMtp.cpp
    device/dbus/org.kde.kmtp.Daemon.cpp
    device/dbus/org.kde.kmtp.Device.cpp
    device/dbus/org.kde.kmtp.Storage.cpp
    device/dbus/org.gtk.vfs.MTPVolumeMonitor.cpp
    device/dbus/org.gtk.vfs.MountTracker.cpp
    device/dbus/org.gtk.vfs.Mount.cpp
    device/dbus/metatypes.cpp
)
endif(Qt6DBus_FOUND)


if (APPLE)
set( SRCS
    ${SRCS}
    device/CDeviceWatcherMac.cpp
)
endif(APPLE)

if(WIN32)
set( SRCS
    ${SRCS}
    device/CDeviceWatcherWindows.cpp
)
endif(WIN32)


set( HDRS
    CAbout.h
    CMainWindow.h
    CSingleInstanceProxy.h
    contributors.h
    canvas/CCanvas.h
    canvas/CCanvasSetup.h
    canvas/CCanvasSelect.h
    canvas/IDrawContext.h
    canvas/IDrawObject.h
    dem/CDemDraw.h
    dem/CDemItem.h
    dem/CDemList.h
    dem/CDemPathSetup.h
    dem/CDemPropSetup.h
    dem/CDemVRT.h
    dem/CDemWCS.h
    dem/IDem.h
    dem/IDemProp.h
    device/CDeviceGarmin.h
    device/CDeviceGarminArchive.h
    device/CDeviceTwoNav.h
    device/IDevice.h
    device/IDeviceWatcher.h
    gis/CGisDatabase.h
    gis/CGisDraw.h
    gis/CWksItemDelegate.h
    gis/CDBItemDelegate.h
    gis/CGisItemRate.h
    gis/CGisListDB.h
    gis/CGisListWks.h
    gis/CGisWorkspace.h
    gis/CSelDevices.h
    gis/CSetupWorkspace.h
    gis/IGisItem.h
    gis/IGisLine.h
    gis/IWksItem.h
    gis/IDBItem.h
    gis/db/CDBFolderGroup.h
    gis/db/CDBFolderLostFound.h
    gis/db/CDBFolderMysql.h
    gis/db/CDBFolderOther.h
    gis/db/CDBFolderProject.h
    gis/db/CDBFolderSqlite.h
    gis/db/CDBItem.h
    gis/db/CDBProject.h
    gis/db/CExportDatabase.h
    gis/db/CExportDatabaseThread.h
    gis/db/CLostFoundProject.h
    gis/db/CResolveDatabaseConflict.h
    gis/db/CSearchDatabase.h
    gis/db/CSelectDBFolder.h
    gis/db/CSelectSaveAction.h
    gis/db/CSetupDatabase.h
    gis/db/CSetupFolder.h    
    gis/db/IDB.h
    gis/db/IDBFolder.h
    gis/db/IDBFolderSql.h
    gis/db/IDBMysql.h
    gis/db/IDBSqlite.h
    gis/db/macros.h
    gis/fit2/CFit2Project.h
    gis/gpx/CGpxProject.h
    gis/ovl/CDetailsOvlArea.h
    gis/ovl/CGisItemOvlArea.h
    gis/ovl/CScrOptOvlArea.h
    gis/prj/CDetailsPrj.h
    gis/prj/IGisProject.h
    gis/qlb/CQlbProject.h
    gis/qms/CQmsProject.h
    gis/rte/CCreateRouteFromWpt.h
    gis/rte/CDetailsRte.h
    gis/rte/CGisItemRte.h
    gis/rte/CScrOptRte.h
    gis/rte/router/CRouterBRouter.h
    gis/rte/router/CRouterOptimization.h
    gis/rte/router/CRouterRoutino.h
    gis/rte/router/CRouterSetup.h
    gis/rte/router/IRouter.h
    gis/rte/router/brouter/CRouterBRouterDownloadPage.h
    gis/rte/router/brouter/CRouterBRouterInfo.h
    gis/rte/router/brouter/CRouterBRouterLocal.h
    gis/rte/router/brouter/CRouterBRouterSetup.h
    gis/rte/router/brouter/CRouterBRouterSetupPage.h
    gis/rte/router/brouter/CRouterBRouterSetupWizard.h
    gis/rte/router/brouter/CRouterBRouterTilesPage.h
    gis/rte/router/brouter/CRouterBRouterTilesSelect.h
    gis/rte/router/brouter/CRouterBRouterTilesSelectArea.h
    gis/rte/router/brouter/CRouterBRouterTilesSelectLayout.h
    gis/rte/router/brouter/CRouterBRouterTilesStatus.h
    gis/rte/router/brouter/CRouterBRouterToolShell.h
    gis/rte/router/routino/CRouterRoutinoPathSetup.h
    gis/search/CGeoSearch.h
    gis/search/CGeoSearchConfig.h
    gis/search/CGeoSearchConfigDialog.h
    gis/search/CGeoSearchWeb.h
    gis/search/CGeoSearchWebConfigDialog.h
    gis/search/CProjectFilterItem.h
    gis/search/CSearchExplanationDialog.h
    gis/search/CSearchLineEdit.h
    gis/slf/CSlfProject.h
    gis/slf/CSlfReader.h
    gis/summary/CGisSummary.h
    gis/summary/CGisSummaryDropZone.h
    gis/summary/CGisSummarySetup.h
    gis/suunto/CLogProject.h
    gis/suunto/CSmlProject.h
    gis/suunto/ISuuntoProject.h
    gis/tcx/CTcxProject.h
    gis/tnv/CTwoNavProject.h
    gis/trk/CActivityTrk.h
    gis/trk/CCombineTrk.h
    gis/trk/CCutTrk.h
    gis/trk/CDetailsTrk.h
    gis/trk/CEnergyCycling.h
    gis/trk/CEnergyCyclingDialog.h
    gis/trk/CGisItemTrk.h
    gis/trk/CInvalidTrk.h
    gis/trk/CKnownExtension.h
    gis/trk/CListTrkPts.h
    gis/trk/CPropertyTrk.h
    gis/trk/CScrOptTrk.h
    gis/trk/CSelectActivityColor.h
    gis/trk/CTableTrk.h
    gis/trk/CTableTrkInfo.h
    gis/trk/CTrkToAreaDialog.h
    gis/trk/CTrkToRteDialog.h
    gis/trk/CTrackData.h
    gis/trk/filter/CFilterChangeStartPoint.h
    gis/trk/filter/CFilterDelete.h
    gis/trk/filter/CFilterDeleteExtension.h
    gis/trk/filter/CFilterDouglasPeuker.h
    gis/trk/filter/CFilterInterpolateElevation.h
    gis/trk/filter/CFilterInvalid.h
    gis/trk/filter/CFilterLoopsCut.h
    gis/trk/filter/CFilterMedian.h
    gis/trk/filter/CFilterNewDate.h
    gis/trk/filter/CFilterObscureDate.h
    gis/trk/filter/CFilterOffsetElevation.h
    gis/trk/filter/CFilterReplaceElevation.h
    gis/trk/filter/CFilterReset.h
    gis/trk/filter/CFilterSpeed.h
    gis/trk/filter/CFilterSpeedConst.h
    gis/trk/filter/CFilterSpeedCycle.h
    gis/trk/filter/CFilterSpeedHike.h
    gis/trk/filter/CFilterSplitSegment.h
    gis/trk/filter/CFilterSplitTrack.h
    gis/trk/filter/CFilterSubPt2Pt.h
    gis/trk/filter/CFilterTerrainSlope.h
    gis/trk/filter/CFilterZeroSpeedDriftCleaner.h
    gis/wpt/CDetailsGeoCache.h
    gis/wpt/CDetailsWpt.h
    gis/wpt/CGisItemWpt.h
    gis/wpt/CProjWpt.h
    gis/wpt/CScrOptWpt.h
    gis/wpt/CScrOptWptRadius.h
    gis/wpt/CSetupIconAndName.h
    grid/CGrid.h
    grid/CGridSetup.h
    grid/CProjWizard.h
    grid/mitab.h
    helpers/CDraw.h
    helpers/CElevationDialog.h
    helpers/CFileExt.h
    gis/search/CSearch.h
    helpers/CInputDialog.h
    helpers/CLimit.h
    helpers/CLinksDialog.h
    helpers/CMapIconSizesSetup.h
    helpers/CPhotoViewer.h
    helpers/CPositionDialog.h
    helpers/CProgressDialog.h
    helpers/CSelectCopyAction.h
    helpers/CSelectProjectDialog.h
    helpers/CSettings.h
    helpers/CThread.h
    helpers/CTryMutexLocker.h
    helpers/CTimeDialog.h
    helpers/CToolBarConfig.h
    helpers/CToolBarSetupDialog.h
    helpers/CValue.h
    helpers/CWebPage.h
    helpers/CWptIconDialog.h
    helpers/CWptIconManager.h
    helpers/Platform.h
    helpers/Signals.h
    helpers/Tristate.h
    map/CMapDraw.h
    map/CMapGEMF.h
    map/CMapIMG.h
    map/CMapItem.h
    map/CMapItemDelegate.h
    map/CMapJNX.h
    map/CMapList.h
    map/CMapMAP.h
    map/CMapPathSetup.h
    map/CMapPropSetup.h
    map/CMapRMAP.h
    map/CMapTMS.h
    map/CMapVRT.h
    map/CMapWMTS.h
    map/IMap.h
    map/IMapItem.h
    map/IMapOnline.h
    map/IMapProp.h
    map/IMapPropSetup.h
    map/cache/CDiskCache.h
    map/garmin/CGarminPoint.h
    map/garmin/CGarminPolygon.h
    map/garmin/CGarminStrTbl6.h
    map/garmin/CGarminStrTbl8.h
    map/garmin/CGarminStrTblUtf8.h
    map/garmin/CGarminTyp.h
    map/garmin/Garmin.h
    map/garmin/IGarminStrTbl.h
    map/mapsforge/types.h
    mouse/CMouseAdapter.h
    mouse/CMouseDummy.h
    mouse/CMouseEditArea.h
    mouse/CMouseEditRte.h
    mouse/CMouseEditTrk.h
    mouse/CMouseMoveWpt.h
    mouse/CMouseNormal.h
    mouse/CMousePrint.h
    mouse/CMouseRadiusWpt.h
    mouse/CMouseRangeTrk.h
    mouse/CMouseRuler.h
    mouse/CMouseSelect.h
    mouse/CMouseWptBubble.h
    mouse/CScrOptPrint.h
    mouse/range/CActionSelect.h
    mouse/range/CRangeToolSetup.h
    mouse/range/CScrOptRangeTool.h
    mouse/range/CScrOptRangeTrk.h
    mouse/CScrOptRuler.h
    mouse/CScrOptSelect.h
    mouse/CScrOptSemaphoreLocker.h
    mouse/CScrOptUnclutter.h
    mouse/IMouse.h
    mouse/IMouseSelect.h
    mouse/IScrOpt.h
    mouse/line/CLineOpAddPoint.h
    mouse/line/CLineOpDeletePoint.h
    mouse/line/CLineOpMovePoint.h
    mouse/line/CLineOpSelectRange.h
    mouse/line/CScrOptEditLine.h
    mouse/line/CScrOptRangeLine.h
    mouse/line/ILineOp.h
    mouse/line/IMouseEditLine.h
    plot/CPlot.h
    plot/CPlotAxis.h
    plot/CPlotAxisTime.h
    plot/CPlotData.h
    plot/CPlotProfile.h
    plot/CPlotTrack.h
    plot/IPlot.h
    plot/ITrack.h
    poi/CPoiCategory.h
    poi/CPoiDraw.h
    poi/CPoiFileItem.h
    poi/CPoiFilePOI.h
    poi/CPoiIconCategory.h
    poi/CPoiItemPOI.h
    poi/CPoiList.h
    poi/CPoiPathSetup.h
    poi/CPoiPropSetup.h
    poi/CPoiTreeWidgetCategories.h
    poi/IPoiFile.h
    poi/IPoiItem.h
    poi/IPoiProp.h
    print/CPrintDialog.h
    print/CScreenshotDialog.h
    qlgt/CQlb.h
    qlgt/CQlgtDb.h
    qlgt/CQlgtDiary.h
    qlgt/CQlgtFolder.h
    qlgt/CQlgtRoute.h
    qlgt/CQlgtTrack.h
    qlgt/CQlgtWpt.h
    qlgt/CQmsDb.h
    qlgt/IItem.h
    qlgt/IQlgtOverlay.h
    realtime/CRtDraw.h
    realtime/CRtSelectSource.h
    realtime/CRtWorkspace.h
    realtime/IRtInfo.h
    realtime/IRtRecord.h
    realtime/IRtSource.h
    realtime/gpstether/CRtGpsTether.h
    realtime/gpstether/CRtGpsTetherInfo.h
    realtime/gpstether/CRtGpsTetherRecord.h
    realtime/opensky/CRtOpenSky.h
    realtime/opensky/CRtOpenSkyInfo.h
    realtime/opensky/CRtOpenSkyRecord.h
    realtime/ais/CRtAis.h
    realtime/ais/CRtAisInfo.h
    realtime/ais/CRtAisRecord.h
    setup/CAppOpts.h
    setup/CAppSetupLinux.h
    setup/CAppSetupMac.h
    setup/CAppSetupWin.h
    setup/CCommandProcessor.h
    setup/CLogHandler.h
    setup/IAppSetup.h
    tool/CImportDatabase.h
    tool/CMapVrtBuilder.h
    tool/CRoutinoDatabaseBuilder.h
    tool/IToolShell.h
    units/CCoordFormatSetup.h
    units/CTimeZoneSetup.h
    units/CUnitImperial.h
    units/CUnitMetric.h
    units/CUnitNautic.h
    units/CUnitAviation.h
    units/CUnitsSetup.h
    units/IUnit.h
    version.h
    widgets/CColorLegend.h
    widgets/CDateTimeEditor.h
    widgets/CDoubleSpinBox.h
    widgets/CFadingIcon.h
    widgets/CFadingLabel.h
    widgets/CHistoryListWidget.h
    widgets/CIconGrid.h
    widgets/CLedIndicator.h
    widgets/CLineEdit.h
    widgets/CPhotoAlbum.h
    widgets/CSelectDoubleListWidget.h
    widgets/CScaleWidget.h
    widgets/CTemplateWidget.h
    widgets/CTextEdit.h
    widgets/CTextEditWidget.h
    widgets/CTextEditWidgetSelMenu.h
    widgets/CTinySpinBox.h
    widgets/CWptIconSelectWidget.h
    ../common/help/CHelp.h
    ../common/help/CHelpBrowser.h
    ../common/help/CHelpIndex.h
    ../common/help/CHelpSearch.h
    ../common/gis/GeoMath.h
    ../common/gis/proj_x.h
)


if(Qt6DBus_FOUND)
set( HDRS
    ${HDRS}
    device/CDeviceWatcherLinux.h
    device/CDeviceAccessKMtp.h
    device/CDeviceAccessGvfsMtp.h
    device/CDeviceGarminMtp.h
    device/CDeviceGarminArchiveMtp.h
    device/CDeviceGenericMtp.h
    device/IDeviceAccess.h
    device/dbus/org.kde.kmtp.Daemon.h
    device/dbus/org.kde.kmtp.Device.h
    device/dbus/org.kde.kmtp.Storage.h
    device/dbus/org.gtk.vfs.MTPVolumeMonitor.h
    device/dbus/org.gtk.vfs.MountTracker.h
    device/dbus/org.gtk.vfs.Mount.h
    device/dbus/metatypes.h
)
endif(Qt6DBus_FOUND)


if(APPLE)
set( HDRS
    ${HDRS}
    device/CDeviceWatcherMac.h
    )
endif(APPLE)

if(WIN32)
set( HDRS
    ${HDRS}
    device/CDeviceWatcherWindows.h
)
endif(WIN32)

set( UIS
    IAbout.ui
    IMainWindow.ui
    canvas/ICanvasSetup.ui
    canvas/ICanvasSelect.ui
    dem/IDemList.ui
    dem/IDemPathSetup.ui
    dem/IDemPropSetup.ui
    gis/IGisDatabase.ui
    gis/IGisItemRate.ui
    gis/IGisWorkspace.ui
    gis/ISelDevices.ui
    gis/ISetupWorkspace.ui
    gis/db/IExportDatabase.ui
    gis/db/IResolveDatabaseConflict.ui
    gis/db/ISearchDatabase.ui
    gis/db/ISelectDBFolder.ui
    gis/db/ISelectSaveAction.ui
    gis/db/ISetupDatabase.ui
    gis/db/ISetupFolder.ui    
    gis/ovl/IDetailsOvlArea.ui
    gis/ovl/IScrOptOvlArea.ui
    gis/prj/IDetailsPrj.ui
    gis/rte/ICreateRouteFromWpt.ui
    gis/rte/IDetailsRte.ui
    gis/rte/IScrOptRte.ui
    gis/rte/router/IRouterBRouter.ui
    gis/rte/router/IRouterRoutino.ui
    gis/rte/router/IRouterSetup.ui
    gis/rte/router/brouter/IRouterBRouterInfo.ui
    gis/rte/router/brouter/IRouterBRouterSetupWizard.ui
    gis/rte/router/routino/IRouterRoutinoPathSetup.ui
    gis/search/IGeoSearchConfigDialog.ui
    gis/search/IGeoSearchWebConfigDialog.ui
    gis/search/ISearchExplanationDialog.ui
    gis/summary/IGisSummary.ui
    gis/summary/IGisSummarySetup.ui
    gis/trk/ICombineTrk.ui
    gis/trk/ICutTrk.ui
    gis/trk/IDetailsTrk.ui
    gis/trk/IEnergyCyclingDialog.ui
    gis/trk/IInvalidTrk.ui
    gis/trk/IListTrkPts.ui
    gis/trk/IScrOptTrk.ui
    gis/trk/ISelectActivityColor.ui
    gis/trk/ITrkToAreaDialog.ui
    gis/trk/ITrkToRteDialog.ui
    gis/trk/filter/IFilterChangeStartPoint.ui
    gis/trk/filter/IFilterDelete.ui
    gis/trk/filter/IFilterDeleteExtension.ui
    gis/trk/filter/IFilterDouglasPeuker.ui
    gis/trk/filter/IFilterInterpolateElevation.ui
    gis/trk/filter/IFilterInvalid.ui
    gis/trk/filter/IFilterLoopsCut.ui
    gis/trk/filter/IFilterMedian.ui
    gis/trk/filter/IFilterNewDate.ui
    gis/trk/filter/IFilterObscureDate.ui
    gis/trk/filter/IFilterOffsetElevation.ui
    gis/trk/filter/IFilterReplaceElevation.ui
    gis/trk/filter/IFilterReset.ui
    gis/trk/filter/IFilterSpeed.ui
    gis/trk/filter/IFilterSpeedConst.ui
    gis/trk/filter/IFilterSpeedCycle.ui
    gis/trk/filter/IFilterSpeedHike.ui
    gis/trk/filter/IFilterSplitSegment.ui
    gis/trk/filter/IFilterSplitTrack.ui
    gis/trk/filter/IFilterSubPt2Pt.ui
    gis/trk/filter/IFilterTerrainSlope.ui
    gis/trk/filter/IFilterZeroSpeedDriftCleaner.ui
    gis/wpt/IDetailsGeoCache.ui
    gis/wpt/IDetailsWpt.ui
    gis/wpt/IProjWpt.ui
    gis/wpt/IScrOptWpt.ui
    gis/wpt/IScrOptWptRadius.ui
    gis/wpt/ISetupIconAndName.ui
    grid/IGridSetup.ui
    grid/IProjWizard.ui
    helpers/IElevationDialog.ui
    helpers/IInputDialog.ui
    helpers/ILinksDialog.ui
    helpers/IMapIconSizesSetup.ui
    helpers/IPositionDialog.ui
    helpers/IProgressDialog.ui
    helpers/ISelectCopyAction.ui
    helpers/ISelectProjectDialog.ui
    helpers/ITimeDialog.ui
    helpers/IToolBarSetupDialog.ui
    helpers/IWptIconDialog.ui
    map/IMapList.ui
    map/IMapPathSetup.ui
    map/IMapPropSetup.ui
    mouse/IScrOptPrint.ui
    mouse/range/IActionSelect.ui
    mouse/range/IRangeToolSetup.ui
    mouse/range/IScrOptRangeTool.ui
    mouse/range/IScrOptRangeTrk.ui
    mouse/IScrOptRuler.ui
    mouse/IScrOptSelect.ui
    mouse/line/IScrOptEditLine.ui
    mouse/line/IScrOptRangeLine.ui
    poi/IPoiList.ui
    poi/IPoiPathSetup.ui
    poi/IPoiPropSetup.ui
    print/IPrintDialog.ui
    print/IScreenshotDialog.ui
    realtime/IRtSelectSource.ui
    realtime/IRtWorkspace.ui
    realtime/gpstether/IRtGpsTetherInfo.ui
    realtime/opensky/IRtOpenSkyInfo.ui
    realtime/ais/IRtAisInfo.ui
    templates/Cycling_Tour_Summary.ui
    templates/Hiking_Tour_Summary.ui
    templates/Hiking_Tour_Summary_\(Advanced\).ui
    templates/Running_Summary.ui
    tool/IImportDatabase.ui
    tool/IMapVrtBuilder.ui
    tool/IRoutinoDatabaseBuilder.ui
    units/ICoordFormatSetup.ui
    units/ITimeZoneSetup.ui
    units/IUnitsSetup.ui
    widgets/IColorChooser.ui
    widgets/IPhotoAlbum.ui
    widgets/ISelectDoubleListWidget.ui
    widgets/ITemplateWidget.ui
    widgets/ITextEditWidget.ui
    widgets/ITextEditWidgetSelMenu.ui
)

set( RCS
    resources.qrc
)

###############################################################################################
# Some Qt magic
###############################################################################################

qt6_wrap_ui(UI_HDRS ${UIS})
qt6_add_resources(RC_SRCS ${RCS})


###############################################################################################
# Build source file and include paths lists
###############################################################################################
set(MAININP
    ${SRCS}
    ${HDRS}
    ${UI_HDRS}
    ${RC_SRCS}
    ${${APPLICATION_NAME}_DESKTOP_FILES}
)

include_directories(
    .
    ../common
    SYSTEM # this prevents warnings from non-QMS headers
    ${CMAKE_BINARY_DIR}
    ${GDAL_INCLUDE_DIRS}
    ${PROJ_INCLUDE_DIRS}
    ${ROUTINO_INCLUDE_DIRS}
    ${ALGLIB_INCLUDE_DIRS}
    ../../3rdparty/GarminFitSdk/cpp
)

if(APPLE)
     include_directories(/System/Library/Frameworks/Foundation.framework)
     include_directories(/System/Library/Frameworks/DiskArbitration.framework)
endif(APPLE)


###############################################################################################
# Build the executable and define necessary libraries.
###############################################################################################
if(WIN32)
    set (ICON win32icon.rc)
endif()
add_executable(${APPLICATION_NAME} WIN32 ${MAININP} ${ICON})

###############################################################################################
# Translation related stuff
###############################################################################################
if(${UPDATE_TRANSLATIONS_PURGE_OBSOLETE})
    set(UPDATE_OPTIONS -noobsolete)
else()
    set(UPDATE_OPTIONS )
endif()

set( TRANSLATIONS
    locale/${APPLICATION_NAME}.ts
    locale/${APPLICATION_NAME}_ca.ts
    locale/${APPLICATION_NAME}_cs.ts
    locale/${APPLICATION_NAME}_de.ts
    locale/${APPLICATION_NAME}_es.ts
    locale/${APPLICATION_NAME}_fr.ts
    locale/${APPLICATION_NAME}_it.ts
    locale/${APPLICATION_NAME}_nl.ts
    locale/${APPLICATION_NAME}_ru.ts
)

if(${UPDATE_TRANSLATIONS})

    qt_add_translations(${APPLICATION_NAME}
        TS_FILES ${TRANSLATIONS}
        QM_FILES_OUTPUT_VARIABLE ${APPLICATION_NAME}_QM_FILES
        LUPDATE_TARGET ${APPLICATION_NAME}_lupdate
        SOURCE_TARGETS ${APPLICATION_NAME}    
        LUPDATE_OPTIONS ${UPDATE_OPTIONS}
    )
    add_dependencies(${APPLICATION_NAME} ${APPLICATION_NAME}_lupdate)
else(${UPDATE_TRANSLATIONS})
    qt_add_lrelease(
        TS_FILES  ${TRANSLATIONS}
        QM_FILES_OUTPUT_VARIABLE ${APPLICATION_NAME}_QM_FILES
    )
    qt_add_resources(${APPLICATION_NAME} "translations"
        PREFIX "/locale"
        BASE "${CMAKE_CURRENT_BINARY_DIR}"
        FILES "${${APPLICATION_NAME}_QM_FILES}"
    )
endif(${UPDATE_TRANSLATIONS})


###############################################################################################
# Compile definitions
###############################################################################################
target_compile_definitions(${APPLICATION_NAME} PUBLIC
    -DVER_MAJOR=${PROJECT_VERSION_MAJOR}
    -DVER_MINOR=${PROJECT_VERSION_MINOR}
    -DVER_STEP=${PROJECT_VERSION_PATCH}
    -DAPPLICATION_NAME=${PROJECT_NAME}
)

if(${DEVELOPMENT_VERSION})
    target_compile_definitions(${APPLICATION_NAME} PUBLIC
        -DDEVELOPMENT
    )
endif(${DEVELOPMENT_VERSION})

###############################################################################################
# Libraries
###############################################################################################
if(Qt6DBus_FOUND)
    set(DBUS_LIB Qt6::DBus)
else(Qt6DBus_FOUND)
    set(DBUS_LIB)
endif(Qt6DBus_FOUND)

target_link_libraries(${APPLICATION_NAME}
    Qt6::Widgets
    Qt6::Xml
    Qt6::Sql
    Qt6::PrintSupport
    Qt6::UiTools
    Qt6::Network
    Qt6::WebEngineWidgets
    Qt6::Qml
    Qt6::Help
    Qt6::Core5Compat
    ${DBUS_LIB}
    ${GDAL_LIBRARIES}
    ${PROJ_LIBRARIES}
    ${ROUTINO_LIBRARIES}
    ${ALGLIB_LIBRARIES}
    QuaZip::QuaZip
    GarminFit
)

if(APPLE)
     target_link_libraries(${APPLICATION_NAME}
     ${Foundation_LIBRARY}
     ${DiskArbitration_LIBRARY}
    )
endif(APPLE)


###############################################################################################
# Install target related stuff
###############################################################################################
install(TARGETS     ${APPLICATION_NAME}                     DESTINATION     ${BIN_INSTALL_DIR})

if (UNIX AND NOT WIN32 AND NOT APPLE)
    install(FILES   ${${APPLICATION_NAME}_QM_FILES}         DESTINATION     ${DATA_INSTALL_PREFIX}/${APPLICATION_NAME}/translations)
    install(FILES   ${${APPLICATION_NAME}_DESKTOP_FILES}    DESTINATION     ${XDG_APPS_DIR})
endif (UNIX AND NOT WIN32 AND NOT APPLE)
if(WIN32)
    qt_generate_deploy_app_script(
        TARGET ${APPLICATION_NAME}
        OUTPUT_SCRIPT deploy_script_${APPLICATION_NAME}
        NO_UNSUPPORTED_PLATFORM_ERROR
    )
    install(SCRIPT ${deploy_script_${APPLICATION_NAME}})
endif()
