cmake_minimum_required(VERSION 3.5)

project(lomiri-ui-extras VERSION 0.7.0)

# Standard install paths
include(GNUInstallDirs)

option(ENABLE_TESTS "Build test programs" ON)
option(ENABLE_WERROR "Enable -Werror" OFF)
option(ENABLE_QT6 "Enable Qt6 build" OFF)

add_compile_options(-Wall -Wextra -pedantic)
if (ENABLE_WERROR)
    add_compile_options(-Werror)
endif()

# enable QML debugging
if(CMAKE_BUILD_TYPE MATCHES DEBUG OR CMAKE_BUILD_TYPE MATCHES "Debug")
    add_definitions(-DQT_QML_DEBUG)
endif()

if (ENABLE_QT6)
    find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core Qml ShaderTools)
else()
    find_package(QT NAMES Qt5 REQUIRED COMPONENTS Core Qml)
endif()

find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets Quick DBus Xml Test)

add_definitions(-DQT_NO_KEYWORDS)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

# make non compiled files visible in qtcreator
file(GLOB_RECURSE NON_COMPILED_FILES *.qml *.js *.py *.svg *.png *.in *.json *.desktop *.pot qmldir)
add_custom_target(NON_COMPILED_TARGET ALL SOURCES ${NON_COMPILED_FILES})

# for dh_translations to extract the domain
# (regarding syntax consistency, see http://pad.lv/1181187)
set (GETTEXT_PACKAGE "lomiri-ui-extras")

add_subdirectory(modules)

if(ENABLE_TESTS)
    enable_testing()
    add_subdirectory(tests)
endif()
add_subdirectory(po)
