#-----------------------------------------------------------------------------
#
# Copyright (C) 2022 Bjarne von Horn <vh@igh.de>
#               2022 Florian Pose <fp@igh.de>
#
# This file is part of the QtPdCom library.
#
# The QtPdCom library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# The QtPdCom library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
# License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with the QtPdCom Library. If not, see <http://www.gnu.org/licenses/>.
#
#-----------------------------------------------------------------------------

cmake_minimum_required(VERSION 3.10)

project(qtpdcomexample)

option(USE_QT6 "Use Qt6 instead of Qt5" OFF)
option(PUT_QT_MAJOR_INTO_LIBNAME "Put Qt Major Version into Library Name" OFF)

if(USE_QT6)
    set(Qt Qt6)
else()
    set(Qt Qt5)
endif()

if (PUT_QT_MAJOR_INTO_LIBNAME)
    set(LIBNAME "${Qt}PdCom1")
else()
    set(LIBNAME "QtPdCom1")
endif()

# load Qt
find_package(${Qt} REQUIRED COMPONENTS Gui Network Widgets Xml)

# load QtPdCom
if (NOT TARGET "EtherLab::${LIBNAME}")
    find_package("${LIBNAME}" REQUIRED)
endif()

add_executable(${PROJECT_NAME}
    MainWindow.ui
    MainWindow.h
    MainWindow.cpp
    main.cpp
    example.qrc
)

# enable moc, uic and rcc
set_target_properties(${PROJECT_NAME} PROPERTIES
    AUTOUIC 1
    AUTOMOC 1
    AUTORCC 1
)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14)

# link against Qt and QtPdCom
target_link_libraries(${PROJECT_NAME} PUBLIC
    EtherLab::${LIBNAME}
    ${Qt}::Gui
    ${Qt}::Widgets
)
