cmake_minimum_required(VERSION 3.14)

project(rktwebview LANGUAGES CXX)

set(QT_DEBUG_FIND_PACKAGE ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets WebEngineWidgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets WebEngineWidgets)

add_executable(rktwebview_prg
  main.cpp

  rktwebview_qt.cpp
  rktwebview_qt.h

  webviewqt.h webviewqt.cpp
  webviewwindow.h webviewwindow.cpp

  rktutils.h rktutils.cpp
  command.h command.cpp

  rkt_protocol.h
  rktwebview_types.h
  utils.cpp utils.h

  build_menu_from_json.cpp
  build_menu_from_json.h
)

target_link_libraries(rktwebview_prg PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
target_link_libraries(rktwebview_prg PRIVATE Qt${QT_VERSION_MAJOR}::WebEngineWidgets)

target_compile_definitions(rktwebview_prg PRIVATE RKTWEBVIEW_PRG_EXE)

add_executable(rktwebview_test
  rktwebview_test.cpp
  rkt_protocol.h
)

target_link_libraries(rktwebview_test PRIVATE Qt${QT_VERSION_MAJOR}::Core)

add_dependencies(rktwebview_test rktwebview_prg)
