File: CMakeLists.txt

package info (click to toggle)
mysql-workbench 6.3.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 113,932 kB
  • ctags: 87,814
  • sloc: ansic: 955,521; cpp: 427,465; python: 59,728; yacc: 59,129; xml: 54,204; sql: 7,091; objc: 965; makefile: 638; sh: 613; java: 237; perl: 30; ruby: 6; php: 1
file content (346 lines) | stat: -rw-r--r-- 12,710 bytes parent folder | download
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
cmake_minimum_required (VERSION 2.8)
# 2.8 needed because of ExternalProject

project(WORKBENCH)

# Retrieve current Workbench version variables
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/get_wb_version.sh major
                OUTPUT_VARIABLE WB_MAJOR_VERSION)
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/get_wb_version.sh minor
                OUTPUT_VARIABLE WB_MINOR_VERSION)
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/get_wb_version.sh revision
                OUTPUT_VARIABLE WB_RELEASE_VERSION)
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/get_wb_version.sh full_version
                OUTPUT_VARIABLE WB_VERSION)

string(STRIP ${WB_MAJOR_VERSION} WB_MAJOR_VERSION)
string(STRIP ${WB_MINOR_VERSION} WB_MINOR_VERSION)
string(STRIP ${WB_RELEASE_VERSION} WB_RELEASE_VERSION)
string(STRIP ${WB_VERSION} WB_VERSION)


#  About MySQL and CMake
#  http://dev.mysql.com/doc/internals/en/autotools-to-cmake.html
#  http://www.lenzg.net/archives/291-Building-MySQL-Server-with-CMake-on-LinuxUnix.html

#-----------------------------------------------------------------------
# Find packages and other useful checks
#-----------------------------------------------------------------------

# Look for our custom modules in cmake/Modules:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/build/cmake/Modules/")

if(ENABLE_COTIRE AND CMAKE_VERSION VERSION_GREATER "2.8.11")
  include(cotire)
  set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY")
endif()
find_package(PkgConfig REQUIRED)

find_package(X11)

find_package(GTK2 2.20 REQUIRED gtk gtkmm)
pkg_check_modules(GTHREAD REQUIRED gthread-2.0)
pkg_check_modules(GMODULE REQUIRED gmodule-2.0)
set(GTK2_INCLUDE_DIRS ${GTK2_INCLUDE_DIRS} ${GTHREAD_INCLUDE_DIRS} ${GMODULE_INCLUDE_DIRS})
list(REMOVE_DUPLICATES GTK2_INCLUDE_DIRS)
set(GTK2_LIBRARIES ${GTK2_LIBRARIES} ${GTHREAD_LIBRARIES} ${GMODULE_LIBRARIES})
list(REMOVE_DUPLICATES GTK2_LIBRARIES)

pkg_check_modules(GLIB REQUIRED glib-2.0)

if (USE_BUNDLED_MYSQLDUMP)
  set(USE_BUNDLED_MYSQLDUMP -DHAVE_BUNDLED_MYSQLDUMP=1)
endif ()


find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})

# All known publicly available versions of Antlr3C are buggy

if (SKIP_BUNDLED_ANTLR)
  find_package(Antlr3C)
endif ()
if (ANTLR3C_FOUND)
  set(ANTLR3C_REQUIRED_VERSION "3.4")
  if (${ANTLR3C_VERSION} VERSION_LESS ${ANTLR3C_REQUIRED_VERSION})
    message("Required antlr3c version ${ANTLR3C_REQUIRED_VERSION} but ${ANTLR3C_VERSION} found, using bundled version")
    unset(ANTLR3C_FOUND)
  endif ()
endif ()

set(Python_ADDITIONAL_VERSIONS "2.7")
#include(FindPythonLibs)

# In Ubuntu 13.04, the built-in check for python fails.. so we have to resort to the check with pkg-config (which doesn't work in many distros)
find_package(PythonLibs 2.6)
if (NOT PYTHONLIBS_FOUND)
    pkg_check_modules(PYTHON REQUIRED python)
endif ()


# We need to be able to detect python module versions and packages hence this function

