aboutsummaryrefslogtreecommitdiff
path: root/src/CMakeLists.txt
blob: d6c6647687cae28c032572f013f4415412bb4410 (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
# 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_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libayatana-indicator3-0.4/libayatana-indicator")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/indicator-image-helper.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libayatana-indicator3-0.4/libayatana-indicator")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/indicator-ng.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libayatana-indicator3-0.4/libayatana-indicator")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/indicator-object.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libayatana-indicator3-0.4/libayatana-indicator")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/indicator-service-manager.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libayatana-indicator3-0.4/libayatana-indicator")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/indicator-service.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libayatana-indicator3-0.4/libayatana-indicator")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/indicator.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_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
    indicator-ng.h
)

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

)

# 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})

# libayatana-indicator3.so

set_source_files_properties(${SOURCES} PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS})
add_library("ayatana-indicator3" SHARED ${SOURCES})
set_target_properties("ayatana-indicator3" PROPERTIES VERSION 7.0.0 SOVERSION 7)
target_compile_definitions("ayatana-indicator3" PUBLIC DG_LOG_DOMAIN="libayatana-indicator")
target_include_directories("ayatana-indicator3" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS})
target_include_directories("ayatana-indicator3" PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories("ayatana-indicator3" PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries("ayatana-indicator3" ${PROJECT_DEPS_LIBRARIES})
add_dependencies("ayatana-indicator3" "src-generated")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libayatana-indicator3.so" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libayatana-indicator3.so.7" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libayatana-indicator3.so.7.0.0" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")