project(libqtdbustest CXX)
cmake_minimum_required(VERSION 2.8.9)

set(API_VERSION 1)
set(ABI_VERSION 1)

set(GETTEXT_PACKAGE libqtdbustest)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")

find_package(PkgConfig REQUIRED)

find_package(Qt5Core REQUIRED)
include_directories(${Qt5Core_INCLUDE_DIRS})

find_package(Qt5DBus COMPONENTS Qt5DBusMacros REQUIRED)
include_directories(${Qt5DBus_INCLUDE_DIRS})

find_package(Qt5Test REQUIRED)
include_directories(${Qt5Test_INCLUDE_DIRS})

set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(DATA_DIR "${CMAKE_SOURCE_DIR}/data")
set(SOURCE_DIR "${CMAKE_SOURCE_DIR}/src")
set(SOURCE_BINARY_DIR "${CMAKE_BINARY_DIR}/src")
include_directories(${SOURCE_DIR})
include_directories(${SOURCE_BINARY_DIR})

include(GNUInstallDirs)
include(Coverage)

# Workaround for libexecdir on debian
if (EXISTS "/etc/debian_version") 
  set(CMAKE_INSTALL_LIBEXECDIR ${CMAKE_INSTALL_LIBDIR})
  set(CMAKE_INSTALL_FULL_LIBEXECDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBEXECDIR}")
endif()

set(LOCALE_DIR "${CMAKE_INSTALL_FULL_DATADIR}/locale")
set(DBUS_SYSTEM_CONFIG_FILE "${CMAKE_INSTALL_FULL_DATADIR}/libqtdbustest/system.conf")
set(DBUS_SESSION_CONFIG_FILE "${CMAKE_INSTALL_FULL_DATADIR}/libqtdbustest/session.conf")
set(QTDBUSTEST_WATCHDOG_BIN "${CMAKE_INSTALL_FULL_LIBEXECDIR}/libqtdbustest/watchdog")

add_definitions(
	-std=c++11
	-fno-permissive
	-pedantic
	-Wall
	-Wextra
)

#set(DOXYFILE_SOURCE_DIR "include")
#set(DOXYFILE_EXTRA_SOURCES "doc")
#include(UseDoxygen)
#if(DOXYGEN_FOUND AND BUILD_DOXYGEN)
#	install(
#		DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html
#		DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/libusermetrics-doc/
#	)
#endif()

configure_file(
	"${SOURCE_DIR}/libqtdbustest/config.h.in"
	"${SOURCE_BINARY_DIR}/libqtdbustest/config.h"
)


#add_subdirectory("po")
add_subdirectory("src")
add_subdirectory("data")

enable_testing()
add_subdirectory(tests)

ADD_CUSTOM_TARGET(
	check
	${CMAKE_CTEST_COMMAND} --force-new-ctest-process --output-on-failure
)