FIND_PROGRAM(PYTHON_EXEC "python2")
include(FindPackageHandleStandardArgs)
function(find_python_module module minver)
        string(TOUPPER ${module} module_upper)
        if(NOT PY_${module_upper})
                if(ARGC GREATER 2 AND ARGV2 STREQUAL "REQUIRED")
                        set(PY_${module}_FIND_REQUIRED TRUE)
                endif()
                # A module's location is usually a directory, but for binary modules 
                # it's a .so file. 
                execute_process(COMMAND "${PYTHON_EXEC}" "-c" 
                        "import re, ${module}; print ${module}.__version__ if ${module}.__version__ >= '${minver}' else exit(1)" 
                        RESULT_VARIABLE _${module}_status 
                        OUTPUT_VARIABLE _${module}_location 
                        ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
                if(NOT _${module}_status)
                        set(PY_${module_upper} ${_${module}_location} CACHE STRING 
                                "Location of Python module ${module}")
                endif(NOT _${module}_status)
        endif(NOT PY_${module_upper})
        find_package_handle_standard_args(PY_${module} DEFAULT_MSG PY_${module_upper})
endfunction(find_python_module)

find_python_module(paramiko 1.15.1 QUIET)
if(NOT PY_PARAMIKO)
  message(WARNING "Paramiko wasn't found, you can still build Workbench, but may not work properly.")
endif()
find_package(MySQL REQUIRED)
if (UNIX)
	set(MYSQL_DEFINITIONS "-DBIG_JOINS=1"  "-fno-strict-aliasing")
endif()
set(PRECOMPILED_HEADERS_EXCLUDE_PATHS "/usr/include/gdal;/usr/include/arpa;${CMAKE_SOURCE_DIR};${PROJECT_SOURCE_DIR}/ext/antlr-runtime;${PROJECT_BINARY_DIR};${MySQL_INCLUDE_DIRS}")



find_package(LibXml2 REQUIRED)

find_package(OpenGL REQUIRED)


find_package(CTemplate 2.2 REQUIRED)
find_package(MySQLCppConn REQUIRED)
find_package(VSqlite REQUIRED)
find_package(TinyXML REQUIRED)
find_package(GDAL REQUIRED)

if (MYSQLCPPCONN_VERSION_1_1_4)
  add_definitions(-DMYSQLCPPCONN_VERSION_1_1_4)
endif ()

if (MYSQLCPPCONN_VERSION_1_1_6_OR_HIGHER)
  add_definitions(-DMYSQLCPPCONN_VERSION_1_1_6_OR_HIGHER)
endif (MYSQLCPPCONN_VERSION_1_1_6_OR_HIGHER)

if (UNIX)
  option(USE_UNIXODBC "Use unixODBC instead of iODBC" OFF)
  find_package(IODBC)
  find_package(UNIXODBC)

  if (USE_UNIXODBC)
    if (UNIXODBC-NOTFOUND)
      message(FATAL_ERROR "You've selected Unixodbc, but it cannot be found, CMake will exit.")
    else()
		  set(ODBC_LIBRARIES ${UNIXODBC_LIBRARIES})
  		set(ODBC_INCLUDE_DIRS ${UNIXODBC_INCLUDE_DIRS})
	  	set(ODBC_DEFINITIONS ${UNIXODBC_DEFINITIONS})
    endif()
  else()
    if (IODBC_FOUND)
      message("Found iodbc, using it as ODBC library.")
      set(ODBC_LIBRARIES ${IODBC_LIBRARIES})
      set(ODBC_INCLUDE_DIRS ${IODBC_INCLUDE_DIRS})
      set(ODBC_DEFINITIONS ${IODBC_DEFINITIONS})
    elseif (UNIXODBC_FOUND)
      message("Found unixodbc, using it as ODBC library.")
      set(ODBC_LIBRARIES ${UNIXODBC_LIBRARIES})
      set(ODBC_INCLUDE_DIRS ${UNIXODBC_INCLUDE_DIRS})
      set(ODBC_DEFINITIONS ${UNIXODBC_DEFINITIONS})
    else()
      message(FATAL_ERROR "Workbench required iodbc or Unixodbc, none was found, CMake will exit.")
    endif()
  endif(USE_UNIXODBC)

endif(UNIX)


pkg_check_modules(PCRE REQUIRED libpcre libpcrecpp)
pkg_check_modules(CAIRO REQUIRED cairo>=1.5.12)
pkg_check_modules(UUID REQUIRED uuid)
pkg_check_modules(LIBZIP REQUIRED libzip)
if (UNIX)
	pkg_check_modules(GNOME_KEYRING gnome-keyring-1)
	if (GNOME_KEYRING_FOUND)
		set(KEYRING_DEFINITION     "HAVE_GNOME_KEYRING")
	else()
		pkg_check_modules(GNOME_KEYRING gnome-keyring)
		if (GNOME_KEYRING_FOUND)
			set(KEYRING_DEFINITION     "HAVE_OLD_GNOME_KEYRING")
		endif()
	endif()
endif()

if (UNIX)
  include (CheckIncludeFiles)
  CHECK_INCLUDE_FILES ("sys/prctl.h" HAVE_PRCTL)
  if (HAVE_PRCTL)
    add_definitions(-DHAVE_PRCTL_H)
  endif()
endif()

include (CheckFunctionExists)
check_function_exists (strtol HAVE_STRTOL)
check_function_exists (strtoll HAVE_STRTOLL)
check_function_exists (strtold HAVE_STRTOLD)
check_function_exists (strtoull HAVE_STRTOULL)
check_function_exists (strtoimax HAVE_STRTOIMAX)
check_function_exists (strtoumax HAVE_STRTOUMAX)

if (UNIX)
	if (NOT LIB_INSTALL_DIR)
		set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
	endif()
	if (NOT SHARE_INSTALL_PREFIX)
		set(SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share")
	endif()
	if (NOT ETC_INSTALL_DIR)
		set(ETC_INSTALL_DIR "/etc")
	endif()
	if (NOT REAL_EXECUTABLE_DIR)
		set(REAL_EXECUTABLE_DIR "${CMAKE_INSTALL_PREFIX}/bin")
	endif()

	set(WB_INSTALL_DIR              "${CMAKE_INSTALL_PREFIX}")
	set(WB_INSTALL_DIR_EXECUTABLE   "${REAL_EXECUTABLE_DIR}")
	set(WB_INSTALL_BIN_DIR          "${CMAKE_INSTALL_PREFIX}/bin")
	set(WB_INSTALL_LIB_DIR          "${LIB_INSTALL_DIR}/mysql-workbench")
	set(WB_PYTHON_MODULES_DIR       "${WB_INSTALL_LIB_DIR}/modules")
	set(WB_INSTALL_SHARED_DIR       "${SHARE_INSTALL_PREFIX}")
	set(WB_INSTALL_ETC_DIR          "${ETC_INSTALL_DIR}")
	set(WB_PACKAGE_SHARED_DIR       "${SHARE_INSTALL_PREFIX}/mysql-workbench")
	set(WB_PACKAGE_PLUGINS_DIR      "${LIB_INSTALL_DIR}/mysql-workbench/plugins")
	set(WB_PYTHON_MODULES_DATA_DIR  "${SHARE_INSTALL_PREFIX}/mysql-workbench/modules/data")
	set(WB_INSTALL_DOC_DIR          "${SHARE_INSTALL_PREFIX}/doc/mysql-workbench")
endif()

include(ExternalProject)

if (NOT ANTLR3C_FOUND)
  message("Using bundled Antlr C runtime")
  #  Use for Antlr3 the one we have in /ext:
  set(ANTLR3C_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/ext/antlr-runtime ${PROJECT_SOURCE_DIR}/ext/antlr-runtime/include)
  set(ANTLR3C_LIBRARIES "-L${PROJECT_BINARY_DIR}/antlr-wb -lantlr3c_wb")

  ExternalProject_Add(antlr-wb
    SOURCE_DIR ${PROJECT_SOURCE_DIR}/ext/antlr-runtime
    CONFIGURE_COMMAND ${PROJECT_SOURCE_DIR}/ext/antlr-runtime/configure
        --prefix=${PROJECT_BINARY_DIR}/antlr-wb
        --libdir=${PROJECT_BINARY_DIR}/antlr-wb
	--disable-abiflags
    BUILD_COMMAND make
    BUILD_IN_SOURCE 2
    INSTALL_COMMAND make install
  )

  link_directories(${PROJECT_BINARY_DIR}/antlr-wb)
endif ()

# Uncomment these lines if at any time you want to force the configure and/or build
# of antlr-wb:
#ExternalProject_Add_Step(antlr-wb forceconfigure
#    COMMAND ${CMAKE_COMMAND} -E echo "Force configure of antlr-wb"
#    DEPENDEES update
#    DEPENDERS configure
#    ALWAYS 1
#)
#ExternalProject_Add_Step(antlr-wb forcebuild
#    COMMAND ${CMAKE_COMMAND} -E echo "Force build of antlr-wb"
#    DEPENDEES configure
#    DEPENDERS build
#    ALWAYS 1
#)


#include(CheckCXXCompilerFlag)
#check_cxx_compiler_flag(-Wall  HAS_ALL_WARNS)
#if (HAS_ALL_WARNS)
#	add_definitions(-Wall)
#endif()
#check_cxx_compiler_flag(-Wsign-compare  HAS_SIGN_COMPARE)
#if (HAS_SIGN_COMPARE)
#	add_definitions(-Wsign-compare)
#endif()
add_definitions(-D__STDC_FORMAT_MACROS)

set(BUILD_SHARED_LIBS ON)  # By default all libs will be built as shared libs
SET(GCOV OFF CACHE BOOL "Add gcov flags")

# Add some common compiler flags. TODO: Shouldn't this be done checking if whatever compiler
# we use supports each flag to allow for non-gcc compilers in Linux (as above)?
if (CMAKE_COMPILER_IS_GNUCXX)
	set(MY_CXXFLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-deprecated -DTIXML_USE_STL=1")

    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror -ggdb3 ${MY_CXXFLAGS}")
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MY_CXXFLAGS}") 
endif()

if(GCOV)
    set(MY_CXXFLAGS "${MY_CXXFLAGS} -fprofile-arcs -ftest-coverage") 
endif()



#-----------------------------------------------------------------------
# Define some useful variables and options
#-----------------------------------------------------------------------

#set(NCORES 3)  # Use this number of cores when compiling
#if(CMAKE_COMPILER_IS_GNUCXX)
#	set(CMAKE_CXX_FLAGS "${CMAKE_CKK_FLAGS} -j${NCORES}")
#	message(STATUS "CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}")
#	set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-s")  ## Strip binary
#endif()


set(GRT_LIBRARIES ${PYTHON_LIBRARIES} ${LIBXML2_LIBRARIES})
set(GRT_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR})

configure_file(${PROJECT_SOURCE_DIR}/mysql-workbench.desktop.in mysql-workbench.desktop)

# FIXME: Should this go here? ---v
include_directories(${PROJECT_SOURCE_DIR}/plugins/migration/copytable ${PROJECT_SOURCE_DIR}/library/base)
include_directories(${GTK2_INCLUDE_DIRS})

add_subdirectory(tools)
add_subdirectory(backend)
add_subdirectory(ext)
add_subdirectory(frontend)
add_subdirectory(images)
add_subdirectory(library)
add_subdirectory(modules)
add_subdirectory(plugins)
add_subdirectory(res)
if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/internal)
  add_subdirectory(internal)
