project(KraView)

cmake_minimum_required(VERSION 2.8.12)

cmake_policy(SET CMP0063 NEW)

set(QT_MIN_VERSION "5.3.0")
set(KF5_MIN_VERSION "5.2.0")

find_package(ECM 1.0.0 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

set(CMAKE_CXX_STANDARD 14)

include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings)
include(FeatureSummary)
kde_enable_exceptions()

add_definitions(
    -DQT_DEPRECATED_WARNINGS
    -DQT_NO_URL_CAST_FROM_STRING
    -DQT_RESTRICTED_CAST_FROM_ASCII
    -DQT_NO_CAST_TO_ASCII
    -DQT_NO_CAST_FROM_BYTEARRAY
    -DQT_STRICT_ITERATORS
    -DQT_USE_FAST_CONCATENATION
    -DQT_USE_FAST_OPERATOR_PLUS
)

find_package(Qt5 REQUIRED COMPONENTS Core Widgets OpenGL Concurrent)

find_package(KF5 REQUIRED COMPONENTS CoreAddons I18n XmlGui ConfigWidgets Archive KIO)

find_package(OpenGL REQUIRED)

if (NOT OPENGL_GLU_FOUND)
  message(FATAL_ERROR "Can't find GLU library.")
endif ()

feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)

set(kraview_SRCS
    src/main.cxx
    src/KraView.cxx
    src/NetpaneWidget.cxx
    src/InfoDlg.cxx
    src/Net.cxx
    src/NetData.cxx
    src/NetSequence.cxx
    src/Netpane.cxx
)

add_executable(kraview ${kraview_SRCS})

include_directories(${OPENGL_INCLUDE_DIR})

target_link_libraries(kraview
    Qt5::Widgets
    Qt5::OpenGL
    Qt5::Concurrent
    KF5::CoreAddons
    KF5::I18n
    KF5::XmlGui
    KF5::ConfigWidgets
    KF5::KIOCore
    KF5::Archive
    ${OPENGL_LIBRARIES}
)

install(TARGETS kraview  ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES src/kraviewui.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/kraview)

add_subdirectory(translations)
