aboutsummaryrefslogtreecommitdiff
path: root/src/CMakeLists.txt
blob: 9a63eb8d265d06210a046ecfd99b134924046619 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# indicator-desktop-shortcuts.h
# indicator-image-helper.h
# indicator-ng.h
# indicator-object.h
# indicator-service-manager.h
# indicator-service.h
# indicator.h

install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/indicator-desktop-shortcuts.h" DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/libayatana-indicator3-0.4/libayatana-indicator")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/indicator-image-helper.h" DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/libayatana-indicator3-0.4/libayatana-indicator")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/indicator-ng.h" DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/libayatana-indicator3-0.4/libayatana-indicator")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/indicator-object.h" DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/libayatana-indicator3-0.4/libayatana-indicator")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/indicator-service-manager.h" DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/libayatana-indicator3-0.4/libayatana-indicator")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/indicator-service.h" DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/libayatana-indicator3-0.4/libayatana-indicator")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/indicator.h" DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/libayatana-indicator3-0.4/libayatana-indicator")

set(HEADERS
    indicator.h
    indicator-desktop-shortcuts.h
    indicator-image-helper.h
    indicator-object.h
    indicator-service.h
    indicator-service-manager.h
)

if (FLAVOUR_GTK3 AND ENABLE_IDO)
    set(HEADERS
        ${HEADERS}
        indicator-ng.h
    )
endif()

set(SOURCES
    gen-indicator-service.xml.c
    indicator-desktop-shortcuts.c
    indicator-image-helper.c
    indicator-object.c
    indicator-object-enum-types.c
    indicator-object-marshal.c
    indicator-service.c
    indicator-service-manager.c
)

if (FLAVOUR_GTK3 AND ENABLE_IDO)
    set(SOURCES
        ${SOURCES}
        indicator-ng.c
    )
endif()

# indicator-object-enum-types.h

find_program(GLIB_MKENUMS glib-mkenums)

add_custom_command(
    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/indicator-object-enum-types.h"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    COMMAND
    ${GLIB_MKENUMS}
    --template indicator-object-enum-types.h.template
    ${HEADERS}
    --output="${CMAKE_CURRENT_BINARY_DIR}/indicator-object-enum-types.h"
)

# indicator-object-enum-types.c

add_custom_command(
    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/indicator-object-enum-types.c"
    DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/indicator-object-enum-types.h"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    COMMAND
    ${GLIB_MKENUMS}
    --template indicator-object-enum-types.c.template
    ${HEADERS}
    --output="${CMAKE_CURRENT_BINARY_DIR}/indicator-object-enum-types.c"
)

find_program(GLIB_GENMARSHAL glib-genmarshal)

# indicator-object-marshal.h

add_custom_command(
    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/indicator-object-marshal.h"
    DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/indicator-object-enum-types.c"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    COMMAND
    ${GLIB_GENMARSHAL}
    --prefix=_indicator_object_marshal
    --header indicator-object-marshal.list
    --quiet
    --output="${CMAKE_CURRENT_BINARY_DIR}/indicator-object-marshal.h"
)

# indicator-object-marshal.c

add_custom_command(
    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/indicator-object-marshal.c"
    DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/indicator-object-marshal.h"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    COMMAND
    ${GLIB_GENMARSHAL}
    --prefix=_indicator_object_marshal
    --body indicator-object-marshal.list
    --include-header=indicator-object-marshal.h
    --quiet
    --output="${CMAKE_CURRENT_BINARY_DIR}/indicator-object-marshal.c"
)

add_custom_target("src-generated" DEPENDS "indicator-object-marshal.c")

# gen-indicator-service.xml.h

file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/gen-indicator-service.xml.h" "extern const char * _indicator_service;")

# gen-indicator-service.xml.c

file(READ "${CMAKE_CURRENT_SOURCE_DIR}/indicator-service.xml" GEN_INDICATOR_SERVICE_XML_C)
string(REPLACE "\"" "\\\"" GEN_INDICATOR_SERVICE_XML_C ${GEN_INDICATOR_SERVICE_XML_C})
string(REPLACE "\n" "\\n\"\n\"" GEN_INDICATOR_SERVICE_XML_C ${GEN_INDICATOR_SERVICE_XML_C})
string(REGEX REPLACE "\n\"$" "\n" GEN_INDICATOR_SERVICE_XML_C ${GEN_INDICATOR_SERVICE_XML_C})
string(PREPEND GEN_INDICATOR_SERVICE_XML_C "const char * _indicator_service = \n\"")
string(APPEND GEN_INDICATOR_SERVICE_XML_C "\;")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/gen-indicator-service.xml.c" ${GEN_INDICATOR_SERVICE_XML_C})


if (FLAVOUR_GTK3)
    # libayatana-indicator3.so
    set (ayatana_indicator_gtkver "ayatana-indicator3")
else()
    # libayatana-indicator.so
    set (ayatana_indicator_gtkver "ayatana-indicator")
endif()

# libayatana-indicator{,3}.so

set_source_files_properties(${SOURCES} PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS})
add_library("${ayatana_indicator_gtkver}" SHARED ${SOURCES})
set_target_properties("${ayatana_indicator_gtkver}" PROPERTIES VERSION ${ABI_VERSION}.0.0 SOVERSION ${ABI_VERSION})
target_compile_definitions("${ayatana_indicator_gtkver}" PUBLIC DG_LOG_DOMAIN="libayatana-indicator")
target_include_directories("${ayatana_indicator_gtkver}" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS})
target_include_directories("${ayatana_indicator_gtkver}" PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories("${ayatana_indicator_gtkver}" PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries("${ayatana_indicator_gtkver}" ${PROJECT_DEPS_LIBRARIES} ${EXTRA_LIBS})
add_dependencies("${ayatana_indicator_gtkver}" "src-generated")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/lib${ayatana_indicator_gtkver}.so" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/lib${ayatana_indicator_gtkver}.so.${ABI_VERSION}" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/lib${ayatana_indicator_gtkver}.so.${ABI_VERSION}.0.0" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")