cmake_minimum_required(VERSION 3.20)

project(FWS-DeskManager VERSION 0.3.1 LANGUAGES CXX)

if(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
    message(FATAL_ERROR "FWS-DeskManager targets Linux with systemd-logind.")
endif()

find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK4 REQUIRED IMPORTED_TARGET gtk4)

add_library(fws-core STATIC
    src/process.cpp
    src/session-catalog.cpp
    src/session-switcher.cpp
    src/session-launcher.cpp
    src/desktop-catalog.cpp
)
target_include_directories(fws-core PUBLIC src)
target_compile_features(fws-core PUBLIC cxx_std_17)
target_compile_options(fws-core PRIVATE -Wall -Wextra -Wpedantic)

# Single executable: the GUI, plus the privileged launch reachable only through
# pkexec (--privileged-launch).
add_executable(fws-deskmanager src/gui.cpp)
target_link_libraries(fws-deskmanager PRIVATE fws-core PkgConfig::GTK4)
target_compile_options(fws-deskmanager PRIVATE -Wall -Wextra -Wpedantic)

install(TARGETS fws-deskmanager RUNTIME DESTINATION bin)

# Desktop integration. The license file is installed as well: Arch expects it
# under share/licenses/<pkgname> and pacman refuses a GPL package without it.
install(FILES packaging/fws-deskmanager.desktop DESTINATION share/applications)
install(FILES packaging/ch.laxacube.fws.deskmanager.metainfo.xml DESTINATION share/metainfo)
install(FILES packaging/fws-deskmanager.svg DESTINATION share/icons/hicolor/scalable/apps)
install(FILES LICENSE DESTINATION share/licenses/fws-deskmanager)