endif()

install(FILES ${CMAKE_BINARY_DIR}/mysql-workbench.desktop DESTINATION ${WB_INSTALL_SHARED_DIR}/applications)

if (EXISTS ${PROJECT_SOURCE_DIR}/COPYING)
    install(FILES README COPYING DESTINATION ${WB_INSTALL_DOC_DIR})
    install(FILES build/mysql-workbench-community.sharedmimeinfo DESTINATION ${WB_INSTALL_SHARED_DIR}/mime/packages RENAME mysql-workbench.xml)
    install(FILES build/mysql-workbench-community.mime DESTINATION ${WB_INSTALL_SHARED_DIR}/mime-info RENAME mysql-workbench.mime)
else ()
    install(FILES README LICENSE.mysql DESTINATION ${WB_INSTALL_DOC_DIR})
    install(FILES build/mysql-workbench-commercial.sharedmimeinfo DESTINATION ${WB_INSTALL_SHARED_DIR}/mime/packages RENAME mysql-workbench.xml)
    install(FILES build/mysql-workbench-commercial.mime DESTINATION ${WB_INSTALL_SHARED_DIR}/mime-info RENAME mysql-workbench.mime)
endif ()

install(FILES build/build_freetds.sh
              samples/models/sakila_full.mwb
        DESTINATION ${WB_PACKAGE_SHARED_DIR}/extras
       )