forked from bibletime/bibletime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
267 lines (227 loc) · 9.77 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
PROJECT(bibletime CXX C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9)
IF("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
MESSAGE(FATAL_ERROR "You probably didn't mean to run CMake from this directory. Now you have all messed up! You'd better delete CMakeFiles/ and CMakeCache.txt or things will break!")
ENDIF()
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
################################################################################
# BibleTime version
################################################################################
# NOTICE! The version number must only be changed during the release procedures
# A N D N O T during development or bug-fixing. This guarantees that all
# versions of BibleTime between OLDVERSION and NEXTVERSION have version strings
# in the form of OLDVERSION+githash where githash is the git commit hash ID.
#
# Note: for pre-#.#.0 versions, use the following suffixes:
# _dev if pre-beta1
# _beta1 if post-beta1
# _beta2 if post-beta2
# _rc1 if post-rc1
# _rc2 if post-rc2
# For post-full-release versions, no suffix is used.
SET(BT_VERSION_MAJOR "2")
SET(BT_VERSION_MINOR "10")
SET(BT_VERSION_PATCH "0_rc1")
#SET(BT_VERSION_BUILD "") # Temporarily uncomment this line for release procedures
# Determine build, if needed:
IF(NOT (DEFINED BT_VERSION_BUILD))
FIND_PACKAGE(Git)
IF(NOT GIT_FOUND)
FIND_PROGRAM(GIT_EXECUTABLE NAMES git)
IF(GIT_EXECUTABLE)
SET(GIT_FOUND TRUE)
ENDIF()
ENDIF()
IF(GIT_FOUND)
FUNCTION(BtGitRevision out)
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
ERROR_QUIET
RESULT_VARIABLE resVar
OUTPUT_VARIABLE outVar
OUTPUT_STRIP_TRAILING_WHITESPACE)
IF(${resVar} EQUAL 0)
STRING(TOLOWER "${outVar}" hashCandidate)
STRING(REGEX MATCH "^[0123456789abcdef]+$" hasHash "${hashCandidate}")
IF(hasHash)
STRING(LENGTH "${hashCandidate}" hashLength)
IF(hashLength EQUAL 40)
SET(${out} "${hashCandidate}" PARENT_SCOPE)
ENDIF()
ENDIF()
ENDIF()
ENDFUNCTION()
BtGitRevision(BibleTimeGitRevision)
IF(DEFINED BibleTimeGitRevision)
SET(BT_VERSION_BUILD "+${BibleTimeGitRevision}")
ENDIF()
ENDIF()
ENDIF()
SET(BT_VERSION_FULL "${BT_VERSION_MAJOR}.${BT_VERSION_MINOR}.${BT_VERSION_PATCH}${BT_VERSION_BUILD}")
MESSAGE(STATUS "Setting up build environment for BibleTime version ${BT_VERSION_FULL}")
ADD_DEFINITIONS(-DBT_VERSION="${BT_VERSION_FULL}")
# Define debug flags
IF(NOT (CMAKE_BUILD_TYPE STREQUAL "Release"))
SET(CMAKE_BUILD_TYPE "Debug")
ADD_DEFINITIONS("-DBT_DEBUG")
ELSE()
ADD_DEFINITIONS("-DBT_NO_DEBUG" "-DNDEBUG" "-DQT_NO_DEBUG")
ENDIF()
#Non-English locales to be processed and installed for handbook and howto
#WARNING: If you modify HANDBOOK_LOCALE_LANGS or HOWTO_LOCALE_LANGS,
#also modify the po4a conf files in cmake/docs/ to make sure all languages are processed.
LIST(APPEND HANDBOOK_LOCALE_LANGS ar cs de es fi fr hu it lt nl pt_BR)
LIST(APPEND HOWTO_LOCALE_LANGS ar bg cs da de es fi fr it hu ko lt nl pt_BR ru)
# Automatically link Qt executables to qtmain target on Windows
IF(MSVC)
cmake_policy(SET CMP0020 NEW)
ENDIF()
# SET INSTALLATION PATHS
IF(APPLE)
SET(BT_DESTINATION "../MacOS")
SET(BT_SHARE_PATH "../share")
ELSE()
SET(BT_DESTINATION "bin")
SET(BT_SHARE_PATH "share")
ENDIF()
FIND_PACKAGE(Qt5Core REQUIRED)
FIND_PACKAGE(Qt5LinguistTools REQUIRED)
FIND_PACKAGE(Qt5Gui REQUIRED)
FIND_PACKAGE(Qt5Widgets REQUIRED)
FIND_PACKAGE(CLucene REQUIRED)
FIND_PACKAGE(Sword 1.7.0 REQUIRED)
# Define $bibletime_SOURCES
INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/BTSourceFileList.cmake")
#
# The actual build options
#
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR} #for .h files generated from .ui
${CMAKE_CURRENT_SOURCE_DIR}/src # so that include paths like "frontend/..." work
${CLucene_INCLUDE_DIR} #CLucene headers
${CLucene_LIBRARY_DIR} #CLucene/clucene-config.h
${Sword_INCLUDE_DIRS}
)
# Macros used by BTUITranslationLink.cmake amd BTUITranslation.cmake
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/BTTranslationMacros.cmake")
# Define rules to generate translation files and link them to
# the executable using a qrc file.
IF (${bibletime_LINK_TRANSLATION_FILES})
INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/BTUITranslationLink.cmake")
ENDIF()
#This must come before the target definition!
LINK_DIRECTORIES(${CLucene_LIBRARY_DIR})
IF(MSVC)
ADD_EXECUTABLE("bibletime" WIN32 ${common_bibletime_SOURCES})
ELSE()
ADD_EXECUTABLE("bibletime" ${common_bibletime_SOURCES})
ENDIF()
IF(${BIBLETIME_FRONTEND} STREQUAL "MOBILE")
SET_TARGET_PROPERTIES("bibletime" PROPERTIES OUTPUT_NAME "btm")
ELSEIF(APPLE)
SET_TARGET_PROPERTIES("bibletime" PROPERTIES OUTPUT_NAME "BibleTime")
ELSE()
SET_TARGET_PROPERTIES("bibletime" PROPERTIES OUTPUT_NAME "bibletime")
ENDIF()
# Define rules to generate and install translation files
IF (NOT ${bibletime_LINK_TRANSLATION_FILES})
INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/BTUITranslation.cmake")
ENDIF()
TARGET_LINK_LIBRARIES("bibletime"
${CLucene_LIBRARY}
${Sword_LDFLAGS}
)
IF(${BIBLETIME_FRONTEND} STREQUAL "MOBILE")
qt5_use_modules("bibletime" Widgets Qml Quick Xml Network PrintSupport Svg)
ELSE()
qt5_use_modules("bibletime" Widgets WebKit WebKitWidgets Xml Network PrintSupport Svg)
ENDIF()
IF(${BIBLETIME_FRONTEND} STREQUAL "MOBILE")
ADD_DEFINITIONS("-DBT_MOBILE")
ENDIF()
SET(BibleTime_CFLAGS "-Wall -Wextra -std=c++11 -O2")
SET(BibleTime_LDFLAGS "")
IF(MSVC)
SET(CMAKE_CXX_FLAGS_RELEASE "-DSWUSINGDLL /MD /Zc:wchar_t- /W1 /D_UNICODE /DUNICODE /Zc:wchar_t")
SET(CMAKE_CXX_FLAGS_DEBUG "-DSWUSINGDLL /MDd /Zc:wchar_t- /W1 /D_UNICODE /DUNICODE /Zc:wchar_t /Od")
SET(BibleTime_LDFLAGS "${BibleTime_LDFLAGS} /SUBSYSTEM:WINDOWS")
ELSE()
SET(BibleTime_CFLAGS "${BibleTime_CFLAGS} -fPIE -fexceptions")
SET(CMAKE_CXX_FLAGS_RELEASE "")
SET(CMAKE_CXX_FLAGS_DEBUG "-ggdb")
IF(APPLE)
# enable support MacOS 10.5+
SET(T "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/")
SET(BibleTime_CFLAGS "${BibleTime_CFLAGS} -mmacosx-version-min=10.7 -stdlib=libc++ -isysroot ${T}")
SET(BibleTime_LDFLAGS "${BibleTime_LDFLAGS} -mmacosx-version-min=10.7 -stdlib=libc++ -isysroot ${T} -F /Library/Frameworks/")
UNSET(T)
ENDIF()
ENDIF()
SET_TARGET_PROPERTIES("bibletime" PROPERTIES
COMPILE_FLAGS "${Sword_CFLAGS_OTHER} ${BibleTime_CFLAGS}"
LINK_FLAGS "${BibleTime_LDFLAGS}")
# Install files
#
INSTALL(TARGETS "bibletime" DESTINATION "${BT_DESTINATION}")
FILE(GLOB INSTALL_ICONS_LIST "${CMAKE_CURRENT_SOURCE_DIR}/pics/icons/*.svg")
INSTALL(FILES ${INSTALL_ICONS_LIST}
DESTINATION "${BT_SHARE_PATH}/bibletime/icons/")
FILE(GLOB INSTALL_ICONS_LIST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pics/icons/bibletime.png")
INSTALL(FILES ${INSTALL_ICONS_LIST_PNG}
DESTINATION "${BT_SHARE_PATH}/bibletime/icons/")
FILE(GLOB INSTALL_TMPL_LIST
${CMAKE_CURRENT_SOURCE_DIR}/src/display-templates/*.css
${CMAKE_CURRENT_SOURCE_DIR}/src/display-templates/Basic.tmpl
${CMAKE_CURRENT_SOURCE_DIR}/src/display-templates/basic_template.txt)
INSTALL(FILES ${INSTALL_TMPL_LIST}
DESTINATION "${BT_SHARE_PATH}/bibletime/display-templates/")
INSTALL(FILES "src/frontend/display/bthtml.js"
DESTINATION "${BT_SHARE_PATH}/bibletime/javascript/")
INSTALL(FILES "docs/license.html"
DESTINATION "${BT_SHARE_PATH}/bibletime/license/")
INSTALL(FILES ${bibletime_QML_FILES} DESTINATION "${BT_SHARE_PATH}/qml/")
INSTALL(FILES "pics/startuplogo.png" "pics/startuplogo_christmas.png"
"pics/startuplogo_easter.jpg"
DESTINATION "${BT_SHARE_PATH}/bibletime/pics/")
#
# Platform specific installation
#
# Linux: application icon and desktop file:
INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/pics/icons/bibletime.svg"
DESTINATION "${BT_SHARE_PATH}/icons/")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/platforms/linux/bibletime.desktop.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/bibletime.desktop" @ONLY)
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/bibletime.desktop"
DESTINATION "${BT_SHARE_PATH}/applications/")
IF(MSVC)
# sword locale information
FILE(GLOB INSTALL_SWORD_LOCALE_LIST "${Sword_INCLUDE_DIRS}/../locales.d/*")
INSTALL(FILES ${INSTALL_SWORD_LOCALE_LIST}
DESTINATION "${BT_SHARE_PATH}/sword/locales.d/")
# install pdb file for debugging purposes
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(bibletime_PDB "${bibletime_BINARY_DIR}/Debug/bibletime.pdb")
INSTALL(FILES "${bibletime_PDB}" DESTINATION "${BT_DESTINATION}")
ENDIF()
ENDIF()
IF(APPLE)
# sword locale information, needed for DMG image
FILE(GLOB INSTALL_SWORD_LOCALE_LIST "${Sword_INCLUDE_DIRS}/../../share/sword/locales.d/*")
INSTALL(FILES ${INSTALL_SWORD_LOCALE_LIST}
DESTINATION "${BT_SHARE_PATH}/sword/locales.d/")
ENDIF()
INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/BTDocumentation.cmake")
IF(WIN32 AND NOT UNIX)
INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/BTBinaryPackageWindows.cmake")
ENDIF()
IF(APPLE)
INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/BTBinaryPackageMacOS.cmake")
ENDIF()
######################################################
# "make uninstall" target; see http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
#
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
######################################################