# Copyright (C) 2020 Uniontech Technology Co., Ltd.
#
# Author:     xinbo wang <wangxinbo@uniontech.com>
#
# Maintainer: xinbo wang <wangxinbo@uniontech.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

cmake_minimum_required(VERSION 3.13)

project(prohibitscreenshot)

option(USE_32BITS "Compile for 32bits processors(linux only)" OFF)

if(USE_32BITS)
    message(STATUS "using 32bits")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
else()
endif(USE_32BITS)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/dbus/prohibitscreenshot/cmake/Modules")

# Required to use std threads
find_package(Threads REQUIRED)
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5DBus REQUIRED)
find_package(PolkitQt5-1)
find_package(X11)
find_package(PkgConfig REQUIRED)
find_package(KF5Wayland REQUIRED)
pkg_search_module(DBUSGLIB REQUIRED dbus-glib-1)

include_directories(${PROJECT_SOURCE_DIR})
include_directories(${DBUSGLIB_INCLUDE_DIRS})

set(SOURCES_PRELOAD_FILES
    dbusmanager.cpp
    window-system/x11.cpp
    utils/string.cpp
    utils/paths.cpp
    config/config.cpp
    config/xml-config-loader.cpp
    prohibitedwindowdecision.cpp
    prohibitscreenshot.cpp
)

install(
    FILES
    ace-config/entity/prohibitscreenshot.json
    DESTINATION
    "/usr/share/uos/usec/entity.d"
)

install(
    FILES
    ace-config/mode/prohibitscreenshot.json
    DESTINATION
    "/usr/share/uos/usec/mode.d"
)

install(FILES ${PROJECT_SOURCE_DIR}/installation/prohibitscreenshotDbus.conf DESTINATION "/usr/share/prohibitscreenshot")
install(FILES ${PROJECT_SOURCE_DIR}/installation/sessionRemoved.sh DESTINATION "/etc/xdg/autostop" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ)

add_subdirectory(dbus_service)
