cmake_minimum_required(VERSION 3.5.0)
project (lomiri-session VERSION 0.3 LANGUAGES NONE)

option(ENABLE_TOUCH_SESSION "Include support for touch session and lightdm integration" ON)
option (ENABLE_UBUNTU_ACCOUNTSSERVICE "Build with Ubuntu's fork of accountsservice" OFF)

# CMake BOOL -> value testable in bash
set(BASH_ENABLE_UBUNTU_ACCOUNTSSERVICE 0)
if(ENABLE_UBUNTU_ACCOUNTSSERVICE)
	set(BASH_ENABLE_UBUNTU_ACCOUNTSSERVICE 1)
endif()

find_program(LOMIRI_BIN lomiri)
if(NOT LOMIRI_BIN)
	message(WARNING "make sure you have the lomiri shell installed at runtime!")
endif()
find_program(INOTIFYWAIT_BIN inotifywait)
if(NOT INOTIFYWAIT_BIN)
	message(WARNING "inotifywait binary not found, it's required for X11 support!")
endif()

include(GNUInstallDirs)
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/lomiri-session.in" "${CMAKE_CURRENT_BINARY_DIR}/lomiri-session" @ONLY)
install (PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/lomiri-session" DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")

find_package(PkgConfig)
pkg_check_modules(PC_SYSTEMD libsystemd)

if(PC_SYSTEMD_FOUND)
	find_program(DUAE_BIN dbus-update-activation-environment REQUIRED)
	add_subdirectory(systemd)

	if(ENABLE_TOUCH_SESSION)
		find_program(LSC_BIN lomiri-system-compositor REQUIRED)
		find_program(LSCS_BIN lomiri-system-compositor-spinner REQUIRED)

		add_subdirectory(touch)
	endif()
elseif(ENABLE_TOUCH_SESSION)
	set(ENABLE_TOUCH_SESSION OFF)
	message(WARNING "Support for touch session was enabled but it depends on systemd which wasn't found!")
endif()

add_subdirectory(desktop)
