~zorba-coders/zorba/bug1151967

10461.2.4 by danielturcanu
Merged with latest trunk
1
# Copyright 2006-2010 The FLWOR Foundation.
2
# 
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
# 
7
# http://www.apache.org/licenses/LICENSE-2.0
8
# 
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
#
15
PROJECT(zorba)
16
ENABLE_TESTING()
17
INCLUDE(CTest)
18
10599.3.2 by Chris Hillery
Adding second expected result for udf-fib-rec test case (for when Zorba
19
10461.2.4 by danielturcanu
Merged with latest trunk
20
# overwriting the source and binary directories with the current zorba ones
21
# this is usefull for other projects reusing zorba as a subcomponent
22
SET(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
23
SET(CMAKE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
24
25
INCLUDE(${CMAKE_SOURCE_DIR}/cmake_modules/CMakeCompareVersionStrings.cmake)
26
27
cmake_minimum_required(VERSION 2.6)
28
IF(CMAKE_VERSION STREQUAL "2.6.3")
29
  MESSAGE(FATAL_ERROR "You are running a buggy CMake version (2.6.3). Please install a different CMake version and execute CMake again.")
30
ENDIF(CMAKE_VERSION STREQUAL "2.6.3")
31
IF(COMMAND cmake_policy)
32
  cmake_policy(SET CMP0003 NEW)
33
  cmake_policy(SET CMP0002 OLD)
34
  # We want CMake to correctly count empty list elements.
35
  cmake_policy(SET CMP0007 NEW)
36
ENDIF(COMMAND cmake_policy)
37
38
IF("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
39
  SET(LINUX "${CMAKE_SYSTEM}")
40
ENDIF("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
41
42
# custom ctest options
43
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake)
44
45
# prohibit in-source-builds
46
IF(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
47
  MESSAGE(STATUS "In-source-builds are not allowed")
48
  MESSAGE(STATUS "Clean your source directory (e.g. delete the CMakeCache.txt file)")
49
  MESSAGE(FATAL_ERROR "Please create a separate build directory and call CMake again")
50
ENDIF(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
51
52
# set the default build type to release
53
# NOTE: the "NMake Makefiles" generator will always set the default build type to "Debug"
54
IF (NOT CMAKE_BUILD_TYPE)
55
  SET (CMAKE_BUILD_TYPE Release CACHE STRING
56
       "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
57
       FORCE)
58
ENDIF (NOT CMAKE_BUILD_TYPE)
59
60
# set the default installation directory to "dist" in the build directory
61
IF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
62
  SET (CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/dist CACHE STRING
63
       "Set the defalt installation directory to \"dist\" in the binary directory." FORCE)
64
ENDIF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
65
66
# Enable RPaths in installed binaries
67
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
10861.1.1 by chillery+launchpad at lambda
Set CMAKE_INSTALL_RPATH_USE_LINK_PATH to TRUE to have correct RPATHs in
68
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
10461.2.4 by danielturcanu
Merged with latest trunk
69
70
# turn on the folder grouping used by IDEs (VS or XCode)
71
SET(ZORBA_USE_TARGET_FOLDERS ON CACHE BOOL "Activate use of target grouping into folders")
72
IF(ZORBA_USE_TARGET_FOLDERS)
73
  SET_PROPERTY (GLOBAL PROPERTY USE_FOLDERS ON)
74
ENDIF(ZORBA_USE_TARGET_FOLDERS)
75
76
###############################################################################
77
# Check for system include files, features, etc.
78
###############################################################################
11140.4.4 by Paul J. Lucas
Intermediate check-in.
79
INCLUDE(CheckCXXSourceCompiles)
80
INCLUDE(CheckFunctionExists)
81
INCLUDE(CheckIncludeFileCXX)
10461.2.4 by danielturcanu
Merged with latest trunk
82
INCLUDE(CheckIncludeFiles)
11140.4.4 by Paul J. Lucas
Intermediate check-in.
83
INCLUDE(CheckLibraryExists)
84
INCLUDE(CheckStructHasMember)
10461.2.4 by danielturcanu
Merged with latest trunk
85
INCLUDE(CheckSymbolExists)
11140.4.4 by Paul J. Lucas
Intermediate check-in.
86
INCLUDE(CheckTypeSize)
10461.2.4 by danielturcanu
Merged with latest trunk
87
INCLUDE(CheckVariableExists)
88
89
CHECK_INCLUDE_FILES ("unicode/coll.h"               ZORBA_HAVE_COLL_H)
11140.4.35 by Paul J. Lucas
Added ZORBA_HAVE_TZFILE_H.
90
CHECK_INCLUDE_FILES ("iconv.h"                      ZORBA_HAVE_ICONV_H)
10461.2.4 by danielturcanu
Merged with latest trunk
91
CHECK_INCLUDE_FILES ("inttypes.h"                   ZORBA_HAVE_INTTYPES_H)
11140.4.35 by Paul J. Lucas
Added ZORBA_HAVE_TZFILE_H.
92
CHECK_INCLUDE_FILES ("limits.h"                     ZORBA_HAVE_LIMITS_H)
10461.2.4 by danielturcanu
Merged with latest trunk
93
CHECK_INCLUDE_FILES ("stdint.h"                     ZORBA_HAVE_STDINT_H)
94
CHECK_INCLUDE_FILES ("stdlib.h"                     ZORBA_HAVE_STDLIB_H)
11140.4.35 by Paul J. Lucas
Added ZORBA_HAVE_TZFILE_H.
95
CHECK_INCLUDE_FILES ("sys/param.h;sys/mount.h"      ZORBA_HAVE_SYS_MOUNT_H)
10461.2.4 by danielturcanu
Merged with latest trunk
96
CHECK_INCLUDE_FILES ("sys/types.h"                  ZORBA_HAVE_SYS_TYPES_H)
11140.4.35 by Paul J. Lucas
Added ZORBA_HAVE_TZFILE_H.
97
CHECK_INCLUDE_FILES ("tzfile.h"                     ZORBA_HAVE_TZFILE_H)
98
CHECK_INCLUDE_FILES ("unicode/ustring.h"            ZORBA_HAVE_USTRING_H)
99
CHECK_INCLUDE_FILES ("unicode/utypes.h"             ZORBA_HAVE_UTYPES_H)
100
10461.2.4 by danielturcanu
Merged with latest trunk
101
IF (NOT APPLE OR ${CMAKE_SYSTEM_VERSION} VERSION_GREATER "10.4")
102
  # execinfo is found by this macro when cross compiling for Mac OS X 10.4
103
  # although it shouldn't be found for this platform
104
  CHECK_INCLUDE_FILES ("execinfo.h"                   ZORBA_HAVE_EXECINFO_H)
105
ENDIF (NOT APPLE OR ${CMAKE_SYSTEM_VERSION} VERSION_GREATER "10.4")
106
CHECK_INCLUDE_FILE_CXX ("FlexLexer.h"               ZORBA_HAVE_FLEXLEXER_H)
10997.2.16 by Markos Zaharioudakis
merge from trunk + some cosmetic changes
107
CHECK_INCLUDE_FILES ("uuid/uuid.h"                  ZORBA_HAVE_UUID_H)
10461.2.4 by danielturcanu
Merged with latest trunk
108
109
CHECK_FUNCTION_EXISTS (strtof                     ZORBA_HAVE_STRTOF_FUNCTION)
110
CHECK_FUNCTION_EXISTS (strtoll                    ZORBA_HAVE_STRTOLL_FUNCTION)
111
CHECK_FUNCTION_EXISTS (_stricmp                   ZORBA_HAVE_STRICMP_FUNCTION)
112
CHECK_FUNCTION_EXISTS (strcat_s                   ZORBA_HAVE_STRCAT_S_FUNCTION)
113
CHECK_FUNCTION_EXISTS (strcpy_s                   ZORBA_HAVE_STRCPY_S_FUNCTION)
114
115
SET(CMAKE_REQUIRED_LIBRARIES pthread)  
116
CHECK_INCLUDE_FILES (pthread.h                    ZORBA_HAVE_PTHREAD_H)
117
CHECK_FUNCTION_EXISTS(pthread_spin_init           ZORBA_HAVE_PTHREAD_SPINLOCK)
118
CHECK_FUNCTION_EXISTS(pthread_mutex_init          ZORBA_HAVE_PTHREAD_MUTEX)
119
SET(CMAKE_REQUIRED_LIBRARIES)  
120
121
CHECK_INCLUDE_FILES ("sys/time.h;sys/resource.h"  ZORBA_HAVE_RUSAGE_INCLUDES)
122
CHECK_FUNCTION_EXISTS (getrusage                  ZORBA_HAVE_RUSAGE_FUNCTION)
123
124
CHECK_TYPE_SIZE("int32_t" ZORBA_HAVE_INT32_T) 
125
CHECK_TYPE_SIZE("uint32_t" ZORBA_HAVE_UINT32_T) 
126
CHECK_TYPE_SIZE("unsigned __int32" ZORBA_HAVE_MS_UINT32) 
127
CHECK_TYPE_SIZE("__int32" ZORBA_HAVE_MS_INT32) 
128
CHECK_TYPE_SIZE("int64_t" ZORBA_HAVE_INT64_T) 
129
11140.4.4 by Paul J. Lucas
Intermediate check-in.
130
CHECK_STRUCT_HAS_MEMBER("struct tm" tm_gmtoff time.h 	ZORBA_HAVE_STRUCT_TM_TM_GMTOFF)
131
CHECK_STRUCT_HAS_MEMBER("struct tm" __tm_gmtoff time.h 	ZORBA_HAVE_STRUCT_TM___TM_GMTOFF)
132
10866.2.19 by Paul J. Lucas
s/ZORBA_CXX_ENABLE_IF/ZORBA_HAVE_ENABLE_IF/
133
# C++ built-in type sizes
10866.2.12 by Paul J. Lucas
Added ZORBA_SIZEOF_ macros.
134
CHECK_TYPE_SIZE("double" ZORBA_SIZEOF_DOUBLE BUILTIN_TYPES_ONLY) 
135
CHECK_TYPE_SIZE("float" ZORBA_SIZEOF_FLOAT BUILTIN_TYPES_ONLY) 
136
CHECK_TYPE_SIZE("int" ZORBA_SIZEOF_INT BUILTIN_TYPES_ONLY) 
137
CHECK_TYPE_SIZE("long" ZORBA_SIZEOF_LONG BUILTIN_TYPES_ONLY) 
138
CHECK_TYPE_SIZE("long long" ZORBA_SIZEOF_LONG_LONG BUILTIN_TYPES_ONLY) 
139
CHECK_TYPE_SIZE("void*" ZORBA_SIZEOF_POINTER BUILTIN_TYPES_ONLY) 
140
CHECK_TYPE_SIZE("short" ZORBA_SIZEOF_SHORT BUILTIN_TYPES_ONLY) 
141
CHECK_TYPE_SIZE("size_t" ZORBA_SIZEOF_SIZE_T) 
10461.2.4 by danielturcanu
Merged with latest trunk
142
SET(CMAKE_EXTRA_INCLUDE_FILES wchar.h)
143
CHECK_TYPE_SIZE("wchar_t" ZORBA_SIZEOF_WCHAR_T)
144
SET(CMAKE_EXTRA_INCLUDE_FILES)
10866.2.1 by Paul J. Lucas
Added unordered_map.
145
10866.2.19 by Paul J. Lucas
s/ZORBA_CXX_ENABLE_IF/ZORBA_HAVE_ENABLE_IF/
146
# C++11 langauge features
10913.1.1 by Dennis Knochenwefel
fixed CHECK_CXX_SOURCE_COMPILES doesn't work with backslash-n using cmake 2.8.8 on windows.
147
CHECK_CXX_SOURCE_COMPILES(
148
  "int main() { int *p = nullptr; }" ZORBA_CXX_NULLPTR)
149
CHECK_CXX_SOURCE_COMPILES(
150
  "int main() { static_assert(1,\"\"); }" ZORBA_CXX_STATIC_ASSERT)
10461.2.4 by danielturcanu
Merged with latest trunk
151
10866.2.19 by Paul J. Lucas
s/ZORBA_CXX_ENABLE_IF/ZORBA_HAVE_ENABLE_IF/
152
# C++11 standard library types
10913.1.1 by Dennis Knochenwefel
fixed CHECK_CXX_SOURCE_COMPILES doesn't work with backslash-n using cmake 2.8.8 on windows.
153
CHECK_CXX_SOURCE_COMPILES (
154
  "#include <type_traits>
155
  int main() { std::enable_if<true,int> x; }" ZORBA_HAVE_ENABLE_IF)
156
CHECK_CXX_SOURCE_COMPILES ("
157
  #include <memory>
158
  int main() { std::unique_ptr<int> p; }" ZORBA_HAVE_UNIQUE_PTR)
159
CHECK_CXX_SOURCE_COMPILES (
160
  "#include <unordered_map>
161
  int main() { std::unordered_map<int,int> m; }" ZORBA_HAVE_UNORDERED_MAP)
162
CHECK_CXX_SOURCE_COMPILES (
163
  "#include <unordered_set>
164
  int main() { std::unordered_set<int> s; }" ZORBA_HAVE_UNORDERED_SET)
10866.2.1 by Paul J. Lucas
Added unordered_map.
165
10461.2.4 by danielturcanu
Merged with latest trunk
166
################################################################################
167
# Various cmake macros
168
10500.1.1 by Gabriel Petrovay
Added SET_CMAKE_MODULE_PATH macro to adjust the CMAKE_MODULE_PATH in zorba module project.
169
SET (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules ${CMAKE_MODULE_PATH})
170
IF (WIN32)
10461.2.4 by danielturcanu
Merged with latest trunk
171
  # On Windows we use proxy modules that try to guess first the location
172
  # of the required third party libraries. This will search in order in:
173
  # 1. the path pointed by ZORBA_THIRD_PARTY_REQUIREMENTS
174
  # 2. the Program Files directory available on the users computer
175
  # 3. the PATH environment variable
176
  # The logic is implemented by the macros in the ProxyFindModule.cmake module.
10500.1.1 by Gabriel Petrovay
Added SET_CMAKE_MODULE_PATH macro to adjust the CMAKE_MODULE_PATH in zorba module project.
177
  SET (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules/Windows ${CMAKE_MODULE_PATH})
178
  INCLUDE (ProxyFindModule)
179
ENDIF (WIN32)
10461.2.4 by danielturcanu
Merged with latest trunk
180
181
################################################################################
10870.3.1 by David Graf
Generate the .vcproj in the '.bat-file-way'.
182
# This section is used for batch script and Visual Studio Project file generation. 
183
# Each executable on Windows needs a bat script and in the Visual Studio build a \
184
# pre-generated Visual Studio Project file in order to set the PATH to the required DLLs.
10461.2.4 by danielturcanu
Merged with latest trunk
185
# For this we use CACHE variables to gather all the information generated
186
# throughout the cmake execution (required DLLs, list of scripts to generate).
187
# The generation occurs only at the end of CMake execution (through the macro
10870.3.1 by David Graf
Generate the .vcproj in the '.bat-file-way'.
188
# ZORBA_GENERATE_EXE_HELPERS_WIN32) when ALL the requirements have been found.
10461.2.4 by danielturcanu
Merged with latest trunk
189
# E.g. zorba.exe needs in PATH all the DLLs of all external modules, etc.
190
IF (WIN32)
191
  # Clear all the variables because they are used only for this build.
192
  SET (ZORBA_REQUIRED_DLLS ""
193
    CACHE STRING "List of DLLs that must be installed" FORCE
194
  )
195
  SET (ZORBA_REQUIRED_DLL_PATHS ""
196
    CACHE STRING "List of paths executable require in order to find the required DLLs" FORCE
197
  )
198
  SET (ZORBA_EXE_SCRIPT_LIST ""
199
    CACHE STRING "List of Windows batch scripts to be generated, one for each executable" FORCE
200
  )
10870.3.1 by David Graf
Generate the .vcproj in the '.bat-file-way'.
201
  IF (MSVC_IDE)
202
    SET (ZORBA_VC_PROJECT_FILE_LIST ""
203
      CACHE STRING "List of Visual Studio project files to be generated, one for each executable" FORCE
204
    )
205
  ENDIF(MSVC_IDE)
206
10461.2.4 by danielturcanu
Merged with latest trunk
207
  # Moreover, mark it as advanced since the CMake GUI user should not see this.
208
  MARK_AS_ADVANCED (FORCE ZORBA_REQUIRED_DLLS)
209
  MARK_AS_ADVANCED (FORCE ZORBA_REQUIRED_DLL_PATHS)
210
  MARK_AS_ADVANCED (FORCE ZORBA_EXE_SCRIPT_LIST)
10870.3.1 by David Graf
Generate the .vcproj in the '.bat-file-way'.
211
  IF (MSVC_IDE)
212
    MARK_AS_ADVANCED (FORCE ZORBA_VC_PROJECT_FILE_LIST)
213
  ENDIF(MSVC_IDE)
10461.2.4 by danielturcanu
Merged with latest trunk
214
ENDIF (WIN32)
215
################################################################################
216
217
218
# ZorbaModule includes a number of generally-useful utility functions,
219
# including expected_failure().  Include it now (very early) to ensure
220
# the "expected_failure()" function is available to anyone who might
221
# add tests.
222
INCLUDE(ZorbaModule)
223
224
################################################################################
225
#                                                                              #
226
# Search for all the external libraries that any library or executable under   #
227
# this CMake depends on.                                                       #
228
#                                                                              #
229
################################################################################
230
231
FOREACH(path "${CMAKE_PREFIX_PATH}")
232
  IF(EXISTS "${path}")
233
    MESSAGE("path entry: ${path}")
234
  ELSE(EXISTS "${path}")
235
    # Ignore non-existing paths
236
    #MESSAGE("Non-existing path!: ${path}")
237
  ENDIF(EXISTS "${path}")
238
ENDFOREACH(path)
239
240
SET(requiredlibs)
241
SET(requiredlibs-store)
242
243
# Check for POSIX high-resolution timers - might be in "rt" library
244
CHECK_LIBRARY_EXISTS(rt clock_gettime ""  _clock_gettime_in_rt)
245
IF(_clock_gettime_in_rt)
246
  SET(requiredlibs ${requiredlibs} rt)
247
  SET(ZORBA_HAVE_CLOCKGETTIME_FUNCTION YES CACHE BOOL "Platform has clock_gettime (in librt)")
248
ELSE(_clock_gettime_in_rt)
249
  CHECK_FUNCTION_EXISTS(clock_gettime   ZORBA_HAVE_CLOCKGETTIME_FUNCTION)
250
ENDIF(_clock_gettime_in_rt)
251
252
#
253
# TcMalloc support
254
#
255
IF(ZORBA_USE_TCMALLOC)
256
  MESSAGE (STATUS "Looking for TcMalloc")
257
258
  FIND_PACKAGE(TcMalloc)
259
  IF(Tcmalloc_FOUND)
260
    SET(requiredlibs ${requiredlibs} ${Tcmalloc_LIBRARIES})
261
  ELSE(Tcmalloc_FOUND)
262
    MESSAGE(FATAL_ERROR "TcMalloc not found")
263
  ENDIF(Tcmalloc_FOUND)
264
ENDIF(ZORBA_USE_TCMALLOC)
265
266
#
267
# GooglePerfTools support
268
#
269
IF(ZORBA_WITH_CPU_PROFILE)
270
  MESSAGE(STATUS "Looking for GooglePerfTools")
271
272
  FIND_PACKAGE(GooglePerfTools)
273
  IF(GooglePerfTools_FOUND)
274
    SET(requiredlibs ${requiredlibs} ${GooglePerfTools_LIBRARIES})
275
  ELSE(GooglePerfTools_FOUND)
276
    MESSAGE(FATAL_ERROR "GooglePerfTools not found. Cannot build with CPU profiling")
277
  ENDIF(GooglePerfTools_FOUND)
278
ENDIF(ZORBA_WITH_CPU_PROFILE)
279
280
#
281
#  LibXml2
282
#
283
MESSAGE(STATUS "Looking for LibXml2")
284
FIND_PACKAGE(LibXml2)
285
IF(LIBXML2_FOUND)
10697.1.9 by Markos Zaharioudakis
merge from trunk
286
  # Now check LibXml2's version
287
  FILE(STRINGS ${LIBXML2_INCLUDE_DIR}/libxml/xmlversion.h LIBXML2_VERSION_TMP REGEX 
288
       "^#define[ \t]+LIBXML_DOTTED_VERSION[ \t]+\".*\"")
289
  STRING(REGEX REPLACE "^#define[ \t]+LIBXML_DOTTED_VERSION[ \t]+\"(.*)\"" "\\1" 
290
         LIBXML2_VERSION ${LIBXML2_VERSION_TMP})
291
         
292
  IF(LIBXML2_VERSION VERSION_EQUAL "2.7.0" OR LIBXML2_VERSION VERSION_GREATER "2.7.0")
293
    MESSAGE(STATUS "Found LIBXML2 library -- " ${LIBXML2_LIBRARIES})
294
    INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
295
    SET(requiredlibs-store ${requiredlibs-store} ${LIBXML2_LIBRARIES})
296
    SET(CXXFLAGS ${CXXFLAGS} ${LIBXML2_DEFINITONS})
297
  ELSE(LIBXML2_VERSION VERSION_EQUAL "2.7.0" OR LIBXML2_VERSION VERSION_GREATER "2.7.0")
298
    MESSAGE(FATAL_ERROR "The libxml2 library version 2.7.0 or higher is required in order to build Zorba.")
299
  ENDIF(LIBXML2_VERSION VERSION_EQUAL "2.7.0" OR LIBXML2_VERSION VERSION_GREATER "2.7.0")
300
10461.2.4 by danielturcanu
Merged with latest trunk
301
ELSE(LIBXML2_FOUND)
302
  MESSAGE(FATAL_ERROR "The libxml2 library and headers are required in order to build simple store.")
303
ENDIF(LIBXML2_FOUND)
304
MESSAGE(STATUS "")
305
306
#
307
# Pthreads
308
#
309
IF(ZORBA_HAVE_PTHREAD_H AND NOT ZORBA_FOR_ONE_THREAD_ONLY)
310
  SET(requiredlibs ${requiredlibs} pthread)
311
ENDIF(ZORBA_HAVE_PTHREAD_H AND NOT ZORBA_FOR_ONE_THREAD_ONLY)
312
313
#
314
# Iconv
315
#
316
IF(WIN32)
317
  MESSAGE(STATUS "Looking for Iconv")
318
  FIND_PACKAGE(Iconv REQUIRED)
319
320
  IF(ICONV_FOUND)
321
    MESSAGE(STATUS "Found Iconv library -- " ${ICONV_LIBRARY})
322
    INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
323
    SET(requiredlibs ${requiredlibs} ${ICONV_LIBRARY})
324
  ELSE(ICONV_FOUND)
325
    MESSAGE(STATUS "The Iconv library was not found.")
326
  ENDIF(ICONV_FOUND)
327
  MESSAGE(STATUS "")
328
ENDIF(WIN32)
329
330
#
331
# ICU
332
#
333
MESSAGE(STATUS "Looking for ICU")
334
FIND_PACKAGE(ICU)
335
  
336
IF(ICU_FOUND AND ICU_I18N_FOUND AND ICU_DATA_FOUND)
337
  MESSAGE(STATUS "Found ICU library -- " ${ICU_LIBRARIES})
338
339
  INCLUDE_DIRECTORIES(${ICU_INCLUDE_DIRS})
340
  SET(requiredlibs ${requiredlibs} ${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES} ${ICU_DATA_LIBRARIES}) 
341
ELSE(ICU_FOUND AND ICU_I18N_FOUND AND ICU_DATA_FOUND)
342
  MESSAGE(FATAL_ERROR "The ICU library is required in order to build Zorba.")
343
ENDIF(ICU_FOUND AND ICU_I18N_FOUND AND ICU_DATA_FOUND)       
344
MESSAGE(STATUS "")
345
346
#
347
# Xerces-C part 1 - finding in default locations
348
#
349
MESSAGE (STATUS "Looking for Xerces-C")
350
FIND_PACKAGE (XercesC)
351
MESSAGE (STATUS "")
352
353
#
10787.1.4 by Rodolfo Ochoa
Fix for missing shlwapi.lib missing in windows
354
# shlwapi
355
#
356
IF(WIN32)
357
    SET(requiredlibs ${requiredlibs} "shlwapi")
358
ENDIF(WIN32)
359
360
#
10461.2.4 by danielturcanu
Merged with latest trunk
361
# SWIG
362
#
363
IF (NOT ZORBA_SUPPRESS_SWIG)
364
  FIND_PACKAGE (SWIG)
365
366
  COMPARE_VERSION_STRINGS("${SWIG_VERSION}" "1.3.40" result)
367
  IF(result LESS 0)
368
    MESSAGE(WARNING "You need at least SWIG version 1.3.40")
369
  ENDIF(result LESS 0)
370
371
372
  IF (SWIG_FOUND)
373
    # this will be used both in swig and doc sub-directories
374
375
    #
376
    # PHP5
377
    #
378
    FIND_PACKAGE (PHP5)
379
380
    #
381
    # Python
382
    #
383
    FIND_PACKAGE (PythonInterp)
384
    FIND_PACKAGE (PythonLibs)
385
    
386
  ELSE (SWIG_FOUND)
387
    MESSAGE (STATUS "SWIG not found => no language bindings are generated.")  
388
  ENDIF (SWIG_FOUND)
389
ELSE (NOT ZORBA_SUPPRESS_SWIG)
390
  MESSAGE (STATUS "SWIG is disabled => no language bindings are generated.")  
391
ENDIF (NOT ZORBA_SUPPRESS_SWIG)
392
393
394
LIST(APPEND requiredlibs ${requiredlibs-store})
395
396
################################################################################
397
# Setup Compiler Options
398
# Note that this needs to be done after all packages are found because
399
# it sets variables based on whether packages have been found or not.
400
INCLUDE(CMakeConfiguration.txt)
401
INCLUDE(CMakeCompiler.txt)
402
403
#
404
#  LibXslt
405
#
406
IF(ZORBA_XQUERYX)
407
  MESSAGE(STATUS "Looking for LibXslt")
408
  FIND_PACKAGE(LibXslt)
409
  IF(LIBXSLT_FOUND)
410
    MESSAGE(STATUS "Found LIBXSLT library -- " ${LIBXSLT_LIBRARIES})
411
412
    INCLUDE_DIRECTORIES(${LIBXSLT_INCLUDE_DIR})
413
    SET(requiredlibs ${requiredlibs} ${LIBXSLT_LIBRARIES})
414
    SET(CXXFLAGS ${CXXFLAGS} ${LIBXSLT_DEFINITONS})
415
  ELSE(LIBXSLT_FOUND)
416
    MESSAGE(FATAL_ERROR "The libxslt library is required in order to build zorba with xqueryx capabilities.")
417
  ENDIF(LIBXSLT_FOUND)
418
  MESSAGE(STATUS "")
419
ENDIF(ZORBA_XQUERYX)
420
421
422
#
423
# Xerces-C part 2 - version verification
424
#
425
IF (NOT ZORBA_NO_XMLSCHEMA)
426
  # Find XercesC Version based on ${XERCESC_INCLUDE}
427
  FIND_PACKAGE(XercesCVersion)
428
  
429
  IF (XERCESC_FOUND)
430
    COMPARE_VERSION_STRINGS("${XERCESC_VERSION}" 2.8.0 result)
431
432
    IF (result LESS 0)
433
      MESSAGE(FATAL_ERROR "Xerces-C ${XERCESC_VERSION} not supported.
434
	Only 2.8.0, 3.0.1 and newer versions are supported
435
	or
436
	Use -D ZORBA_NO_XMLSCHEMA=ON option for building without XMLSchema support.")
437
    ELSE (result LESS 0)
438
      MESSAGE(STATUS "Found Xerces ${XERCESC_VERSION} -- " ${XERCESC_INCLUDE}  ${XERCESC_LIBRARY})
439
      INCLUDE_DIRECTORIES(${XERCESC_INCLUDE})
440
      SET(requiredlibs ${requiredlibs} ${XERCESC_LIBRARY})
441
    ENDIF (result LESS 0)
442
  ELSE  (XERCESC_FOUND)
443
    MESSAGE(FATAL_ERROR "Xerces-C not found.
444
	Make sure you have Xerces-C 2.8.0 or 3.0.1+ installed
445
	or
446
	Use -D ZORBA_NO_XMLSCHEMA=ON option for building without XMLSchema support.")    
447
  ENDIF (XERCESC_FOUND)
448
ELSE (NOT ZORBA_NO_XMLSCHEMA)
449
  MESSAGE(STATUS "ZORBA_NO_XMLSCHEMA: ${ZORBA_NO_XMLSCHEMA}"
450
    " - build without XMLSchema support")
451
ENDIF (NOT ZORBA_NO_XMLSCHEMA)
452
453
IF(WIN32)
454
  SET(requiredlibs ${requiredlibs} wsock32)
455
  
10870.3.1 by David Graf
Generate the .vcproj in the '.bat-file-way'.
456
  # Clear those variables because this is used only for this build.
10461.2.4 by danielturcanu
Merged with latest trunk
457
  # A cache variable is needed since this must be modified by subdirectories
10870.3.1 by David Graf
Generate the .vcproj in the '.bat-file-way'.
458
  # and be visible at this level when ZORBA_GENERATE_EXE_HELPERS_WIN32 is called
10461.2.4 by danielturcanu
Merged with latest trunk
459
  SET(ZORBA_EXE_SCRIPT_LIST "" CACHE STRING "List of bat scripts" FORCE)
10870.3.1 by David Graf
Generate the .vcproj in the '.bat-file-way'.
460
  SET(ZORBA_VC_PROJECT_FILE_LIST "" CACHE STRING "List of VC project files" FORCE)
10461.2.4 by danielturcanu
Merged with latest trunk
461
ENDIF(WIN32)
462
463
################################################################################
464
# Variables
465
SET(DEFINITIONS)
466
467
################################################################################
468
# Custom user-defined settings
469
INCLUDE ("CMakeUser.txt" OPTIONAL)
470
471
472
################################################################################
473
# Compiler setup
474
475
# add the include dir (i.e. the library) to the include path
476
INCLUDE_DIRECTORIES(AFTER ${CMAKE_CURRENT_BINARY_DIR}/include)
477
INCLUDE_DIRECTORIES(AFTER ${CMAKE_CURRENT_SOURCE_DIR}/include)
478
479
# zorba versioning
480
SET(ZORBA_MAJOR_NUMBER "2")
11437.1.1 by chillery+launchpad at lambda
Bump Zorba version to 2.9.
481
SET(ZORBA_MINOR_NUMBER "9")
10520.2.1 by Chris Hillery
Replace ZORBA_MODULES_INSTALL_DIR with four different paths: core and
482
SET(ZORBA_PATCH_NUMBER "0")
10461.2.4 by danielturcanu
Merged with latest trunk
483
SET(ZORBA_VERSION ${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER})
484
MESSAGE(STATUS "Zorba version number: ${ZORBA_VERSION}")
10520.2.1 by Chris Hillery
Replace ZORBA_MODULES_INSTALL_DIR with four different paths: core and
485
486
SET(ZORBA_LIB_DIRNAME "lib" CACHE STRING
487
  "directory name for libs (may want to set to 'lib64' on 64-bit Linux platforms)")
488
489
# Directories for modules and schemas. "Core" are those which are
490
# shipped with Zorba and must be present for correct Zorba
491
# functionality. "Non-core" are developed independently of Zorba and
492
# have different version lifecycles.
493
#
494
# URI dir is for things resolved by URI - specifically modules (.xq
495
# files) and schemas (.xsd files) - which are platform-
496
# independent. Lib dir is for platform-specific files, specifically
497
# shared libraries for module external functions.
498
SET(ZORBA_NONCORE_URI_DIR "share/zorba/uris"
499
  CACHE STRING "Path (relative to installdir) to non-core modules/schemas")
500
MARK_AS_ADVANCED(ZORBA_NONCORE_URI_DIR)
10520.2.5 by Chris Hillery
1. Added documentation for URI and Library paths.
501
SET(ZORBA_CORE_URI_DIR "${ZORBA_NONCORE_URI_DIR}/core/${ZORBA_VERSION}"
502
  CACHE STRING "Path (relative to installdir) to core modules/schemas")
503
MARK_AS_ADVANCED(ZORBA_CORE_URI_DIR)
10520.2.1 by Chris Hillery
Replace ZORBA_MODULES_INSTALL_DIR with four different paths: core and
504
SET(ZORBA_NONCORE_LIB_DIR "${ZORBA_LIB_DIRNAME}/zorba"
505
  CACHE STRING "Path (relative to installdir) to non-core libraries")
506
MARK_AS_ADVANCED(ZORBA_NONCORE_LIB_DIR)
10520.2.5 by Chris Hillery
1. Added documentation for URI and Library paths.
507
SET(ZORBA_CORE_LIB_DIR "${ZORBA_NONCORE_LIB_DIR}/core/${ZORBA_VERSION}"
508
  CACHE STRING "Path (relative to installdir) to core libraries")
509
MARK_AS_ADVANCED(ZORBA_CORE_LIB_DIR)
10461.2.4 by danielturcanu
Merged with latest trunk
510
511
# add compiler variables
512
ADD_DEFINITIONS(${DEFINITIONS})
513
514
515
################################################################################
516
# find all dylib files (i.e. transitive closure of the library files
517
# that are linked)
518
IF(APPLE)
519
  EXECUTE_PROCESS(
520
    COMMAND ${CMAKE_SOURCE_DIR}/scripts/find_macosx_libraries.sh ${ICU_LIBRARIES}
521
    OUTPUT_VARIABLE Zorba_ICUUC)
522
  EXECUTE_PROCESS(
523
    COMMAND ${CMAKE_SOURCE_DIR}/scripts/find_macosx_libraries.sh ${ICU_I18N_LIBRARIES}
524
    OUTPUT_VARIABLE Zorba_ICUI18N)
525
  EXECUTE_PROCESS(
526
    COMMAND ${CMAKE_SOURCE_DIR}/scripts/find_macosx_libraries.sh ${ICU_DATA_LIBRARIES}
527
    OUTPUT_VARIABLE Zorba_ICU_DATA)
528
  EXECUTE_PROCESS(
529
    COMMAND ${CMAKE_SOURCE_DIR}/scripts/find_macosx_libraries.sh ${XERCESC_LIBRARY}
530
    OUTPUT_VARIABLE Zorba_XERCESC)
531
  EXECUTE_PROCESS(
532
    COMMAND ${CMAKE_SOURCE_DIR}/scripts/find_macosx_libraries.sh ${LIBXML2_LIBRARIES}
533
    OUTPUT_VARIABLE Zorba_XML2)
534
ENDIF(APPLE)
535
536
537
SET (ZORBA_MODULES_DIR "${CMAKE_SOURCE_DIR}/../zorba_modules"
538
  CACHE PATH "Path to directory (outside of Zorba svn root) containing external modules to add to the build")
539
540
# Subdir of the installation directory for CMake files, relative to
541
# CMAKE_INSTALL_PREFIX.
542
IF (WIN32)
543
  SET(ZORBA_CMAKE_DIR "cmake" CACHE STRING
544
    "Relative path to CMake files in Zorba installation")
545
ELSE (WIN32)
10520.2.5 by Chris Hillery
1. Added documentation for URI and Library paths.
546
  SET(ZORBA_CMAKE_DIR "share/cmake/zorba-${ZORBA_VERSION}" CACHE STRING
10461.2.4 by danielturcanu
Merged with latest trunk
547
    "Relative path to CMake files in Zorba installation")
548
ENDIF (WIN32)
549
550
################################################################################
551
#                                                                              #
552
# Tell CMake to process the sub-directories                                    #
553
#                                                                              #
554
################################################################################
555
556
ADD_SUBDIRECTORY(scripts)
557
ADD_SUBDIRECTORY(cmake_modules)
558
11138.3.1 by chillery+launchpad at lambda
First step: script to import FOTS archive and create ZORBA_ADD_TEST()
559
# Subdirectory ordering: We need to include "bin" before "test" so
560
# that test/fots can add zorbacmd-based tests. We need to include
561
# "test" before "config" so ZorbaConfig knows about testdriver. We
562
# need to include "config" before "modules" so external modules will
563
# be able to find ZorbaConfig.cmake. We need to include "modules"
564
# before "include" so config.h can know eg. whether we found CURL. We
565
# need to include "modules" before "doc" so xqdoc can know what
566
# non-core modules are available.
567
568
ADD_SUBDIRECTORY(bin)
10461.2.4 by danielturcanu
Merged with latest trunk
569
570
ADD_SUBDIRECTORY(test)
571
ADD_SUBDIRECTORY(config)
572
ADD_SUBDIRECTORY(schemas)
573
ADD_SUBDIRECTORY(modules)
10842.1.5 by chillery+launchpad at lambda
Added IS_ZORBA_MODULE_DECLARED() to determine whether a given module is part
574
ADD_SUBDIRECTORY(doc)
10643.1.1 by chillery+launchpad at lambda
Several fixes related to test breakages caused by zorba-xquery.com changes:
575
ADD_SUBDIRECTORY(include)
10461.2.4 by danielturcanu
Merged with latest trunk
576
577
ADD_DEFINITIONS(-Dzorba_EXPORTS)
578
ADD_SUBDIRECTORY(src)
579
REMOVE_DEFINITIONS(-Dzorba_EXPORTS)
580
581
IF (SWIG_FOUND)
582
  ADD_SUBDIRECTORY (swig)
583
ENDIF (SWIG_FOUND)
584
585
# add the uninstall support
586
# QQQ move to config/
587
CONFIGURE_FILE(
588
    "${CMAKE_CURRENT_SOURCE_DIR}/CMakeUninstall.cmake.in"
589
    "${CMAKE_CURRENT_BINARY_DIR}/CMakeUninstall.cmake"
590
    @ONLY)
591
ADD_CUSTOM_TARGET(uninstall
592
    "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/CMakeUninstall.cmake")
593
594
SET(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
595
INCLUDE(InstallRequiredSystemLibraries)
596
597
IF (NOT ZORBA_SKIP_CPACK)
598
  # QQQ move to config/ ?
599
  INCLUDE(CMakeCPack.cmake)
600
ENDIF (NOT ZORBA_SKIP_CPACK)
601
602
IF (APPLE AND UNIVERSAL)
603
  SET (CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "archs" FORCE)
604
  SET (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -v" )
605
  # The following is not the default when building universal
606
  INCLUDE_DIRECTORIES	(SYSTEM /usr/local/include)
607
  SET (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -v")
608
  MESSAGE ("Building Apple universal binaries")
609
ENDIF (APPLE AND UNIVERSAL)
610
611
IF (WIN32)
10870.3.1 by David Graf
Generate the .vcproj in the '.bat-file-way'.
612
  ZORBA_GENERATE_EXE_HELPERS_WIN32 ()
10461.2.4 by danielturcanu
Merged with latest trunk
613
ENDIF (WIN32)
614
615
# This must be done last! Create the one top-level target which
616
# depends on all generated (copied) module/schema files.
617
DONE_DECLARING_ZORBA_URIS()
618
619
# This dependency makes sure that the error and warning definition
620
# modules are generated before trying to install them as zorba modules.
621
# This dependency is zorba-only related, which is why it's added here
622
# and not within zorba-modules, which is for general use in other
623
# non-zorba modules.
10560.1.1 by Chris Hillery
Introduced check_core_uris target.
624
ADD_DEPENDENCIES(check_core_uris gen_diag_modules)