aboutsummaryrefslogtreecommitdiff
path: root/src/CMakeLists.txt
blob: 9e537c8f343eabb34a0f69fc5108472471ecb6ef (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
set (SERVICE_LIB "ayatanaindicatorpowerservice")
set (SERVICE_EXEC "aytana-indicator-power-service")

add_definitions(-DG_LOG_DOMAIN="Ayatana-Indicator-Power")

# handwritten sources
set(SERVICE_MANUAL_SOURCES
    brightness.c
    device-provider-mock.c
    device-provider-upower.c
    device-provider.c
    device.c
    notifier.c
    testing.c
    service.c)

# generated sources
include(GdbusCodegen)
set(SERVICE_GENERATED_SOURCES)
add_gdbus_codegen_with_namespace(SERVICE_GENERATED_SOURCES dbus-powerd
                                 org.ayatana
                                 Dbus
                                 ${CMAKE_SOURCE_DIR}/src/org.ayatana.powerd.xml)
add_gdbus_codegen_with_namespace(SERVICE_GENERATED_SOURCES dbus-battery
                                 org.ayatana.indicator.power
                                 Dbus
                                 ${CMAKE_SOURCE_DIR}/data/org.ayatana.indicator.power.Battery.xml)
add_gdbus_codegen_with_namespace(SERVICE_GENERATED_SOURCES dbus-testing
                                 org.ayatana.indicator.power
                                 Dbus
                                 ${CMAKE_SOURCE_DIR}/data/org.ayatana.indicator.power.Testing.xml)
# add the bin dir to our include path so the code can find the generated header files
include_directories(${CMAKE_CURRENT_BINARY_DIR})


# add warnings/coverage info on handwritten files
# but not the autogenerated ones...
set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-bad-function-cast") # g_clear_object()
set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-used-but-marked-unused") # G_ADD_PRIVATE
set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-disabled-macro-expansion") # G_DEFINE_TYPE
set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-assign-enum") # GParamFlags
set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-switch-enum")
set_source_files_properties(${SERVICE_MANUAL_SOURCES}
                            PROPERTIES COMPILE_FLAGS "${C_WARNING_ARGS} ${GCOV_FLAGS} -g -std=c99")

# the service library for tests to link against (basically, everything except main())
add_library(${SERVICE_LIB} STATIC ${SERVICE_MANUAL_SOURCES} ${SERVICE_GENERATED_SOURCES})
include_directories(${CMAKE_SOURCE_DIR})
link_directories(${SERVICE_DEPS_LIBRARY_DIRS})

# the executable: lib + main()
add_executable (${SERVICE_EXEC} main.c)
set_source_files_properties(${SERVICE_SOURCES} main.c PROPERTIES COMPILE_FLAGS "${C_WARNING_ARGS} -g -std=c99")
target_link_libraries (${SERVICE_EXEC} ${SERVICE_LIB} ${SERVICE_DEPS_LIBRARIES} ${GCOV_LIBS})
install (TARGETS ${SERVICE_EXEC} RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_PKGLIBEXECDIR})