forked from Studio3T/robomongo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
274 lines (256 loc) · 13.7 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
267
268
269
270
271
272
273
274
cmake_minimum_required(VERSION 2.8.0)
###
# Settings
#
set(PROJECT_NAME "Robomongo" CACHE STRING "Project Name")
set(PROJECT_NAME_TITLE ${PROJECT_NAME})
set(PROJECT_DOMAIN "www.robomongo.org" CACHE STRING "Internet domain name for ${PROJECT_NAME}")
set(PROJECT_COMPANYNAME "Paralect" CACHE STRING "Company name for ${PROJECT_NAME}")
set(PROJECT_COPYRIGHT "Copyright (C) 2013 ${PROJECT_COMPANYNAME} All Rights Reserved.")
set(PROJECT_COMPANYNAME_DOMAIN "www.paralect.com" CACHE STRING "Internet domain name for ${PROJECT_NAME}")
set(PROJECT_GITHUB_FORK "www.github.com/paralect/robomongo" CACHE STRING "Git fork of ${PROJECT_NAME}")
set(PROJECT_GITHUB_ISSUES "www.github.com/paralect/robomongo/issues" CACHE STRING "Git issue link for ${PROJECT_NAME}")
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWERCASE)
set(MAJOR "0")
set(MINOR "8")
set(PATCH "4")
set(BUILD "")
set(SHORT_VERSION ${MAJOR}.${MINOR}.${PATCH} CACHE STRING "${PROJECT_NAME} short version")
set(PROJECT_VERSION "${SHORT_VERSION}${BUILD}" CACHE STRING "${PROJECT_NAME} version")
if(APPLE AND CMAKE_OSX_SYSROOT)
string(REGEX REPLACE ".*MacOSX([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_SDK_VERSION "${CMAKE_OSX_SYSROOT}")
string(REGEX REPLACE ".*MacOSX([0-9]+)\\.([0-9]+).*$" "\\2" DARWIN_MINOR_SDK_VERSION "${CMAKE_OSX_SYSROOT}")
if(EXISTS "${CMAKE_OSX_SYSROOT}")
set(MACOSX_DEPLOYMENT_TARGET ${DARWIN_MAJOR_SDK_VERSION}.${DARWIN_MINOR_SDK_VERSION})
set(CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS}")
message("Setting MACOSX_DEPLOYMENT_TARGET to '${MACOSX_DEPLOYMENT_TARGET}'.")
endif()
elseif(UNIX AND NOT APPLE)
set(PROJECT_NAME ${PROJECT_NAME_LOWERCASE})
endif()
###
# Configure project
PROJECT(${PROJECT_NAME})
###
# Options
IF(WIN32)
OPTION(MANIFEST_ENABLE "Enable Manifest" ON)
ENDIF(WIN32)
set(ROBOMONGO_QT_VERSION 5 CACHE STRING "Qt version to use when building Robomongo (can be 4 or 5)")
OPTION(BOOST_ENABLED "Enable boost system support" OFF)
OPTION(OPENSSL_ENABLED "Enable openssl support" ON)
OPTION(SSH_ENABLED "Enable ssh support" ON)
OPTION(CPACK_SUPPORT "Enable package support" ON)
OPTION(DEVELOPER_DYNAMIC_RUNTIME "Build with dynamic C++ runtime" ON)
OPTION(DEVELOPER_FEATURES "Use some debug tricks for developers" OFF)
OPTION(DEVELOPER_ENABLE_TESTS "Enable tests for ${PROJECT_NAME_TITLE} project" ON)
IF(MSVC)
IF(CMAKE_CL_64)
OPTION(BUILD_64X "Build 64bit project" ON)
ELSE()
OPTION(BUILD_64X "Build 64bit project" OFF)
ENDIF()
ELSE()
IF("${OS_ARC}" STREQUAL "64")
OPTION(BUILD_64X "Build 64bit project" ON)
ELSEIF("${OS_ARC}" STREQUAL "32")
OPTION(BUILD_64X "Build 64bit project" OFF)
ELSE()
IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
OPTION(BUILD_64X "Build 64bit project" ON)
ELSE(CMAKE_SIZEOF_VOID_P MATCHES 8)
OPTION(BUILD_64X "Build 64bit project" OFF)
ENDIF(CMAKE_SIZEOF_VOID_P MATCHES 8)
ENDIF()
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE DEBUG)
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCXX AND NOT MINGW)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
ENDIF()
ENDIF()
INCLUDE(cmake/config.cmake)
DEFINE_DEFAULT_DEFINITIONS()
# Search libraries
# use Qt
DETECT_QT()
##################### Libraries search ###################
IF(DEVELOPER_QT5)
SET(QT_COMPONENTS_TO_USE Qt5Core Qt5Gui Qt5Widgets)
IF(UNIX AND NOT APPLE)
SET(QT_COMPONENTS_TO_USE ${QT_COMPONENTS_TO_USE} Qt5DBus) #for libqxcb
ENDIF(UNIX AND NOT APPLE)
ELSE()
SET(QT_COMPONENTS_TO_USE QtCore QtGui)
ENDIF()
INTEGRATE_QT(${QT_COMPONENTS_TO_USE})
##########################################################
IF(BUILD_64X)
SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS 1)
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m64")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -m64")
ELSEIF(MSVC)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /machine:x64")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /machine:x64")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /machine:x64")
ENDIF()
IF(APPLE)
SET(CMAKE_OSX_ARCHITECTURES x86_64)
ENDIF()
SET(ARCH_TEXT 64)
SET(ARCH_TEXT_PACKAGE x86_64)#amd64
ELSE()
SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS 0)
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -m32")
ELSEIF(MSVC)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /machine:x86")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /machine:x86")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /machine:x86")
ENDIF()
IF(APPLE)
SET(CMAKE_OSX_ARCHITECTURES i386)
#-DCMAKE_OSX_ARCHITECTURES= ;i386
ENDIF()
SET(ARCH_TEXT 32)
SET(ARCH_TEXT_PACKAGE i386)
ENDIF()
##################################DEFAULT VALUES##########################################
IF(NOT CMAKE_INSTALL_PREFIX})
SET(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install")
ENDIF()
IF("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
MESSAGE(SEND_ERROR "In-source builds are not allowed.")
ENDIF("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
############################################################################
IF(WIN32)
SET(RESOURCE_OS "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/win.rc")
SET(RESOURCE_OS_IN "${CMAKE_SOURCE_DIR}/install/windows/winres.rc.in")
SET(ICON_FILE "${CMAKE_SOURCE_DIR}/src/robomongo/gui/resources/robo.ico")
SET(LIB_INSTALL_DESTINATION .)
SET(TARGET_INSTALL_DESTINATION .)
ELSEIF(APPLE)
SET(RESOURCE_OS "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/robomongo.desktop")
SET(RESOURCE_OS_IN "${CMAKE_SOURCE_DIR}/install/robomongo.desktop.in")
SET(ICON_FILE "${CMAKE_SOURCE_DIR}/install/osx/Robomongo.icns")
SET(LIB_INSTALL_DESTINATION .)
SET(TARGET_INSTALL_DESTINATION .)
ELSEIF(UNIX)
SET(RESOURCE_OS "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}.desktop")
SET(RESOURCE_OS_IN "${CMAKE_SOURCE_DIR}/install/robomongo.desktop.in")
SET(ICON_FILE "${CMAKE_SOURCE_DIR}/install/linux/robomongo.png")
SET(LIB_INSTALL_DESTINATION lib)
SET(TARGET_INSTALL_DESTINATION bin)
ENDIF()
# project sources
SET_PROPERTY( GLOBAL PROPERTY USE_FOLDERS ON)
ADD_SUBDIRECTORY(src)
IF(CPACK_SUPPORT)
SET(CPACK_PACKAGE_DESCRIPTION "Shell-centric cross-platform MongoDB management tool.")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME_TITLE} shell-centric cross-platform MongoDB management tool.")#CPACK_DEBIAN_PACKAGE_DESCRIPTION CPACK_RPM_PACKAGE_SUMMARY
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")#CPACK_RPM_PACKAGE_DESCRIPTION
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
SET(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
SET(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
SET(CPACK_PACKAGE_VENDOR ${PROJECT_COMPANYNAME})#CPACK_RPM_PACKAGE_VENDOR
SET(CPACK_PACKAGE_CONTACT "Dmitry Schetnikovich <[email protected]>")#CPACK_DEBIAN_PACKAGE_MAINTAINER
SET(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${SHORT_VERSION})
IF(BUILD)
STRING(REGEX REPLACE " " "" BUILD_ESCAPE ${BUILD})
SET(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}-${BUILD_ESCAPE}")
ENDIF(BUILD)
SET(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_PATCH})#CPACK_DEBIAN_PACKAGE_VERSION CPACK_RPM_PACKAGE_VERSION
SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})#CPACK_DEBIAN_PACKAGE_NAME CPACK_RPM_PACKAGE_NAME
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${ARCH_TEXT_PACKAGE}")#out package name
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY ${PROJECT_NAME})
SET(CPACK_PACKAGE_EXECUTABLES "${PROJECT_NAME_TITLE};${PROJECT_NAME}")
MESSAGE(STATUS "CPACK_PACKAGE_FILE_NAME: ${CPACK_PACKAGE_FILE_NAME}")
SET(CPACK_MONOLITHIC_INSTALL ON)
IF(WIN32)
IF(NOT CPACK_GENERATOR)
SET(CPACK_GENERATOR NSIS)
ENDIF(NOT CPACK_GENERATOR)
IF(CPACK_GENERATOR STREQUAL "NSIS")
# There is a bug in NSI that does not handle full unix paths properly. Make
# sure there is at least one set of four (4) backlasshes.
#SET(CPACK_NSIS_MODIFY_PATH ON)
SET(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/install/windows\\\\nsis-top-logo.bmp")
SET(CPACK_NSIS_INSTALLED_ICON_NAME "\\\\${PROJECT_NAME}.exe")
SET(CPACK_CREATE_DESKTOP_LINKS "${PROJECT_NAME}.exe")
SET(CPACK_NSIS_CREATE_ICONS "CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\${PROJECT_NAME}.lnk\\\" \\\"$INSTDIR\\\\${PROJECT_NAME}.exe\\\"")
SET(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut \\\"$DESKTOP\\\\${PROJECT_NAME}.lnk\\\" \\\"$INSTDIR\\\\${PROJECT_NAME}.exe\\\"")
SET(CPACK_NSIS_DELETE_ICONS_EXTRA "Delete \\\"$DESKTOP\\\\${PROJECT_NAME}.lnk\\\"")
SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\${PROJECT_COMPANYNAME_DOMAIN}")
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\${PROJECT_DOMAIN}")
SET(SIDEBAR_IMAGE ${CMAKE_SOURCE_DIR}/install/windows\\\\database.bmp)
SET(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "!define MUI_WELCOMEFINISHPAGE_BITMAP \\\"${SIDEBAR_IMAGE}\\\"")
SET(CPACK_NSIS_CONTACT "[email protected]")
SET(CPACK_NSIS_MUI_FINISHPAGE_RUN "..\\\\${PROJECT_NAME}.exe")
ENDIF(CPACK_GENERATOR STREQUAL "NSIS")
ELSEIF(APPLE)
IF(NOT CPACK_GENERATOR)
SET(CPACK_GENERATOR DragNDrop)
ENDIF(NOT CPACK_GENERATOR)
#SET(CPACK_OSX_PACKAGE_VERSION "10.5")
ELSEIF(UNIX)
SET(CPACK_STRIP_FILES ON)
#SET(UBUNTU_LP_BUG 300472)
#SET(CPACK_STRIP_FILES "bin/${PROJECT_NAME}")
#SET(CPACK_SOURCE_STRIP_FILES "")
IF(NOT CPACK_GENERATOR)
SET(CPACK_GENERATOR DEB)
ENDIF(NOT CPACK_GENERATOR)
IF(CPACK_GENERATOR STREQUAL "RPM" OR CPACK_GENERATOR STREQUAL "DEB")
SET(CPACK_PACKAGING_INSTALL_PREFIX "/opt/${PROJECT_NAME}")
ENDIF(CPACK_GENERATOR STREQUAL "RPM" OR CPACK_GENERATOR STREQUAL "DEB")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/install/linux/postinst.in" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/scripts/postinst" @ONLY IMMEDIATE)
FILE(COPY ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/scripts/postinst DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/install/linux/prerm.in" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/scripts/prerm" @ONLY IMMEDIATE)
FILE(COPY ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/scripts/prerm DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
IF(CPACK_GENERATOR STREQUAL "RPM")
#CPACK_RPM_PACKAGE_ARCHITECTURE CPACK_RPM_PACKAGE_LICENSE CPACK_RPM_PACKAGE_DESCRIPTION CPACK_RPM_SPEC_INSTALL_POST
#SET(CPACK_PACKAGE_RELEASE 1)
SET(CPACK_RPM_PACKAGE_LICENSE "GPL v3")
SET(CPACK_RPM_PACKAGE_AUTOREQPROV "no")
SET(CPACK_RPM_PACKAGE_REQUIRES "libc.so.6 >= 2.12, libstdc++.so.6 >= 6.0.13")
SET(CPACK_RPM_PACKAGE_RELEASE 1)
SET(CPACK_RPM_PACKAGE_GROUP "Development/Libraries/${PROJECT_COMPANYNAME}")
SET(CPACK_RPM_PACKAGE_ARCHITECTURE ${ARCH_TEXT_PACKAGE})
SET(CPACK_RPM_PACKAGE_VERSION ${SHORT_VERSION})
SET(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/postinst")
SET(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/prerm")
ELSEIF(CPACK_GENERATOR STREQUAL "DEB")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/install/linux/fixup_deb.sh.in" "${CMAKE_CURRENT_BINARY_DIR}/fixup_deb.sh" @ONLY IMMEDIATE)
IF(ARCH_TEXT_PACKAGE STREQUAL x86_64)
SET(ARCH_TEXT_PACKAGE amd64)
ENDIF()
#SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
#CPACK_DEBIAN_PACKAGE_HOMEPAGE The URL of the web site for this package
SET(CPACK_DEBIAN_PACKAGE_DEBUG ON)
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.12), libstdc++6 (>= 4.4.7)")
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
SET(CPACK_DEBIAN_PACKAGE_SECTION "database")#input our section
SET(CPACK_DEBIAN_PACKAGE_RECOMMENDS "Unknown")
SET(CPACK_DEBIAN_PACKAGE_SUGGESTS "Unknown")
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${ARCH_TEXT_PACKAGE})#i386
SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/postinst;${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/prerm")
ENDIF(CPACK_GENERATOR STREQUAL "RPM")
ENDIF(WIN32)
INCLUDE(CPack)
ENDIF(CPACK_SUPPORT)