-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
185 lines (153 loc) · 5.11 KB
/
CMakeLists.txt
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# Set the name and the supported language of the project
project(gjitenkai C)
# Set the minimum version of cmake required to build this project
cmake_minimum_required(VERSION 2.6)
#include directories variables
include(GNUInstallDirs)
#include GSettings macro
include(GSettings.cmake)
#Directories in the source tree
set (SOURCE_SHARE "share")
##directories where to install files.
#These paths must be relative
set(GLIB_SCHEMADIR "glib-2.0/schemas")
set(SCHEMADIR ${CMAKE_INSTALL_DATADIR}/${GLIB_SCHEMADIR})
set(RES_FILES "")
#compiled binary output directory
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
## Set the output binary full path name variable
set(OUTPUT_BIN ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME})
#Make the binary directory
file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
#These path are passed onto config.h.in to be used as preprocessor definitions
if(MINGW)
include(MinGW.cmake)
else()
if(COMPILE_GSETTINGS_AT)
install(
CODE
"message (STATUS \"Compiling GSettings schemas at ${COMPILE_GSETTINGS_AT}\")"
)
compile_schemas_at(${COMPILE_GSETTINGS_AT} ${COMPILE_GSETTINGS_AT})
install(
FILES ${COMPILE_GSETTINGS_AT}/gschemas.compiled
DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas/)
# at install, copy gschema.xml to the glib gschemas directory
install(
FILES ${COMPILE_GSETTINGS_AT}/${PROJECT_NAME}.gschema.xml
DESTINATION ${COMPILE_GSETTINGS_AT})
else()
# at install, copy gschema.xml to the glib gschemas directory
install(
FILES ${SOURCE_SHARE}/${GLIB_SCHEMADIR}/${PROJECT_NAME}.gschema.xml
DESTINATION ${GLIB_PREFIX}/${SCHEMADIR}
)
#at install, compile glib gschemas directory
install(
CODE
"message (STATUS \"Compiling GSettings schemas at ${GLIB_PREFIX}/${SCHEMADIR}\")"
)
compile_schemas_install(${GLIB_PREFIX}/${SCHEMADIR})
endif()
endif()
#generate config.h from config.h.in
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h)
# Use the package PkgConfig to detect GTK+ headers/library files
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
pkg_check_modules(LIBSOUP REQUIRED libsoup-2.4)
# Setup CMake to use GTK+, tell the compiler where to look for headers
# and to the linker where to look for libraries
include_directories(${GTK3_INCLUDE_DIRS} ${LIBSOUP_INCLUDE_DIRS})
link_directories(${GTK3_LIBRARY_DIRS} ${LIBSOUP_LIBRARY_DIRS})
############################################################
# Add other flags to the compiler
add_definitions(${GTK3_CFLAGS_OTHER})
add_definitions(-Wall -fcommon)
# files needed to compile the executable
add_executable(
${PROJECT_NAME}
src/${PROJECT_NAME}/main.c
src/${PROJECT_NAME}/${PROJECT_NAME}.c
src/${PROJECT_NAME}/callbacks.c
src/${PROJECT_NAME}/conf.c
src/${PROJECT_NAME}/dicfile.c
src/${PROJECT_NAME}/dicutil.c
src/${PROJECT_NAME}/error.c
src/worddic/conf.c
src/worddic/worddic.c
src/worddic/preferences.c
src/worddic/inflection.c
src/worddic/callbacks.c
src/worddic/dicentry.c
src/worddic/parser/jmdict.c
src/worddic/parser/jmnedict.c
src/worddic/parser/edict.c
src/worddic/worddic_dicfile.c
src/worddic/dicresult.c
src/worddic/sense.c
src/kanjidic/conf.c
src/kanjidic/kanjidic.c
src/kanjidic/kanjiutils.c
src/kanjidic/callbacks.c
src/kanjidic/kanjifile.c
src/kanjidic/radical_window.c
src/kanjidic/preferences.c
src/kanjidic/kanji_item.c
${RES_FILES} #resouces file for icon
)
# Link the target to the GTK+ libraries
target_link_libraries(${PROJECT_NAME} ${GTK3_LIBRARIES} ${LIBSOUP_LIBRARIES} -lz -lxml2)
if(MINGW)
target_link_libraries(${PROJECT_NAME} -lurlmon -lOleAut32)
endif()
# Compiler flag needed to reach callback functions
set(GCC_COVERAGE_COMPILE_FLAGS "-rdynamic")
## Install UI definitions files
install(
FILES
${PROJECT_NAME}/ui/${PROJECT_NAME}.ui
${PROJECT_NAME}/ui/worddic.ui
${PROJECT_NAME}/ui/kanjidic.ui
DESTINATION
${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/ui/)
## Install locales
###Francais
install(
FILES
po/fr/${PROJECT_NAME}.mo
po/fr/worddic.mo
po/fr/kanjidic.mo
DESTINATION ${CMAKE_INSTALL_LOCALEDIR}/fr/LC_MESSAGES/)
###Japanese
install(
FILES
po/ja/${PROJECT_NAME}.mo
po/ja/worddic.mo
po/ja/kanjidic.mo
DESTINATION ${CMAKE_INSTALL_LOCALEDIR}/ja/LC_MESSAGES/)
install(
FILES
${PROJECT_NAME}/kanjidic.utf8
${PROJECT_NAME}/radkfile.utf8
${PROJECT_NAME}/vconj.xml
${PROJECT_NAME}/style.css
${PROJECT_NAME}/url
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
## Install icon
install(
FILES ${PROJECT_NAME}/kai.png
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
install(
FILES ${PROJECT_NAME}/kai.png
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps/)
#install about menu banner
install(
FILES ${PROJECT_NAME}/${PROJECT_NAME}.png
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
## Install desktop file
install(
FILES ${PROJECT_NAME}.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
## Install programs
install(PROGRAMS ${OUTPUT_BIN} DESTINATION ${CMAKE_INSTALL_BINDIR})