# AdvancedControllerRemoteCPP - remote control of the AdvancedController from Linux (C++ / Qt 6)
#
# Layout:
#   lib/    static library AdvancedControllerRemote - protocol client (link it into your software)
#   panel/  AdvancedControllerPanel - the virtual front panel (Qt Widgets)
#   tools/  remote_test - console test tool
#
# Build and run:
#   ./build.sh
#   ./run.sh

cmake_minimum_required(VERSION 3.16)

project(AdvancedControllerRemote LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Linux RPATH settings: ensure executables locate libraries in standard/local paths
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib;$ORIGIN/lib;/usr/lib/x86_64-linux-gnu;$ENV{HOME}/.local/lib/x86_64-linux-gnu;$ENV{HOME}/.local/lib")

# Locate Qt6SerialPort if installed in user local directory or custom prefix
if(NOT DEFINED Qt6SerialPort_DIR)
    find_path(Qt6SerialPort_DIR Qt6SerialPortConfig.cmake
        PATHS
            /usr/lib/x86_64-linux-gnu/cmake/Qt6SerialPort
            /usr/lib64/cmake/Qt6SerialPort
            /usr/lib/cmake/Qt6SerialPort
            "$ENV{HOME}/.local/lib/x86_64-linux-gnu/cmake/Qt6SerialPort"
            "$ENV{HOME}/.local/lib/cmake/Qt6SerialPort"
    )
endif()

find_package(Qt6 6.5 REQUIRED COMPONENTS Core Gui Widgets SerialPort)
qt_standard_project_setup()

add_subdirectory(lib)
add_subdirectory(panel)
add_subdirectory(tools)
