commonSetup.cmake 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052
  1. ################################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ################################################################################
  16. # File : commonSetup.cmake
  17. #
  18. #########################################################
  19. # Description:
  20. # ------------
  21. # sets up various cmake options.
  22. #########################################################
  23. IF ("${COMMONSETUP_DONE}" STREQUAL "")
  24. SET (COMMONSETUP_DONE 1)
  25. MACRO (MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage)
  26. STRING(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource)
  27. IF (insource)
  28. MESSAGE(FATAL_ERROR "${_errorMessage}")
  29. ENDIF(insource)
  30. ENDMACRO (MACRO_ENSURE_OUT_OF_SOURCE_BUILD)
  31. macro_ensure_out_of_source_build("The LexisNexis Hpcc requires an out of source build.
  32. Please remove the directory ${CMAKE_BINARY_DIR}/CMakeFiles
  33. and the file ${CMAKE_BINARY_DIR}/CMakeCache.txt,
  34. then create a separate build directory and run 'cmake path_to_source [options]' there.")
  35. cmake_policy ( SET CMP0011 NEW )
  36. if (NOT (CMAKE_MAJOR_VERSION LESS 3))
  37. cmake_policy ( SET CMP0026 OLD )
  38. if (NOT (CMAKE_MINOR_VERSION LESS 1))
  39. cmake_policy ( SET CMP0054 NEW )
  40. endif()
  41. endif()
  42. option(CLIENTTOOLS "Enable the building/inclusion of a Client Tools component." ON)
  43. option(PLATFORM "Enable the building/inclusion of a Platform component." ON)
  44. option(DEVEL "Enable the building/inclusion of a Development component." OFF)
  45. option(CLIENTTOOLS_ONLY "Enable the building of Client Tools only." OFF)
  46. option(INCLUDE_PLUGINS "Enable the building of platform and all plugins for testing purposes" OFF)
  47. option(USE_CASSANDRA "Include the Cassandra plugin in the base package" ON)
  48. option(PLUGIN "Enable building of a plugin" OFF)
  49. option(USE_SHLIBDEPS "Enable the use of dpkg-shlibdeps on ubuntu packaging" OFF)
  50. option(SIGN_MODULES "Enable signing of ecl standard library modules" OFF)
  51. option(USE_CPPUNIT "Enable unit tests (requires cppunit)" OFF)
  52. option(USE_OPENLDAP "Enable OpenLDAP support (requires OpenLDAP)" ON)
  53. option(USE_ICU "Enable unicode support (requires ICU)" ON)
  54. option(USE_BOOST_REGEX "Configure use of boost regex" ON)
  55. # USE_C11_REGEX is only checked if USE_BOOST_REGEX is OFF
  56. # to disable REGEX altogether turn both off
  57. option(USE_C11_REGEX "Configure use of c++11 std::regex" ON)
  58. option(Boost_USE_STATIC_LIBS "Use boost_regex static library for RPM BUILD" OFF)
  59. option(USE_OPENSSL "Configure use of OpenSSL" ON)
  60. option(USE_ZLIB "Configure use of zlib" ON)
  61. option(USE_CBLAS "Configure use of cblas" ON)
  62. if (WIN32)
  63. option(USE_GIT "Configure use of GIT (Hooks)" OFF)
  64. else()
  65. option(USE_GIT "Configure use of GIT (Hooks)" ON)
  66. endif()
  67. option(USE_LIBARCHIVE "Configure use of libarchive" ON)
  68. option(USE_URIPARSER "Configure use of uriparser" OFF)
  69. if (APPLE OR WIN32)
  70. option(USE_NUMA "Configure use of numa" OFF)
  71. else()
  72. option(USE_NUMA "Configure use of numa" ON)
  73. endif()
  74. IF (WIN32)
  75. option(USE_NATIVE_LIBRARIES "Search standard OS locations (otherwise in EXTERNALS_DIRECTORY) for 3rd party libraries" OFF)
  76. ELSE()
  77. option(USE_NATIVE_LIBRARIES "Search standard OS locations (otherwise in EXTERNALS_DIRECTORY) for 3rd party libraries" ON)
  78. ENDIF()
  79. option(USE_GIT_DESCRIBE "Use git describe to generate build tag" ON)
  80. option(CHECK_GIT_TAG "Require git tag to match the generated build tag" OFF)
  81. option(USE_XALAN "Configure use of xalan" OFF)
  82. option(USE_APR "Configure use of Apache Software Foundation (ASF) Portable Runtime (APR) libraries" ON)
  83. option(USE_LIBXSLT "Configure use of libxslt" ON)
  84. option(MAKE_DOCS "Create documentation at build time." OFF)
  85. option(MAKE_DOCS_ONLY "Create a base build with only docs." OFF)
  86. option(DOCS_DRUPAL "Create Drupal HTML Docs" OFF)
  87. option(DOCS_EPUB "Create EPUB Docs" OFF)
  88. option(DOCS_MOBI "Create Mobi Docs" OFF)
  89. option(DOCS_AUTO "DOCS automation" OFF)
  90. option(USE_RESOURCE "Use resource download in ECLWatch" OFF)
  91. option(GENERATE_COVERAGE_INFO "Generate coverage info for gcov" OFF)
  92. option(USE_SIGNED_CHAR "Build system with default char type is signed" OFF)
  93. option(USE_UNSIGNED_CHAR "Build system with default char type is unsigned" OFF)
  94. option(USE_MYSQL "Enable mysql support" ON)
  95. option(USE_LIBMEMCACHED "Enable libmemcached support" ON)
  96. option(USE_PYTHON2 "Enable python2 language support for platform build" ON)
  97. option(USE_PYTHON3 "Enable python3 language support for platform build" ON)
  98. option(USE_OPTIONAL "Automatically disable requested features with missing dependencies" ON)
  99. option(JLIB_ONLY "Build JLIB for other projects such as Configurator, Ganglia Monitoring, etc" OFF)
  100. # Generates code that is more efficient, but will cause problems if target platforms do not support it.
  101. if (CMAKE_SIZEOF_VOID_P EQUAL 8)
  102. option(USE_INLINE_TSC "Inline calls to read TSC (time stamp counter)" ON)
  103. else()
  104. option(USE_INLINE_TSC "Inline calls to read TSC (time stamp counter)" OFF)
  105. endif()
  106. if (APPLE OR WIN32)
  107. option(USE_TBB "Enable Threading Building Block support" OFF)
  108. else()
  109. option(USE_TBB "Enable Threading Building Block support" ON)
  110. option(USE_TBBMALLOC "Enable Threading Building Block scalable allocator proxy support" OFF)
  111. option(USE_TBBMALLOC_ROXIE "Enable Threading Building Block scalable allocator proxy support in Roxie" OFF)
  112. endif()
  113. option(LOGGING_SERVICE "Configure use of logging service" ON)
  114. option(WSSQL_SERVICE "Configure use of ws_sql service" ON)
  115. option(USE_DIGISIGN "Use digisign" ON)
  116. set(CUSTOM_PACKAGE_SUFFIX "" CACHE STRING "Custom package suffix to differentiate development builds")
  117. MACRO(SET_PLUGIN_PACKAGE plugin)
  118. string(TOLOWER "${plugin}" pname)
  119. if(DEFINED pluginname)
  120. message(FATAL_ERROR "Cannot enable ${pname}, already declared ${pluginname}")
  121. else()
  122. set(pluginname "${pname}")
  123. endif()
  124. foreach(p in ${PLUGINS_LIST})
  125. if(NOT "${p}" STREQUAL "${plugin}" AND ${p})
  126. message(FATAL_ERROR "Cannot declare multiple plugins in a plugin package")
  127. endif()
  128. endforeach()
  129. set(PLUGIN ON)
  130. set(CLIENTTOOLS OFF)
  131. set(PLATFORM OFF)
  132. set(INCLUDE_PLUGINS OFF)
  133. set(SIGN_MODULES OFF)
  134. set(USE_OPTIONAL OFF) # Force failure if we can't find the plugin dependencies
  135. ENDMACRO()
  136. # Plugin options
  137. set(PLUGINS_LIST
  138. REMBED
  139. V8EMBED
  140. MEMCACHED
  141. REDIS
  142. SQS
  143. MYSQLEMBED
  144. JAVAEMBED
  145. SQLITE3EMBED
  146. KAFKA
  147. COUCHBASEEMBED
  148. SPARK
  149. EXAMPLEPLUGIN)
  150. foreach(plugin ${PLUGINS_LIST})
  151. option(${plugin} "Create a package with ONLY the ${plugin} plugin" OFF)
  152. option(INCLUDE_${plugin} "Include ${plugin} within package for testing" OFF)
  153. option(SUPPRESS_${plugin} "Suppress ${plugin} from INCLUDE_PLUGINS build" OFF)
  154. # Plugin Release build for individual package
  155. if(${plugin})
  156. SET_PLUGIN_PACKAGE("${plugin}")
  157. # Development build with all plugins for testing
  158. # Development build with addition of plugin
  159. elseif((INCLUDE_PLUGINS OR INCLUDE_${plugin}) AND (NOT SUPPRESS_${plugin}) AND (NOT PLUGIN))
  160. set(${plugin} ON)
  161. endif()
  162. endforeach()
  163. #"cmake -DEXAMPLEPLUGIN=ON <path-to/HPCC-Platform/>" will configure the plugin makefiles to be built with "make".
  164. set(CMAKE_MODULE_PATH "${HPCC_SOURCE_DIR}/cmake_modules/")
  165. if ( NOT MAKE_DOCS_ONLY )
  166. set(LIBMEMCACHED_MINVERSION "1.0.10")
  167. if(USE_LIBMEMCACHED)
  168. if(WIN32)
  169. message(STATUS "libmemcached not available on windows. Disabling for build")
  170. set(USE_LIBMEMCACHED OFF)
  171. else()
  172. find_package(LIBMEMCACHED ${LIBMEMCACHED_MINVERSION} REQUIRED)
  173. add_definitions(-DUSE_LIBMEMCACHED)
  174. include_directories(${LIBMEMCACHED_INCLUDE_DIR})
  175. endif()
  176. endif()
  177. endif()
  178. if (SIGN_MODULES)
  179. message(STATUS "GPG signing check")
  180. execute_process(COMMAND bash "-c" "gpg --version | awk 'NR==1{print $3}'"
  181. OUTPUT_VARIABLE GPG_VERSION
  182. OUTPUT_STRIP_TRAILING_WHITESPACE
  183. ERROR_QUIET)
  184. set(GPG_COMMAND_STR "gpg")
  185. if(${GPG_VERSION} VERSION_GREATER "2.1")
  186. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --pinentry-mode loopback --batch --no-tty")
  187. else()
  188. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --batch --no-tty")
  189. endif()
  190. if(DEFINED SIGN_MODULES_PASSPHRASE)
  191. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --passphrase ${SIGN_MODULES_PASSPHRASE}")
  192. endif()
  193. if(DEFINED SIGN_MODULES_KEYID)
  194. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --default-key ${SIGN_MODULES_KEYID}")
  195. endif()
  196. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --output sm_keycheck.asc --clearsign sm_keycheck.tmp")
  197. execute_process(COMMAND rm -f sm_keycheck.tmp sm_keycheck.asc TIMEOUT 5
  198. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} OUTPUT_QUIET ERROR_QUIET)
  199. execute_process(COMMAND touch sm_keycheck.tmp TIMEOUT 5
  200. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} RESULT_VARIABLE t_rc
  201. OUTPUT_QUIET ERROR_QUIET)
  202. if(NOT "${t_rc}" STREQUAL "0")
  203. message(FATAL_ERROR "Failed to create sm_keycheck.tmp for signing")
  204. endif()
  205. execute_process(
  206. COMMAND bash "-c" "${GPG_COMMAND_STR}"
  207. TIMOUT 120
  208. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  209. RESULT_VARIABLE rc_var
  210. OUTPUT_VARIABLE out_var
  211. ERROR_VARIABLE err_var
  212. )
  213. if(NOT "${rc_var}" STREQUAL "0")
  214. message(STATUS "GPG signing check - failed")
  215. message(FATAL_ERROR "gpg signing of std ecllibrary unsupported in current environment. \
  216. If you wish to build without a signed std ecllibrary add -DSIGN_MODULES=OFF to your \
  217. cmake invocation.\n${err_var}")
  218. else()
  219. message(STATUS "GPG signing check - done")
  220. endif()
  221. endif()
  222. if ( USE_XALAN AND USE_LIBXSLT )
  223. set(USE_LIBXSLT OFF)
  224. endif()
  225. if ( USE_LIBXSLT )
  226. set(USE_LIBXML2 ON)
  227. endif()
  228. if ( USE_XALAN )
  229. set(USE_XERCES ON)
  230. endif()
  231. if ( MAKE_DOCS AND CLIENTTOOLS_ONLY )
  232. set( MAKE_DOCS OFF )
  233. endif()
  234. if ( MAKE_DOCS_ONLY AND NOT CLIENTTOOLS_ONLY )
  235. set( MAKE_DOCS ON )
  236. if ( USE_DOCS_AUTO )
  237. set ( DOCS_AUTO ON)
  238. endif()
  239. endif()
  240. if ( CLIENTTOOLS_ONLY )
  241. set(PLATFORM OFF)
  242. set(DEVEL OFF)
  243. endif()
  244. option(PORTALURL "Set url to hpccsystems portal download page")
  245. if ( NOT PORTALURL )
  246. set( PORTALURL "http://hpccsystems.com/download" )
  247. endif()
  248. if(UNIX AND SIGN_MODULES)
  249. execute_process(COMMAND bash "-c" "gpg --version | awk 'NR==1{print $3}'"
  250. OUTPUT_VARIABLE GPG_VERSION
  251. OUTPUT_STRIP_TRAILING_WHITESPACE
  252. ERROR_QUIET)
  253. message(STATUS "gpg version ${GPG_VERSION}")
  254. #export gpg public key used for signing to new installation
  255. add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/pub.key
  256. COMMAND bash "-c" "gpg --output=${CMAKE_BINARY_DIR}/pub.key --batch --no-tty --export ${SIGN_MODULES_KEYID}"
  257. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  258. COMMENT "Exporting public key for eclcc signed modules to ${CMAKE_BINARY_DIR}/pub.key"
  259. VERBATIM
  260. )
  261. add_custom_target(export-stdlib-pubkey ALL
  262. DEPENDS ${CMAKE_BINARY_DIR}/pub.key
  263. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  264. )
  265. install(FILES ${CMAKE_BINARY_DIR}/pub.key DESTINATION .${CONFIG_DIR}/rpmnew COMPONENT Runtime)
  266. install(PROGRAMS ${CMAKE_MODULE_PATH}publickey.install DESTINATION etc/init.d/install COMPONENT Runtime)
  267. endif()
  268. ##########################################################
  269. # common compiler/linker flags
  270. if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
  271. set ( CMAKE_BUILD_TYPE "Release" )
  272. elseif (NOT "${CMAKE_BUILD_TYPE}" MATCHES "^Debug$|^Release$|^RelWithDebInfo$")
  273. message (FATAL_ERROR "Unknown build type ${CMAKE_BUILD_TYPE}")
  274. endif ()
  275. message ("-- Making ${CMAKE_BUILD_TYPE} system")
  276. if (CMAKE_SIZEOF_VOID_P EQUAL 8)
  277. set ( ARCH64BIT 1 )
  278. else ()
  279. set ( ARCH64BIT 0 )
  280. endif ()
  281. message ("-- 64bit architecture is ${ARCH64BIT}")
  282. set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DDEBUG")
  283. IF (USE_INLINE_TSC)
  284. add_definitions (-DINLINE_GET_CYCLES_NOW)
  285. ENDIF()
  286. set (CMAKE_THREAD_PREFER_PTHREAD 1)
  287. find_package(Threads)
  288. IF (NOT THREADS_FOUND)
  289. message(FATAL_ERROR "No threading support found")
  290. ENDIF()
  291. if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
  292. set (CMAKE_COMPILER_IS_CLANGXX 1)
  293. endif()
  294. if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
  295. set (CMAKE_COMPILER_IS_CLANG 1)
  296. endif()
  297. if ((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) AND (NOT ${CMAKE_C_COMPILER_VERSION} MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+"))
  298. execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE CMAKE_C_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
  299. endif ()
  300. if ((CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) AND (NOT ${CMAKE_CXX_COMPILER_VERSION} MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+"))
  301. execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
  302. endif()
  303. if (CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
  304. add_definitions (-fvisibility=hidden)
  305. endif ()
  306. if (CMAKE_COMPILER_IS_CLANGXX)
  307. execute_process( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string )
  308. if (${clang_full_version_string} MATCHES "Apple LLVM version ([0-9]+\\.[0-9]+\\.[0-9]+).*")
  309. string (REGEX REPLACE "Apple LLVM version ([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1" APPLE_CLANG_VERSION ${clang_full_version_string})
  310. endif()
  311. if (${clang_full_version_string} MATCHES ".*based on LLVM ([0-9]+\\.[0-9]+).*")
  312. string (REGEX REPLACE ".*based on LLVM ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION ${clang_full_version_string})
  313. else()
  314. if (${clang_full_version_string} MATCHES ".*clang version ([0-9]+\\.[0-9]+).*")
  315. string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION ${clang_full_version_string})
  316. endif()
  317. endif()
  318. endif ()
  319. if (WIN32)
  320. # On windows, the vcproj generator generates both windows and debug build capabilities, and the release mode is appended to the directory later
  321. # This output location matches what our existing windows release scripts expect - might make sense to move out of tree sometime though
  322. set ( EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" )
  323. set ( LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" )
  324. # Workaround CMake's odd decision to default windows stack size to 10000000
  325. STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
  326. SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
  327. if (${ARCH64BIT} EQUAL 1)
  328. add_definitions(/bigobj)
  329. endif ()
  330. if ("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
  331. if (${ARCH64BIT} EQUAL 0)
  332. add_definitions(/ZI)
  333. else()
  334. add_definitions(/Zi)
  335. endif ()
  336. endif ()
  337. if ("${GIT_COMMAND}" STREQUAL "")
  338. set ( GIT_COMMAND "git.cmd" )
  339. endif ()
  340. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHa")
  341. if (USE_SIGNED_CHAR AND USE_UNSIGNED_CHAR )
  342. message (FATAL_ERROR "Can't use USE_SIGNED_CHAR and USE_UNSIGNED_CHAR together!")
  343. else()
  344. if (USE_SIGNED_CHAR)
  345. message ("Build system with signed char type.")
  346. # This is default for MSVC
  347. endif ()
  348. if (USE_UNSIGNED_CHAR )
  349. message ("Build system with unsigned char type.")
  350. add_definitions(/J)
  351. endif ()
  352. endif ()
  353. #=== WARNING ======
  354. # Temporary disable warnings. Reenable them one by one to reexamine and fix them.
  355. IF (NOT ALL_WARNINGS_ON)
  356. set (WARNINGS_IGNORE "/wd4267 /wd4244 /wd6340 /wd6297 /wd4018 /wd4302 /wd4311 /wd4320 /wd4800") # data conversion warnings
  357. set (WARNINGS_IGNORE "${WARNINGS_IGNORE} /wd4251 /wd4275") # dll-interface for used by clients
  358. set (WARNINGS_IGNORE "${WARNINGS_IGNORE} /wd6246") # local variable hidden by outer scope
  359. set (WARNINGS_IGNORE "${WARNINGS_IGNORE} /wd6031") # Return value ignored
  360. set (WARNINGS_IGNORE "${WARNINGS_IGNORE} /wd4005") # MACRO redef: same value
  361. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNINGS_IGNORE}")
  362. ENDIF()
  363. else ()
  364. if (NOT CMAKE_USE_PTHREADS_INIT)
  365. message (FATAL_ERROR "pthreads support not detected")
  366. endif ()
  367. set ( EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/bin" )
  368. set ( LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/libs" )
  369. if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
  370. message ("Using compiler: ${CMAKE_CXX_COMPILER_ID} :: ${CMAKE_CXX_COMPILER_VERSION} :: ${CLANG_VERSION} :: ${APPLE_CLANG_VERSION}")
  371. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti -fPIC -fmessage-length=0 -Werror=format -Wformat-security -Wformat-nonliteral -pthread -Wuninitialized")
  372. SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic")
  373. SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -fno-inline-functions")
  374. if (CMAKE_COMPILER_IS_GNUCXX)
  375. SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -fno-default-inline")
  376. if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.2.4 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.2.4)
  377. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type -Werror=format-nonliteral")
  378. endif ()
  379. if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.4.0)
  380. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi")
  381. endif ()
  382. if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 2.95.3 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 2.95.3)
  383. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wparentheses")
  384. endif ()
  385. endif ()
  386. SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE}")
  387. SET (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE}")
  388. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  389. if (GENERATE_COVERAGE_INFO)
  390. message ("Build system with coverage.")
  391. if (CMAKE_COMPILER_IS_CLANGXX)
  392. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
  393. else()
  394. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
  395. endif()
  396. endif()
  397. # Handle forced default char type
  398. if (USE_SIGNED_CHAR AND USE_UNSIGNED_CHAR )
  399. message (FATAL_ERROR "Can't use USE_SIGNED_CHAR and USE_UNSIGNED_CHAR together!")
  400. else()
  401. if (USE_SIGNED_CHAR)
  402. message ("Build system with signed char type.")
  403. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char")
  404. endif ()
  405. if (USE_UNSIGNED_CHAR )
  406. message ("Build system with unsigned char type.")
  407. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funsigned-char")
  408. endif ()
  409. endif ()
  410. endif ()
  411. if (CMAKE_COMPILER_IS_CLANGXX)
  412. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=logical-op-parentheses -Werror=bool-conversions -Werror=return-type -Werror=comment")
  413. if (APPLE)
  414. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
  415. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
  416. endif ()
  417. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=bitwise-op-parentheses -Werror=tautological-compare")
  418. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch-enum -Wno-format-zero-length -Wno-switch")
  419. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments") # Silence messages about pthread not being used when linking...
  420. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override -Wno-unknown-warning-option") # Until we fix them all, whcih would be a huge task...
  421. if (CLANG_VERSION VERSION_GREATER 3.6 OR CLANG_VERSION VERSION_EQUAL 3.6 OR APPLE_CLANG_VERSION VERSION_GREATER 6.0)
  422. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pointer-bool-conversion")
  423. endif()
  424. endif()
  425. # All of these are defined in platform.h too, but need to be defned before any system header is included
  426. ADD_DEFINITIONS (-D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -D__USE_LARGEFILE64=1 -D__USE_FILE_OFFSET64=1)
  427. if ("${GIT_COMMAND}" STREQUAL "")
  428. set ( GIT_COMMAND "git" )
  429. endif ()
  430. endif ()
  431. macro(HPCC_ADD_EXECUTABLE target)
  432. add_executable(${target} ${ARGN})
  433. endmacro(HPCC_ADD_EXECUTABLE target)
  434. macro(HPCC_ADD_LIBRARY target)
  435. add_library(${target} ${ARGN})
  436. endmacro(HPCC_ADD_LIBRARY target)
  437. # This Macro is provided as Public domain from
  438. # http://www.cmake.org/Wiki/CMakeMacroParseArguments
  439. MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
  440. SET(DEFAULT_ARGS)
  441. FOREACH(arg_name ${arg_names})
  442. SET(${prefix}_${arg_name})
  443. ENDFOREACH(arg_name)
  444. FOREACH(option ${option_names})
  445. SET(${prefix}_${option} FALSE)
  446. ENDFOREACH(option)
  447. SET(current_arg_name DEFAULT_ARGS)
  448. SET(current_arg_list)
  449. FOREACH(arg ${ARGN})
  450. SET(larg_names ${arg_names})
  451. LIST(FIND larg_names "${arg}" is_arg_name)
  452. IF (is_arg_name GREATER -1)
  453. SET(${prefix}_${current_arg_name} ${current_arg_list})
  454. SET(current_arg_name ${arg})
  455. SET(current_arg_list)
  456. ELSE (is_arg_name GREATER -1)
  457. SET(loption_names ${option_names})
  458. LIST(FIND loption_names "${arg}" is_option)
  459. IF (is_option GREATER -1)
  460. SET(${prefix}_${arg} TRUE)
  461. ELSE (is_option GREATER -1)
  462. SET(current_arg_list ${current_arg_list} ${arg})
  463. ENDIF (is_option GREATER -1)
  464. ENDIF (is_arg_name GREATER -1)
  465. ENDFOREACH(arg)
  466. SET(${prefix}_${current_arg_name} ${current_arg_list})
  467. ENDMACRO(PARSE_ARGUMENTS)
  468. # This macro allows for disabling a directory based on the value of a variable passed to the macro.
  469. #
  470. # ex. HPCC_ADD_SUBDIRECORY(roxie ${CLIENTTOOLS_ONLY})
  471. #
  472. # This call will disable the roxie dir if -DCLIENTTOOLS_ONLY=ON is set at config time.
  473. #
  474. macro(HPCC_ADD_SUBDIRECTORY)
  475. set(adddir OFF)
  476. PARSE_ARGUMENTS(_HPCC_SUB "" "" ${ARGN})
  477. LIST(GET _HPCC_SUB_DEFAULT_ARGS 0 subdir)
  478. set(flags ${_HPCC_SUB_DEFAULT_ARGS})
  479. LIST(REMOVE_AT flags 0)
  480. LIST(LENGTH flags length)
  481. if(NOT length)
  482. set(adddir ON)
  483. else()
  484. foreach(f ${flags})
  485. if(${f})
  486. set(adddir ON)
  487. endif()
  488. endforeach()
  489. endif()
  490. if ( adddir )
  491. add_subdirectory(${subdir})
  492. endif()
  493. endmacro(HPCC_ADD_SUBDIRECTORY)
  494. set ( SCM_GENERATED_DIR ${CMAKE_BINARY_DIR}/generated )
  495. ###############################################################
  496. # Macro for Logging Plugin build in CMake
  497. macro(LOG_PLUGIN)
  498. PARSE_ARGUMENTS(pLOG
  499. "OPTION;MDEPS"
  500. ""
  501. ${ARGN})
  502. LIST(GET pLOG_DEFAULT_ARGS 0 PLUGIN_NAME)
  503. if(${pLOG_OPTION})
  504. message(STATUS "Building Plugin: ${PLUGIN_NAME}" )
  505. else()
  506. message(WARNING "Not Building Plugin: ${PLUGIN_NAME}")
  507. foreach (dep ${pLOG_MDEPS})
  508. message(WARNING "Missing dependency: ${dep}")
  509. endforeach()
  510. if(NOT USE_OPTIONAL)
  511. message(FATAL_ERROR "Optional dependencies missing and USE_OPTIONAL OFF")
  512. endif()
  513. endif()
  514. endmacro()
  515. ###############################################################
  516. # Macro for adding an optional plugin to the CMake build.
  517. macro(ADD_PLUGIN)
  518. PARSE_ARGUMENTS(PLUGIN
  519. "PACKAGES;MINVERSION;MAXVERSION"
  520. ""
  521. ${ARGN})
  522. LIST(GET PLUGIN_DEFAULT_ARGS 0 PLUGIN_NAME)
  523. string(TOUPPER ${PLUGIN_NAME} name)
  524. set(ALL_PLUGINS_FOUND 1)
  525. set(PLUGIN_MDEPS ${PLUGIN_NAME}_mdeps)
  526. set(${PLUGIN_MDEPS} "")
  527. foreach(package ${PLUGIN_PACKAGES})
  528. set(findvar ${package}_FOUND)
  529. string(TOUPPER ${findvar} PACKAGE_FOUND)
  530. if("${PLUGIN_MINVERSION}" STREQUAL "")
  531. find_package(${package})
  532. else()
  533. set(findvar ${package}_VERSION_STRING)
  534. string(TOUPPER ${findvar} PACKAGE_VERSION_STRING)
  535. find_package(${package} ${PLUGIN_MINVERSION} )
  536. if ("${${PACKAGE_VERSION_STRING}}" VERSION_GREATER "${PLUGIN_MAXVERSION}")
  537. set(${ALL_PLUGINS_FOUND} 0)
  538. endif()
  539. endif()
  540. if(NOT ${PACKAGE_FOUND})
  541. set(ALL_PLUGINS_FOUND 0)
  542. set(${PLUGIN_MDEPS} ${${PLUGIN_MDEPS}} ${package})
  543. endif()
  544. endforeach()
  545. set(MAKE_${name} ${ALL_PLUGINS_FOUND})
  546. LOG_PLUGIN(${PLUGIN_NAME} OPTION ${ALL_PLUGINS_FOUND} MDEPS ${${PLUGIN_MDEPS}})
  547. if(${ALL_PLUGINS_FOUND})
  548. set(bPLUGINS ${bPLUGINS} ${PLUGIN_NAME})
  549. else()
  550. set(nbPLUGINS ${nbPLUGINS} ${PLUGIN_NAME})
  551. endif()
  552. endmacro()
  553. ##################################################################
  554. # Build tag generation
  555. set(projname ${HPCC_PROJECT})
  556. set(majorver ${HPCC_MAJOR})
  557. set(minorver ${HPCC_MINOR})
  558. set(point ${HPCC_POINT})
  559. if ( "${HPCC_MATURITY}" STREQUAL "release" )
  560. set(stagever "${HPCC_SEQUENCE}")
  561. else()
  562. set(stagever "${HPCC_MATURITY}${HPCC_SEQUENCE}")
  563. endif()
  564. set(version ${majorver}.${minorver}.${point})
  565. IF ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  566. set( stagever "${stagever}Debug" )
  567. ENDIF ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  568. ###########################################################################
  569. if(USE_OPTIONAL)
  570. message(WARNING "USE_OPTIONAL set - missing dependencies for optional features will automatically disable them")
  571. endif()
  572. if(NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
  573. message(STATUS "Using externals directory at ${EXTERNALS_DIRECTORY}")
  574. endif()
  575. IF ( NOT MAKE_DOCS_ONLY )
  576. IF ("${EXTERNALS_DIRECTORY}" STREQUAL "")
  577. SET(bisoncmd "bison")
  578. SET(flexcmd "flex")
  579. ELSE()
  580. IF (WIN32)
  581. SET(bisoncmdprefix "call")
  582. SET(flexcmdprefix "call")
  583. SET(bisoncmd "${EXTERNALS_DIRECTORY}\\bison\\bison.bat")
  584. SET(flexcmd "${EXTERNALS_DIRECTORY}\\bison\\flex.bat")
  585. ELSE ()
  586. SET(bisoncmd "${EXTERNALS_DIRECTORY}/bison/bison")
  587. SET(flexcmd "${EXTERNALS_DIRECTORY}/bison/flex")
  588. ENDIF()
  589. ENDIF()
  590. IF ("${BISON_VERSION}" STREQUAL "")
  591. IF (WIN32)
  592. # cmake bug workaround - it converts path separators fine in add_custom_command but not here
  593. STRING(REPLACE "/" "\\" BISON_exename "${bisoncmd}")
  594. ELSE()
  595. SET(BISON_exename "${bisoncmd}")
  596. ENDIF()
  597. EXECUTE_PROCESS(COMMAND ${BISON_exename} --version
  598. OUTPUT_VARIABLE BISON_version_output
  599. ERROR_VARIABLE BISON_version_error
  600. RESULT_VARIABLE BISON_version_result
  601. OUTPUT_STRIP_TRAILING_WHITESPACE)
  602. STRING(REGEX REPLACE "^[^0-9]*([0-9.]+).*" "\\1" BISON_VERSION "${BISON_version_output}")
  603. ENDIF()
  604. IF ("${FLEX_VERSION}" STREQUAL "")
  605. IF (WIN32)
  606. # cmake bug workaround - it converts path separators fine in add_custom_command but not here
  607. STRING(REPLACE "/" "\\" FLEX_exename "${flexcmd}")
  608. ELSE()
  609. SET(FLEX_exename "${flexcmd}")
  610. ENDIF()
  611. EXECUTE_PROCESS(COMMAND ${FLEX_exename} --version
  612. OUTPUT_VARIABLE FLEX_version_output
  613. ERROR_VARIABLE FLEX_version_error
  614. RESULT_VARIABLE FLEX_version_result
  615. OUTPUT_STRIP_TRAILING_WHITESPACE)
  616. STRING(REGEX REPLACE "^[^0-9]*([0-9.]+).*" "\\1" FLEX_VERSION "${FLEX_version_output}")
  617. ENDIF()
  618. IF ("${BISON_VERSION}" VERSION_LESS "2.4.1")
  619. MESSAGE(FATAL_ERROR "You need bison version 2.4.1 or later to build this project (version ${BISON_VERSION} detected)")
  620. ENDIF()
  621. IF ("${BISON_VERSION}" VERSION_LESS "2.7.0")
  622. #Ignore all warnings - not recommend to develope on this version!
  623. SET(bisonopt "-Wnone")
  624. ELSE()
  625. SET(bisonopt -Werror -Wno-other)
  626. ENDIF()
  627. IF ("${FLEX_VERSION}" VERSION_LESS "2.5.35")
  628. MESSAGE(FATAL_ERROR "You need flex version 2.5.35 or later to build this project (version ${FLEX_VERSION} detected)")
  629. ENDIF()
  630. IF (CMAKE_COMPILER_IS_GNUCXX)
  631. IF ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.7.3")
  632. MESSAGE(FATAL_ERROR "You need Gnu c++ version 4.7.3 or later to build this project (version ${CMAKE_CXX_COMPILER_VERSION} detected)")
  633. ENDIF()
  634. ENDIF()
  635. ENDIF()
  636. ###########################################################################
  637. # External library setup - some can be optionally selected based on USE_xxx flags, some are required
  638. IF (MAKE_DOCS)
  639. find_package(XSLTPROC)
  640. IF (XSLTPROC_FOUND)
  641. add_definitions (-D_USE_XSLTPROC)
  642. ELSE()
  643. message(FATAL_ERROR "XSLTPROC requested but package not found")
  644. ENDIF()
  645. find_package(FOP)
  646. IF (FOP_FOUND)
  647. add_definitions (-D_USE_FOP)
  648. ELSE()
  649. message(FATAL_ERROR "FOP requested but package not found")
  650. ENDIF()
  651. IF ( DOCS_AUTO )
  652. find_package(SAXON)
  653. IF (SAXON_FOUND)
  654. add_definitions (-D_USE_SAXON)
  655. ELSE()
  656. message(FATAL_ERROR "SAXON, a XSLT and XQuery processor, is required for documentation build but not found.")
  657. ENDIF()
  658. ENDIF()
  659. ENDIF(MAKE_DOCS)
  660. IF ( NOT MAKE_DOCS_ONLY )
  661. IF (USE_OPENLDAP)
  662. find_package(OPENLDAP)
  663. IF (OPENLDAP_FOUND)
  664. add_definitions (-D_USE_OPENLDAP)
  665. ELSE()
  666. message(FATAL_ERROR "OPENLDAP requested but package not found")
  667. ENDIF()
  668. ELSE()
  669. add_definitions (-D_NO_LDAP)
  670. ENDIF(USE_OPENLDAP)
  671. IF (USE_CPPUNIT)
  672. find_package(CPPUNIT)
  673. IF (CPPUNIT_FOUND)
  674. add_definitions (-D_USE_CPPUNIT)
  675. include_directories(${CPPUNIT_INCLUDE_DIR})
  676. ELSE()
  677. message(FATAL_ERROR "CPPUNIT requested but package not found")
  678. ENDIF()
  679. ELSE()
  680. SET(CPPUNIT_INCLUDE_DIR "")
  681. SET(CPPUNIT_LIBRARIES "")
  682. ENDIF(USE_CPPUNIT)
  683. IF (USE_ICU)
  684. find_package(ICU)
  685. IF (ICU_FOUND)
  686. add_definitions (-D_USE_ICU)
  687. IF (NOT WIN32)
  688. add_definitions (-DUCHAR_TYPE=uint16_t)
  689. ENDIF()
  690. include_directories(${ICU_INCLUDE_DIR})
  691. ELSE()
  692. message(FATAL_ERROR "ICU requested but package not found")
  693. ENDIF()
  694. ENDIF(USE_ICU)
  695. if(USE_XALAN)
  696. find_package(XALAN)
  697. if (XALAN_FOUND)
  698. add_definitions (-D_USE_XALAN)
  699. else()
  700. message(FATAL_ERROR "XALAN requested but package not found")
  701. endif()
  702. endif(USE_XALAN)
  703. if(USE_LIBXSLT)
  704. find_package(LIBXSLT)
  705. if (LIBXSLT_FOUND)
  706. add_definitions (-D_USE_LIBXSLT)
  707. else()
  708. message(FATAL_ERROR "LIBXSLT requested but package not found")
  709. endif()
  710. endif(USE_LIBXSLT)
  711. if(USE_XERCES)
  712. find_package(XERCES)
  713. if (XERCES_FOUND)
  714. add_definitions (-D_USE_XERCES)
  715. else()
  716. message(FATAL_ERROR "XERCES requested but package not found")
  717. endif()
  718. endif(USE_XERCES)
  719. if(USE_LIBXML2)
  720. find_package(LIBXML2)
  721. if (LIBXML2_FOUND)
  722. add_definitions (-D_USE_LIBXML2)
  723. else()
  724. message(FATAL_ERROR "LIBXML2 requested but package not found")
  725. endif()
  726. endif(USE_LIBXML2)
  727. if(USE_CBLAS)
  728. find_package(CBLAS)
  729. if(CBLAS_FOUND)
  730. add_definitions(-D_USE_CBLAS)
  731. else()
  732. message(FATAL_ERROR "CBLAS requested but package not found")
  733. endif()
  734. endif(USE_CBLAS)
  735. if(USE_ZLIB)
  736. find_package(ZLIB)
  737. if (ZLIB_FOUND)
  738. add_definitions (-D_USE_ZLIB)
  739. else()
  740. message(FATAL_ERROR "ZLIB requested but package not found")
  741. endif()
  742. endif(USE_ZLIB)
  743. if(USE_LIBARCHIVE)
  744. if (WIN32)
  745. if(NOT USE_ZLIB)
  746. message(FATAL ERROR "LIBARCHIVE requires ZLIB")
  747. endif(NOT USE_ZLIB)
  748. find_package(BZip2)
  749. if (BZIP2_FOUND)
  750. add_definitions (-D_USE_BZIP2)
  751. else()
  752. message(FATAL_ERROR "LIBARCHIVE requires BZIP2 but package not found")
  753. endif()
  754. endif (WIN32)
  755. find_package(LIBARCHIVE)
  756. if (LIBARCHIVE_FOUND)
  757. add_definitions (-D_USE_LIBARCHIVE)
  758. else()
  759. message(FATAL_ERROR "LIBARCHIVE requested but package not found")
  760. endif()
  761. endif(USE_LIBARCHIVE)
  762. if(USE_URIPARSER)
  763. find_package(Uriparser)
  764. if (URIPARSER_FOUND)
  765. add_definitions (-D_USE_URIPARSER)
  766. else()
  767. message(FATAL_ERROR "URIPARSER requested but package not found")
  768. endif()
  769. endif(USE_URIPARSER)
  770. if(USE_BOOST_REGEX)
  771. find_package(BOOST_REGEX)
  772. if (BOOST_REGEX_FOUND)
  773. message(STATUS "BOOST_REGEX enabled")
  774. add_definitions (-D_USE_BOOST_REGEX)
  775. else()
  776. message(FATAL_ERROR "BOOST_REGEX requested but package not found")
  777. endif()
  778. else(USE_BOOST_REGEX)
  779. if (USE_C11_REGEX)
  780. if ((NOT CMAKE_COMPILER_IS_GNUCC) OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9.0))
  781. message(STATUS "C11_REGEX enabled")
  782. add_definitions (-D_USE_C11_REGEX)
  783. else()
  784. message(STATUS "C11_REGEX requested but not supported on this platform")
  785. endif()
  786. else(USE_C11_REGEX)
  787. message(STATUS "NO REGEX requested")
  788. endif(USE_C11_REGEX)
  789. endif(USE_BOOST_REGEX)
  790. if(USE_OPENSSL)
  791. find_package(OPENSSL)
  792. if (OPENSSL_FOUND)
  793. add_definitions (-D_USE_OPENSSL)
  794. include_directories(${OPENSSL_INCLUDE_DIR})
  795. link_directories(${OPENSSL_LIBRARY_DIR})
  796. else()
  797. message(FATAL_ERROR "OPENSSL requested but package not found")
  798. endif()
  799. endif(USE_OPENSSL)
  800. if(USE_MYSQL_REPOSITORY)
  801. find_package(MYSQL)
  802. if (MYSQL_FOUND)
  803. add_definitions (-D_USE_MYSQL_REPOSITORY)
  804. else()
  805. message(FATAL_ERROR "MYSQL requested but package not found")
  806. endif()
  807. else()
  808. add_definitions (-D_NO_MYSQL_REPOSITORY)
  809. endif(USE_MYSQL_REPOSITORY)
  810. if(USE_APR)
  811. find_package(APR)
  812. if (APR_FOUND)
  813. add_definitions (-D_USE_APR)
  814. include_directories(${APR_INCLUDE_DIR})
  815. link_directories(${APR_LIBRARY_DIR})
  816. else()
  817. message(FATAL_ERROR "APR requested but package not found")
  818. endif()
  819. if (APRUTIL_FOUND)
  820. include_directories(${APRUTIL_INCLUDE_DIR})
  821. link_directories(${APRUTIL_LIBRARY_DIR})
  822. else()
  823. message(FATAL_ERROR "APRUTIL requested but package not found")
  824. endif()
  825. else()
  826. add_definitions (-D_NO_APR)
  827. endif(USE_APR)
  828. if (USE_NUMA)
  829. find_package(NUMA)
  830. add_definitions (-D_USE_NUMA)
  831. if (NOT NUMA_FOUND)
  832. message(FATAL_ERROR "NUMA requested but package not found")
  833. endif()
  834. endif()
  835. if(USE_TBB)
  836. message(STATUS "Enabled use of TBB")
  837. add_definitions (-D_USE_TBB)
  838. endif(USE_TBB)
  839. if(USE_TBBMALLOC)
  840. message(STATUS "Enabled use of TBBMALLOC")
  841. add_definitions (-D_USE_TBBMALLOC)
  842. if(USE_TBBMALLOC_ROXIE)
  843. message(STATUS "Enabled use of TBBMALLOC_ROXIE")
  844. endif(USE_TBBMALLOC_ROXIE)
  845. endif(USE_TBBMALLOC)
  846. ENDIF()
  847. ###########################################################################
  848. ###
  849. ## The following sets the install directories and names.
  850. ###
  851. if ( PLATFORM OR PLUGIN )
  852. set ( CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" )
  853. else ( )
  854. set ( CMAKE_INSTALL_PREFIX "${INSTALL_DIR}/${version}/clienttools" )
  855. endif ( PLATFORM OR PLUGIN )
  856. if(APPLE)
  857. set(CMAKE_MACOSX_RPATH ON)
  858. endif()
  859. set (CMAKE_SKIP_BUILD_RPATH FALSE)
  860. set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  861. set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_DIR};${CMAKE_INSTALL_PREFIX}/${PLUGINS_DIR};${CMAKE_INSTALL_PREFIX}/${LIB_DIR}/external")
  862. set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  863. MACRO (FETCH_GIT_TAG workdir edition result)
  864. execute_process(COMMAND "${GIT_COMMAND}" describe --tags --dirty --abbrev=6 --match ${edition}*
  865. WORKING_DIRECTORY "${workdir}"
  866. OUTPUT_VARIABLE ${result}
  867. ERROR_QUIET
  868. OUTPUT_STRIP_TRAILING_WHITESPACE)
  869. if ("${${result}}" STREQUAL "")
  870. execute_process(COMMAND "${GIT_COMMAND}" describe --always --tags --all --abbrev=6 --dirty --long
  871. WORKING_DIRECTORY "${workdir}"
  872. OUTPUT_VARIABLE ${result}
  873. ERROR_QUIET
  874. OUTPUT_STRIP_TRAILING_WHITESPACE)
  875. endif()
  876. ENDMACRO()
  877. function(LIST_TO_STRING separator outvar)
  878. set ( tmp_str "" )
  879. list (LENGTH ARGN list_length)
  880. if ( ${list_length} LESS 2 )
  881. set ( tmp_str "${ARGN}" )
  882. else()
  883. math(EXPR last_index "${list_length} - 1")
  884. foreach( index RANGE ${last_index} )
  885. if ( ${index} GREATER 0 )
  886. list( GET ARGN ${index} element )
  887. set( tmp_str "${tmp_str}${separator}${element}")
  888. else()
  889. list( GET ARGN 0 element )
  890. set( tmp_str "${element}")
  891. endif()
  892. endforeach()
  893. endif()
  894. set ( ${outvar} "${tmp_str}" PARENT_SCOPE )
  895. endfunction()
  896. function(STRING_TO_LIST separator outvar stringvar)
  897. set( tmp_list "" )
  898. string(REPLACE "${separator}" ";" tmp_list ${stringvar})
  899. string(STRIP "${tmp_list}" tmp_list)
  900. set( ${outvar} "${tmp_list}" PARENT_SCOPE)
  901. endfunction()
  902. ###########################################################################
  903. ###
  904. ## The following sets the dependency list for a package
  905. ###
  906. ###########################################################################
  907. function(SET_DEPENDENCIES cpackvar)
  908. set(_tmp "")
  909. if(${cpackvar})
  910. STRING_TO_LIST(", " _tmp ${${cpackvar}})
  911. endif()
  912. foreach(element ${ARGN})
  913. list(APPEND _tmp ${element})
  914. endforeach()
  915. list(REMOVE_DUPLICATES _tmp)
  916. LIST_TO_STRING(", " _tmp "${_tmp}")
  917. set(${cpackvar} "${_tmp}" CACHE STRING "" FORCE)
  918. message(STATUS "Updated ${cpackvar} to ${${cpackvar}}")
  919. endfunction()
  920. MACRO(SIGN_MODULE module)
  921. if(SIGN_MODULES)
  922. set(GPG_COMMAND_STR "gpg")
  923. if(DEFINED SIGN_MODULES_PASSPHRASE)
  924. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --passphrase ${SIGN_MODULES_PASSPHRASE}")
  925. endif()
  926. if(DEFINED SIGN_MODULES_KEYID)
  927. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --default-key ${SIGN_MODULES_KEYID}")
  928. endif()
  929. if("${GPG_VERSION}" VERSION_GREATER "2.1")
  930. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --pinentry-mode loopback")
  931. endif()
  932. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --batch --yes --no-tty --output ${CMAKE_CURRENT_BINARY_DIR}/${module} --clearsign ${module}")
  933. add_custom_command(
  934. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${module}
  935. COMMAND bash "-c" "${GPG_COMMAND_STR}"
  936. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${module}
  937. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  938. COMMENT "Adding signed ${module} to project"
  939. )
  940. else()
  941. add_custom_command(
  942. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${module}
  943. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${module} ${CMAKE_CURRENT_BINARY_DIR}/${module}
  944. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${module}
  945. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  946. COMMENT "Adding unsigned ${module} to project"
  947. VERBATIM
  948. )
  949. endif()
  950. # Use custom target to cause build to fail if dependency file isn't generated by gpg or cp commands
  951. get_filename_component(module_without_extension ${module} NAME_WE)
  952. add_custom_target(
  953. ${module_without_extension}-ecl ALL
  954. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${module}
  955. )
  956. if(SIGN_MODULES)
  957. add_dependencies(${module_without_extension}-ecl export-stdlib-pubkey)
  958. endif()
  959. ENDMACRO()
  960. endif ("${COMMONSETUP_DONE}" STREQUAL "")