cmake_minimum_required(VERSION 3.16)

project(adhd VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Set minimum macOS version
# Qt 6.8.6 requires macOS 11.0 (Big Sur) minimum
if(APPLE)
    set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "Minimum macOS version")
endif()

find_package(Qt6 REQUIRED COMPONENTS
        Core
        Gui
        Widgets
)

qt_standard_project_setup()

qt_add_executable(adhd
  main.cpp
  mainwindow.cpp
  mainwindow.h
  service.cpp
  service.h
  mainwindow.ui
  sessionslistmodel.h
  sessionslistmodel.cpp
  sessionitemdelegate.h
  sessionitemdelegate.cpp
  createsessiondialog.h
  createsessiondialog.cpp
  createsessiondialog.ui
  focusoverlay.h
  focusoverlay.cpp
  focusoverlay.ui
  endsessiondialog.h
  endsessiondialog.cpp
  endsessiondialog.ui
  namegenerator.h
  namegenerator.cpp
)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(adhd PROPERTIES
        #    MACOSX_BUNDLE_GUI_IDENTIFIER com.example.adhd
        MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
        MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
        MACOSX_BUNDLE TRUE
        WIN32_EXECUTABLE $<NOT:$<CONFIG:Debug>>
)

target_link_libraries(adhd
  PRIVATE
    Qt6::Core
    Qt6::Gui
    Qt6::Widgets
)

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

qt_generate_deploy_app_script(
        TARGET adhd
        OUTPUT_SCRIPT deploy_script
        NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
