cmake_minimum_required(VERSION 3.21.1)

project(gallery VERSION 1.0.0 LANGUAGES CXX)

# generate compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_subdirectory(../ ${CMAKE_BINARY_DIR}/designsystem)

find_package(Qt6 6.8 REQUIRED COMPONENTS 
    Quick
    Core
    QuickControls2
)

qt_standard_project_setup(REQUIRES 6.8)

set(SOURCES main.cpp)
qt_add_executable(Gallery MACOSX_BUNDLE ${SOURCES})

qt_add_qml_module(Gallery
    URI Gallery
    VERSION 1.0
    RESOURCE_PREFIX /live.flowy/imports
    QML_FILES
        Main.qml
    RESOURCES
)

# including every subdirectory because : https://bugreports.qt.io/browse/QTBUG-101146
target_include_directories(Gallery PRIVATE src)

target_link_libraries(Gallery
    PRIVATE 
      Qt6::Quick 
      Qt6::Core
      designsystemplugin
)

include(GNUInstallDirs)
install(TARGETS Gallery
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
