aboutsummaryrefslogtreecommitdiff
path: root/tests/CMakeLists.txt
blob: 1e81bc29a745ce3f7e5b6712cee99eadacd965aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
find_package(GMock)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-pie")

# build the necessary schemas
set_directory_properties (PROPERTIES
                          ADDITIONAL_MAKE_CLEAN_FILES gschemas.compiled)
set_source_files_properties (gschemas.compiled GENERATED)

# GSettings:
# compile the schemas our tests use (ayatana-indicator-session's, lockdown, media-keys)
# into a gschemas.compiled file in this directory, and help the tests to find
# that file by setting -DSCHEMA_DIR
set (SCHEMA_DIR ${CMAKE_CURRENT_BINARY_DIR})
add_definitions(-DSCHEMA_DIR="${SCHEMA_DIR}")
execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas
                 OUTPUT_VARIABLE COMPILE_SCHEMA_EXECUTABLE
                 OUTPUT_STRIP_TRAILING_WHITESPACE)
add_custom_command (OUTPUT gschemas.compiled
                    DEPENDS ${CMAKE_BINARY_DIR}/data/org.ayatana.indicator.session.gschema.xml
                            ${CMAKE_SOURCE_DIR}/tests/org.ayatana.indicator.session.backendmock.gschema.xml
                            ${CMAKE_SOURCE_DIR}/tests/org.gnome.desktop.lockdown.gschema.xml
                            ${CMAKE_SOURCE_DIR}/tests/org.gnome.settings-daemon.plugins.media-keys.gschema.xml
                    COMMAND cp -f ${CMAKE_BINARY_DIR}/data/*gschema.xml ${SCHEMA_DIR}
                    COMMAND if [ \"x${CMAKE_SOURCE_DIR}/tests\" != \"x${SCHEMA_DIR}\" ]; then cp -f \"${CMAKE_SOURCE_DIR}/tests/\"*gschema.xml \"${SCHEMA_DIR}\"\; fi
                    COMMAND ${COMPILE_SCHEMA_EXECUTABLE} ${SCHEMA_DIR})

# DBus Activation
configure_file (ayatana-indicator-session.service.in ayatana-indicator-session.service)
add_definitions(-DINDICATOR_SERVICE_DIR="${CMAKE_CURRENT_BINARY_DIR}")

# look for hearder in our src dir, and also in the directories where we autogenerate files...
include_directories (${CMAKE_SOURCE_DIR}/src)
include_directories (${CMAKE_CURRENT_BINARY_DIR} ${SERVICE_INCLUDE_DIRS})

# backendmock
add_library (backendmock STATIC
             backend-mock-actions.c
             backend-mock-actions.h
             backend-mock.c
             backend-mock.h
             backend-mock-guest.c
             backend-mock-guest.h
             backend-mock-users.c
             backend-mock-users.h)

add_custom_target(
            gschemas-compiled ALL DEPENDS gschemas.compiled
)

# test-service
add_executable (test-service
                test-service.cc)
set_target_properties (test-service PROPERTIES COMPILE_FLAGS " -std=c++0x")
add_test (test-service test-service)
add_dependencies (test-service libayatanaindicatorsessionservice backendmock gschemas-compiled)
target_link_libraries (test-service libayatanaindicatorsessionservice backendmock ${SERVICE_LIBRARIES} ${GTEST_LIBRARIES} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARIES})

add_subdirectory (backend-dbus)