cmake_minimum_required(VERSION 3.5)

project(ElectronicCharts VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

find_package(Qt5 REQUIRED COMPONENTS Widgets Xml Svg Network OpenGL Positioning)

set(COMMON
    common/global.h
    common/global.cpp
    common/iconhelper.h
    common/iconhelper.cpp
    common/databasestruct.h
)
source_group(common FILES ${COMMON})

set(UI_FRAMELESS
    ui/frameless/frameless_define.h
    ui/frameless/framelesshelper.cpp
    ui/frameless/framelesshelper.h
    ui/frameless/framelesstitlebar.cpp
    ui/frameless/framelesstitlebar.h
    ui/frameless/framelesstitlebar_p.h
)
source_group(ui/frameless FILES ${UI_FRAMELESS})

set(UI_MENU
    ui/menu/titlebar.h
    ui/menu/titlebar.cpp
    ui/menu/menu.h
    ui/menu/menu.cpp
)
source_group(ui/menu FILES ${UI_MENU})

set(UI_COMMON
    ui/common/clistwidget.h
    ui/common/clistwidget.cpp
    ui/common/switchbutton.h
    ui/common/switchbutton.cpp
    ui/common/lightpoint.h
    ui/common/lightpoint.cpp
)
source_group(ui/common FILES ${UI_COMMON})

set(UI_ARCGISMAP
    ui/arcgismap/cmapview.h
    ui/arcgismap/cmapview.cpp
    ui/arcgismap/armyiconlayer.h
    ui/arcgismap/armyiconlayer.cpp
)
source_group(ui/arcgismap FILES ${UI_ARCGISMAP})

set(UI_LAYERCONTROL
    ui/layercontrol/layercontrolwidget.h
    ui/layercontrol/layercontrolwidget.cpp
    ui/layercontrol/mapxwidget.h
    ui/layercontrol/mapxwidget.cpp
    ui/layercontrol/iconlayerwidget.h
    ui/layercontrol/iconlayerwidget.cpp
    ui/layercontrol/maplayerwidget.h
    ui/layercontrol/maplayerwidget.cpp
    ui/layercontrol/entitywidget.h
    ui/layercontrol/entitywidget.cpp
)
source_group(ui/layercontrol FILES ${UI_LAYERCONTROL})

set(UI_LAYERCONTROL_MAPLAYERTREE
    ui/layercontrol/maplayertree/treeitem.h
    ui/layercontrol/maplayertree/treeitem.cpp
    ui/layercontrol/maplayertree/treemodel.h
    ui/layercontrol/maplayertree/treemodel.cpp
)
source_group(ui/layercontrol/maplayertree FILES ${UI_LAYERCONTROL_MAPLAYERTREE})

set(UI_LAYERCONTROL_NAVIGATION
    ui/layercontrol/navigation/ArrowDiscWidget.cpp
    ui/layercontrol/navigation/ArrowDiscWidget.h
    ui/layercontrol/navigation/navigation.ui
    ui/layercontrol/navigation/NavigationButton.cpp
    ui/layercontrol/navigation/NavigationButton.h
    ui/layercontrol/navigation/NavigationFloatItem.cpp
    ui/layercontrol/navigation/NavigationFloatItem.h
    ui/layercontrol/navigation/NavigationSlider.cpp
    ui/layercontrol/navigation/NavigationSlider.h
)
source_group(ui/layercontrol/navigation FILES ${UI_LAYERCONTROL_NAVIGATION})

set(UI_INFODISPLAY
    ui/infodisplay/infodisplaywidget.h
    ui/infodisplay/infodisplaywidget.cpp
    ui/infodisplay/entityproperty.h
    ui/infodisplay/entityproperty.cpp
)
source_group(ui/infodisplay FILES ${UI_INFODISPLAY})


set(UI
    ui/mainwindow.h
    ui/mainwindow.cpp
    ui/framelesswindow.h
    ui/framelesswindow.cpp
)
source_group(ui FILES ${UI})

set(UI_RESORCES
    ui/resources/entityproperty.ui
)
source_group(ui/resources FILES ${UI_RESORCES})

set(MAIN
    main/main.cpp
)
source_group(main FILES ${MAIN})

set(NETWORK
    network/tcpsocket.h
    network/tcpsocket.cpp
)
source_group(network FILES ${NETWORK})

set(RES
    res/res.qrc
    res/navigation.qrc
)
source_group(res FILES ${RES})
set(RES_IMAGES
    res/images/logo.rc
)
source_group(res/images FILES ${RES_IMAGES})


include(cmake/arcgis-sdk.cmake)

include_directories(
    common
    main
    ui
    ui/common
    ui/frameless
    ui/menu
    ui/arcgismap
    ui/layercontrol
    ui/layercontrol/maplayertree
    ui/layercontrol/navigation
    ui/infodisplay
    network
)

# ui/resources是ui文件所在目录
set(CMAKE_AUTOUIC_SEARCH_PATHS "ui/resources")



add_executable(${PROJECT_NAME}
    WIN32
    ${MAIN}
    ${COMMON}
    ${UI}
    ${UI_COMMON}
    ${UI_MENU}
    ${UI_ARCGISMAP}
    ${UI_FRAMELESS}       
    ${UI_LAYERCONTROL}
    ${UI_RESORCES}
    ${UI_LAYERCONTROL_MAPLAYERTREE}
    ${UI_LAYERCONTROL_NAVIGATION}
    ${UI_INFODISPLAY}
    ${RES}
    ${RES_IMAGES}
    ${NETWORK}
)

target_link_libraries(${PROJECT_NAME} PRIVATE
    Qt5::Widgets Qt5::Xml Qt5::Svg Qt5::Network Qt5::OpenGL Qt5::Positioning
    ${ARCGIS_LIB_FILE}
    ${OSG_LIBRARIES}
    ${OSGEARTH_LIBRARIES}
)

set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
