commonSetup.cmake 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055
  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. elseif(APPLE)
  172. message(STATUS "libmemcached not available on macOS. Disabling for build")
  173. set(USE_LIBMEMCACHED OFF)
  174. else()
  175. find_package(LIBMEMCACHED ${LIBMEMCACHED_MINVERSION} REQUIRED)
  176. add_definitions(-DUSE_LIBMEMCACHED)
  177. include_directories(${LIBMEMCACHED_INCLUDE_DIR})
  178. endif()
  179. endif()
  180. endif()
  181. if (SIGN_MODULES)
  182. message(STATUS "GPG signing check")
  183. execute_process(COMMAND bash "-c" "gpg --version | awk 'NR==1{print $3}'"
  184. OUTPUT_VARIABLE GPG_VERSION
  185. OUTPUT_STRIP_TRAILING_WHITESPACE
  186. ERROR_QUIET)
  187. set(GPG_COMMAND_STR "gpg")
  188. if(${GPG_VERSION} VERSION_GREATER "2.1")
  189. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --pinentry-mode loopback --batch --no-tty")
  190. else()
  191. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --batch --no-tty")
  192. endif()
  193. if(DEFINED SIGN_MODULES_PASSPHRASE)
  194. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --passphrase ${SIGN_MODULES_PASSPHRASE}")
  195. endif()
  196. if(DEFINED SIGN_MODULES_KEYID)
  197. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --default-key ${SIGN_MODULES_KEYID}")
  198. endif()
  199. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --output sm_keycheck.asc --clearsign sm_keycheck.tmp")
  200. execute_process(COMMAND rm -f sm_keycheck.tmp sm_keycheck.asc TIMEOUT 5
  201. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} OUTPUT_QUIET ERROR_QUIET)
  202. execute_process(COMMAND touch sm_keycheck.tmp TIMEOUT 5
  203. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} RESULT_VARIABLE t_rc
  204. OUTPUT_QUIET ERROR_QUIET)
  205. if(NOT "${t_rc}" STREQUAL "0")
  206. message(FATAL_ERROR "Failed to create sm_keycheck.tmp for signing")
  207. endif()
  208. execute_process(
  209. COMMAND bash "-c" "${GPG_COMMAND_STR}"
  210. TIMOUT 120
  211. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  212. RESULT_VARIABLE rc_var
  213. OUTPUT_VARIABLE out_var
  214. ERROR_VARIABLE err_var
  215. )
  216. if(NOT "${rc_var}" STREQUAL "0")
  217. message(STATUS "GPG signing check - failed")
  218. message(FATAL_ERROR "gpg signing of std ecllibrary unsupported in current environment. \
  219. If you wish to build without a signed std ecllibrary add -DSIGN_MODULES=OFF to your \
  220. cmake invocation.\n${err_var}")
  221. else()
  222. message(STATUS "GPG signing check - done")
  223. endif()
  224. endif()
  225. if ( USE_XALAN AND USE_LIBXSLT )
  226. set(USE_LIBXSLT OFF)
  227. endif()
  228. if ( USE_LIBXSLT )
  229. set(USE_LIBXML2 ON)
  230. endif()
  231. if ( USE_XALAN )
  232. set(USE_XERCES ON)
  233. endif()
  234. if ( MAKE_DOCS AND CLIENTTOOLS_ONLY )
  235. set( MAKE_DOCS OFF )
  236. endif()
  237. if ( MAKE_DOCS_ONLY AND NOT CLIENTTOOLS_ONLY )
  238. set( MAKE_DOCS ON )
  239. if ( USE_DOCS_AUTO )
  240. set ( DOCS_AUTO ON)
  241. endif()
  242. endif()
  243. if ( CLIENTTOOLS_ONLY )
  244. set(PLATFORM OFF)
  245. set(DEVEL OFF)
  246. endif()
  247. option(PORTALURL "Set url to hpccsystems portal download page")
  248. if ( NOT PORTALURL )
  249. set( PORTALURL "http://hpccsystems.com/download" )
  250. endif()
  251. if(UNIX AND SIGN_MODULES)
  252. execute_process(COMMAND bash "-c" "gpg --version | awk 'NR==1{print $3}'"
  253. OUTPUT_VARIABLE GPG_VERSION
  254. OUTPUT_STRIP_TRAILING_WHITESPACE
  255. ERROR_QUIET)
  256. message(STATUS "gpg version ${GPG_VERSION}")
  257. #export gpg public key used for signing to new installation
  258. add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/pub.key
  259. COMMAND bash "-c" "gpg --output=${CMAKE_BINARY_DIR}/pub.key --batch --no-tty --export ${SIGN_MODULES_KEYID}"
  260. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  261. COMMENT "Exporting public key for eclcc signed modules to ${CMAKE_BINARY_DIR}/pub.key"
  262. VERBATIM
  263. )
  264. add_custom_target(export-stdlib-pubkey ALL
  265. DEPENDS ${CMAKE_BINARY_DIR}/pub.key
  266. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  267. )
  268. install(FILES ${CMAKE_BINARY_DIR}/pub.key DESTINATION .${CONFIG_DIR}/rpmnew COMPONENT Runtime)
  269. install(PROGRAMS ${CMAKE_MODULE_PATH}publickey.install DESTINATION etc/init.d/install COMPONENT Runtime)
  270. endif()
  271. ##########################################################
  272. # common compiler/linker flags
  273. if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
  274. set ( CMAKE_BUILD_TYPE "Release" )
  275. elseif (NOT "${CMAKE_BUILD_TYPE}" MATCHES "^Debug$|^Release$|^RelWithDebInfo$")
  276. message (FATAL_ERROR "Unknown build type ${CMAKE_BUILD_TYPE}")
  277. endif ()
  278. message ("-- Making ${CMAKE_BUILD_TYPE} system")
  279. if (CMAKE_SIZEOF_VOID_P EQUAL 8)
  280. set ( ARCH64BIT 1 )
  281. else ()
  282. set ( ARCH64BIT 0 )
  283. endif ()
  284. message ("-- 64bit architecture is ${ARCH64BIT}")
  285. set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DDEBUG")
  286. IF (USE_INLINE_TSC)
  287. add_definitions (-DINLINE_GET_CYCLES_NOW)
  288. ENDIF()
  289. set (CMAKE_THREAD_PREFER_PTHREAD 1)
  290. find_package(Threads)
  291. IF (NOT THREADS_FOUND)
  292. message(FATAL_ERROR "No threading support found")
  293. ENDIF()
  294. if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
  295. set (CMAKE_COMPILER_IS_CLANGXX 1)
  296. endif()
  297. if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
  298. set (CMAKE_COMPILER_IS_CLANG 1)
  299. endif()
  300. if ((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) AND (NOT ${CMAKE_C_COMPILER_VERSION} MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+"))
  301. execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE CMAKE_C_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
  302. endif ()
  303. if ((CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) AND (NOT ${CMAKE_CXX_COMPILER_VERSION} MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+"))
  304. execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
  305. endif()
  306. if (CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
  307. add_definitions (-fvisibility=hidden)
  308. endif ()
  309. if (CMAKE_COMPILER_IS_CLANGXX)
  310. execute_process( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string )
  311. if (${clang_full_version_string} MATCHES "Apple LLVM version ([0-9]+\\.[0-9]+\\.[0-9]+).*")
  312. string (REGEX REPLACE "Apple LLVM version ([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1" APPLE_CLANG_VERSION ${clang_full_version_string})
  313. endif()
  314. if (${clang_full_version_string} MATCHES ".*based on LLVM ([0-9]+\\.[0-9]+).*")
  315. string (REGEX REPLACE ".*based on LLVM ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION ${clang_full_version_string})
  316. else()
  317. if (${clang_full_version_string} MATCHES ".*clang version ([0-9]+\\.[0-9]+).*")
  318. string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION ${clang_full_version_string})
  319. endif()
  320. endif()
  321. endif ()
  322. if (WIN32)
  323. # On windows, the vcproj generator generates both windows and debug build capabilities, and the release mode is appended to the directory later
  324. # This output location matches what our existing windows release scripts expect - might make sense to move out of tree sometime though
  325. set ( EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" )
  326. set ( LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" )
  327. # Workaround CMake's odd decision to default windows stack size to 10000000
  328. STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
  329. SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
  330. if (${ARCH64BIT} EQUAL 1)
  331. add_definitions(/bigobj)
  332. endif ()
  333. if ("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
  334. if (${ARCH64BIT} EQUAL 0)
  335. add_definitions(/ZI)
  336. else()
  337. add_definitions(/Zi)
  338. endif ()
  339. endif ()
  340. if ("${GIT_COMMAND}" STREQUAL "")
  341. set ( GIT_COMMAND "git.cmd" )
  342. endif ()
  343. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHa")
  344. if (USE_SIGNED_CHAR AND USE_UNSIGNED_CHAR )
  345. message (FATAL_ERROR "Can't use USE_SIGNED_CHAR and USE_UNSIGNED_CHAR together!")
  346. else()
  347. if (USE_SIGNED_CHAR)
  348. message ("Build system with signed char type.")
  349. # This is default for MSVC
  350. endif ()
  351. if (USE_UNSIGNED_CHAR )
  352. message ("Build system with unsigned char type.")
  353. add_definitions(/J)
  354. endif ()
  355. endif ()
  356. #=== WARNING ======
  357. # Temporary disable warnings. Reenable them one by one to reexamine and fix them.
  358. IF (NOT ALL_WARNINGS_ON)
  359. set (WARNINGS_IGNORE "/wd4267 /wd4244 /wd6340 /wd6297 /wd4018 /wd4302 /wd4311 /wd4320 /wd4800") # data conversion warnings
  360. set (WARNINGS_IGNORE "${WARNINGS_IGNORE} /wd4251 /wd4275") # dll-interface for used by clients
  361. set (WARNINGS_IGNORE "${WARNINGS_IGNORE} /wd6246") # local variable hidden by outer scope
  362. set (WARNINGS_IGNORE "${WARNINGS_IGNORE} /wd6031") # Return value ignored
  363. set (WARNINGS_IGNORE "${WARNINGS_IGNORE} /wd4005") # MACRO redef: same value
  364. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNINGS_IGNORE}")
  365. ENDIF()
  366. else ()
  367. if (NOT CMAKE_USE_PTHREADS_INIT)
  368. message (FATAL_ERROR "pthreads support not detected")
  369. endif ()
  370. set ( EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/bin" )
  371. set ( LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/libs" )
  372. if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
  373. message ("Using compiler: ${CMAKE_CXX_COMPILER_ID} :: ${CMAKE_CXX_COMPILER_VERSION} :: ${CLANG_VERSION} :: ${APPLE_CLANG_VERSION}")
  374. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti -fPIC -fmessage-length=0 -Werror=format -Wformat-security -Wformat-nonliteral -pthread -Wuninitialized")
  375. SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic")
  376. SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -fno-inline-functions")
  377. if (CMAKE_COMPILER_IS_GNUCXX)
  378. SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -fno-default-inline")
  379. if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.2.4 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.2.4)
  380. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type -Werror=format-nonliteral")
  381. endif ()
  382. if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.4.0)
  383. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi")
  384. endif ()
  385. if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 2.95.3 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 2.95.3)
  386. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wparentheses")
  387. endif ()
  388. endif ()
  389. SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE}")
  390. SET (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE}")
  391. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  392. if (GENERATE_COVERAGE_INFO)
  393. message ("Build system with coverage.")
  394. if (CMAKE_COMPILER_IS_CLANGXX)
  395. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
  396. else()
  397. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
  398. endif()
  399. endif()
  400. # Handle forced default char type
  401. if (USE_SIGNED_CHAR AND USE_UNSIGNED_CHAR )
  402. message (FATAL_ERROR "Can't use USE_SIGNED_CHAR and USE_UNSIGNED_CHAR together!")
  403. else()
  404. if (USE_SIGNED_CHAR)
  405. message ("Build system with signed char type.")
  406. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char")
  407. endif ()
  408. if (USE_UNSIGNED_CHAR )
  409. message ("Build system with unsigned char type.")
  410. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funsigned-char")
  411. endif ()
  412. endif ()
  413. endif ()
  414. if (CMAKE_COMPILER_IS_CLANGXX)
  415. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=logical-op-parentheses -Werror=bool-conversions -Werror=return-type -Werror=comment")
  416. if (APPLE)
  417. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
  418. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
  419. endif ()
  420. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=bitwise-op-parentheses -Werror=tautological-compare")
  421. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch-enum -Wno-format-zero-length -Wno-switch")
  422. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments") # Silence messages about pthread not being used when linking...
  423. 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...
  424. if (CLANG_VERSION VERSION_GREATER 3.6 OR CLANG_VERSION VERSION_EQUAL 3.6 OR APPLE_CLANG_VERSION VERSION_GREATER 6.0)
  425. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pointer-bool-conversion")
  426. endif()
  427. endif()
  428. # All of these are defined in platform.h too, but need to be defned before any system header is included
  429. ADD_DEFINITIONS (-D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -D__USE_LARGEFILE64=1 -D__USE_FILE_OFFSET64=1)
  430. if ("${GIT_COMMAND}" STREQUAL "")
  431. set ( GIT_COMMAND "git" )
  432. endif ()
  433. endif ()
  434. macro(HPCC_ADD_EXECUTABLE target)
  435. add_executable(${target} ${ARGN})
  436. endmacro(HPCC_ADD_EXECUTABLE target)
  437. macro(HPCC_ADD_LIBRARY target)
  438. add_library(${target} ${ARGN})
  439. endmacro(HPCC_ADD_LIBRARY target)
  440. # This Macro is provided as Public domain from
  441. # http://www.cmake.org/Wiki/CMakeMacroParseArguments
  442. MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
  443. SET(DEFAULT_ARGS)
  444. FOREACH(arg_name ${arg_names})
  445. SET(${prefix}_${arg_name})
  446. ENDFOREACH(arg_name)
  447. FOREACH(option ${option_names})
  448. SET(${prefix}_${option} FALSE)
  449. ENDFOREACH(option)
  450. SET(current_arg_name DEFAULT_ARGS)
  451. SET(current_arg_list)
  452. FOREACH(arg ${ARGN})
  453. SET(larg_names ${arg_names})
  454. LIST(FIND larg_names "${arg}" is_arg_name)
  455. IF (is_arg_name GREATER -1)
  456. SET(${prefix}_${current_arg_name} ${current_arg_list})
  457. SET(current_arg_name ${arg})
  458. SET(current_arg_list)
  459. ELSE (is_arg_name GREATER -1)
  460. SET(loption_names ${option_names})
  461. LIST(FIND loption_names "${arg}" is_option)
  462. IF (is_option GREATER -1)
  463. SET(${prefix}_${arg} TRUE)
  464. ELSE (is_option GREATER -1)
  465. SET(current_arg_list ${current_arg_list} ${arg})
  466. ENDIF (is_option GREATER -1)
  467. ENDIF (is_arg_name GREATER -1)
  468. ENDFOREACH(arg)
  469. SET(${prefix}_${current_arg_name} ${current_arg_list})
  470. ENDMACRO(PARSE_ARGUMENTS)
  471. # This macro allows for disabling a directory based on the value of a variable passed to the macro.
  472. #
  473. # ex. HPCC_ADD_SUBDIRECORY(roxie ${CLIENTTOOLS_ONLY})
  474. #
  475. # This call will disable the roxie dir if -DCLIENTTOOLS_ONLY=ON is set at config time.
  476. #
  477. macro(HPCC_ADD_SUBDIRECTORY)
  478. set(adddir OFF)
  479. PARSE_ARGUMENTS(_HPCC_SUB "" "" ${ARGN})
  480. LIST(GET _HPCC_SUB_DEFAULT_ARGS 0 subdir)
  481. set(flags ${_HPCC_SUB_DEFAULT_ARGS})
  482. LIST(REMOVE_AT flags 0)
  483. LIST(LENGTH flags length)
  484. if(NOT length)
  485. set(adddir ON)
  486. else()
  487. foreach(f ${flags})
  488. if(${f})
  489. set(adddir ON)
  490. endif()
  491. endforeach()
  492. endif()
  493. if ( adddir )
  494. add_subdirectory(${subdir})
  495. endif()
  496. endmacro(HPCC_ADD_SUBDIRECTORY)
  497. set ( SCM_GENERATED_DIR ${CMAKE_BINARY_DIR}/generated )
  498. ###############################################################
  499. # Macro for Logging Plugin build in CMake
  500. macro(LOG_PLUGIN)
  501. PARSE_ARGUMENTS(pLOG
  502. "OPTION;MDEPS"
  503. ""
  504. ${ARGN})
  505. LIST(GET pLOG_DEFAULT_ARGS 0 PLUGIN_NAME)
  506. if(${pLOG_OPTION})
  507. message(STATUS "Building Plugin: ${PLUGIN_NAME}" )
  508. else()
  509. message(WARNING "Not Building Plugin: ${PLUGIN_NAME}")
  510. foreach (dep ${pLOG_MDEPS})
  511. message(WARNING "Missing dependency: ${dep}")
  512. endforeach()
  513. if(NOT USE_OPTIONAL)
  514. message(FATAL_ERROR "Optional dependencies missing and USE_OPTIONAL OFF")
  515. endif()
  516. endif()
  517. endmacro()
  518. ###############################################################
  519. # Macro for adding an optional plugin to the CMake build.
  520. macro(ADD_PLUGIN)
  521. PARSE_ARGUMENTS(PLUGIN
  522. "PACKAGES;MINVERSION;MAXVERSION"
  523. ""
  524. ${ARGN})
  525. LIST(GET PLUGIN_DEFAULT_ARGS 0 PLUGIN_NAME)
  526. string(TOUPPER ${PLUGIN_NAME} name)
  527. set(ALL_PLUGINS_FOUND 1)
  528. set(PLUGIN_MDEPS ${PLUGIN_NAME}_mdeps)
  529. set(${PLUGIN_MDEPS} "")
  530. foreach(package ${PLUGIN_PACKAGES})
  531. set(findvar ${package}_FOUND)
  532. string(TOUPPER ${findvar} PACKAGE_FOUND)
  533. if("${PLUGIN_MINVERSION}" STREQUAL "")
  534. find_package(${package})
  535. else()
  536. set(findvar ${package}_VERSION_STRING)
  537. string(TOUPPER ${findvar} PACKAGE_VERSION_STRING)
  538. find_package(${package} ${PLUGIN_MINVERSION} )
  539. if ("${${PACKAGE_VERSION_STRING}}" VERSION_GREATER "${PLUGIN_MAXVERSION}")
  540. set(${ALL_PLUGINS_FOUND} 0)
  541. endif()
  542. endif()
  543. if(NOT ${PACKAGE_FOUND})
  544. set(ALL_PLUGINS_FOUND 0)
  545. set(${PLUGIN_MDEPS} ${${PLUGIN_MDEPS}} ${package})
  546. endif()
  547. endforeach()
  548. set(MAKE_${name} ${ALL_PLUGINS_FOUND})
  549. LOG_PLUGIN(${PLUGIN_NAME} OPTION ${ALL_PLUGINS_FOUND} MDEPS ${${PLUGIN_MDEPS}})
  550. if(${ALL_PLUGINS_FOUND})
  551. set(bPLUGINS ${bPLUGINS} ${PLUGIN_NAME})
  552. else()
  553. set(nbPLUGINS ${nbPLUGINS} ${PLUGIN_NAME})
  554. endif()
  555. endmacro()
  556. ##################################################################
  557. # Build tag generation
  558. set(projname ${HPCC_PROJECT})
  559. set(majorver ${HPCC_MAJOR})
  560. set(minorver ${HPCC_MINOR})
  561. set(point ${HPCC_POINT})
  562. if ( "${HPCC_MATURITY}" STREQUAL "release" )
  563. set(stagever "${HPCC_SEQUENCE}")
  564. else()
  565. set(stagever "${HPCC_MATURITY}${HPCC_SEQUENCE}")
  566. endif()
  567. set(version ${majorver}.${minorver}.${point})
  568. IF ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  569. set( stagever "${stagever}Debug" )
  570. ENDIF ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  571. ###########################################################################
  572. if(USE_OPTIONAL)
  573. message(WARNING "USE_OPTIONAL set - missing dependencies for optional features will automatically disable them")
  574. endif()
  575. if(NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
  576. message(STATUS "Using externals directory at ${EXTERNALS_DIRECTORY}")
  577. endif()
  578. IF ( NOT MAKE_DOCS_ONLY )
  579. IF ("${EXTERNALS_DIRECTORY}" STREQUAL "")
  580. SET(bisoncmd "bison")
  581. SET(flexcmd "flex")
  582. ELSE()
  583. IF (WIN32)
  584. SET(bisoncmdprefix "call")
  585. SET(flexcmdprefix "call")
  586. SET(bisoncmd "${EXTERNALS_DIRECTORY}\\bison\\bison.bat")
  587. SET(flexcmd "${EXTERNALS_DIRECTORY}\\bison\\flex.bat")
  588. ELSE ()
  589. SET(bisoncmd "${EXTERNALS_DIRECTORY}/bison/bison")
  590. SET(flexcmd "${EXTERNALS_DIRECTORY}/bison/flex")
  591. ENDIF()
  592. ENDIF()
  593. IF ("${BISON_VERSION}" STREQUAL "")
  594. IF (WIN32)
  595. # cmake bug workaround - it converts path separators fine in add_custom_command but not here
  596. STRING(REPLACE "/" "\\" BISON_exename "${bisoncmd}")
  597. ELSE()
  598. SET(BISON_exename "${bisoncmd}")
  599. ENDIF()
  600. EXECUTE_PROCESS(COMMAND ${BISON_exename} --version
  601. OUTPUT_VARIABLE BISON_version_output
  602. ERROR_VARIABLE BISON_version_error
  603. RESULT_VARIABLE BISON_version_result
  604. OUTPUT_STRIP_TRAILING_WHITESPACE)
  605. STRING(REGEX REPLACE "^[^0-9]*([0-9.]+).*" "\\1" BISON_VERSION "${BISON_version_output}")
  606. ENDIF()
  607. IF ("${FLEX_VERSION}" STREQUAL "")
  608. IF (WIN32)
  609. # cmake bug workaround - it converts path separators fine in add_custom_command but not here
  610. STRING(REPLACE "/" "\\" FLEX_exename "${flexcmd}")
  611. ELSE()
  612. SET(FLEX_exename "${flexcmd}")
  613. ENDIF()
  614. EXECUTE_PROCESS(COMMAND ${FLEX_exename} --version
  615. OUTPUT_VARIABLE FLEX_version_output
  616. ERROR_VARIABLE FLEX_version_error
  617. RESULT_VARIABLE FLEX_version_result
  618. OUTPUT_STRIP_TRAILING_WHITESPACE)
  619. STRING(REGEX REPLACE "^[^0-9]*([0-9.]+).*" "\\1" FLEX_VERSION "${FLEX_version_output}")
  620. ENDIF()
  621. IF ("${BISON_VERSION}" VERSION_LESS "2.4.1")
  622. MESSAGE(FATAL_ERROR "You need bison version 2.4.1 or later to build this project (version ${BISON_VERSION} detected)")
  623. ENDIF()
  624. IF ("${BISON_VERSION}" VERSION_LESS "2.7.0")
  625. #Ignore all warnings - not recommend to develope on this version!
  626. SET(bisonopt "-Wnone")
  627. ELSE()
  628. SET(bisonopt -Werror -Wno-other)
  629. ENDIF()
  630. IF ("${FLEX_VERSION}" VERSION_LESS "2.5.35")
  631. MESSAGE(FATAL_ERROR "You need flex version 2.5.35 or later to build this project (version ${FLEX_VERSION} detected)")
  632. ENDIF()
  633. IF (CMAKE_COMPILER_IS_GNUCXX)
  634. IF ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.7.3")
  635. MESSAGE(FATAL_ERROR "You need Gnu c++ version 4.7.3 or later to build this project (version ${CMAKE_CXX_COMPILER_VERSION} detected)")
  636. ENDIF()
  637. ENDIF()
  638. ENDIF()
  639. ###########################################################################
  640. # External library setup - some can be optionally selected based on USE_xxx flags, some are required
  641. IF (MAKE_DOCS)
  642. find_package(XSLTPROC)
  643. IF (XSLTPROC_FOUND)
  644. add_definitions (-D_USE_XSLTPROC)
  645. ELSE()
  646. message(FATAL_ERROR "XSLTPROC requested but package not found")
  647. ENDIF()
  648. find_package(FOP)
  649. IF (FOP_FOUND)
  650. add_definitions (-D_USE_FOP)
  651. ELSE()
  652. message(FATAL_ERROR "FOP requested but package not found")
  653. ENDIF()
  654. IF ( DOCS_AUTO )
  655. find_package(SAXON)
  656. IF (SAXON_FOUND)
  657. add_definitions (-D_USE_SAXON)
  658. ELSE()
  659. message(FATAL_ERROR "SAXON, a XSLT and XQuery processor, is required for documentation build but not found.")
  660. ENDIF()
  661. ENDIF()
  662. ENDIF(MAKE_DOCS)
  663. IF ( NOT MAKE_DOCS_ONLY )
  664. IF (USE_OPENLDAP)
  665. find_package(OPENLDAP)
  666. IF (OPENLDAP_FOUND)
  667. add_definitions (-D_USE_OPENLDAP)
  668. ELSE()
  669. message(FATAL_ERROR "OPENLDAP requested but package not found")
  670. ENDIF()
  671. ELSE()
  672. add_definitions (-D_NO_LDAP)
  673. ENDIF(USE_OPENLDAP)
  674. IF (USE_CPPUNIT)
  675. find_package(CPPUNIT)
  676. IF (CPPUNIT_FOUND)
  677. add_definitions (-D_USE_CPPUNIT)
  678. include_directories(${CPPUNIT_INCLUDE_DIR})
  679. ELSE()
  680. message(FATAL_ERROR "CPPUNIT requested but package not found")
  681. ENDIF()
  682. ELSE()
  683. SET(CPPUNIT_INCLUDE_DIR "")
  684. SET(CPPUNIT_LIBRARIES "")
  685. ENDIF(USE_CPPUNIT)
  686. IF (USE_ICU)
  687. find_package(ICU)
  688. IF (ICU_FOUND)
  689. add_definitions (-D_USE_ICU)
  690. IF (NOT WIN32)
  691. add_definitions (-DUCHAR_TYPE=uint16_t)
  692. ENDIF()
  693. include_directories(${ICU_INCLUDE_DIR})
  694. ELSE()
  695. message(FATAL_ERROR "ICU requested but package not found")
  696. ENDIF()
  697. ENDIF(USE_ICU)
  698. if(USE_XALAN)
  699. find_package(XALAN)
  700. if (XALAN_FOUND)
  701. add_definitions (-D_USE_XALAN)
  702. else()
  703. message(FATAL_ERROR "XALAN requested but package not found")
  704. endif()
  705. endif(USE_XALAN)
  706. if(USE_LIBXSLT)
  707. find_package(LIBXSLT)
  708. if (LIBXSLT_FOUND)
  709. add_definitions (-D_USE_LIBXSLT)
  710. else()
  711. message(FATAL_ERROR "LIBXSLT requested but package not found")
  712. endif()
  713. endif(USE_LIBXSLT)
  714. if(USE_XERCES)
  715. find_package(XERCES)
  716. if (XERCES_FOUND)
  717. add_definitions (-D_USE_XERCES)
  718. else()
  719. message(FATAL_ERROR "XERCES requested but package not found")
  720. endif()
  721. endif(USE_XERCES)
  722. if(USE_LIBXML2)
  723. find_package(LIBXML2)
  724. if (LIBXML2_FOUND)
  725. add_definitions (-D_USE_LIBXML2)
  726. else()
  727. message(FATAL_ERROR "LIBXML2 requested but package not found")
  728. endif()
  729. endif(USE_LIBXML2)
  730. if(USE_CBLAS)
  731. find_package(CBLAS)
  732. if(CBLAS_FOUND)
  733. add_definitions(-D_USE_CBLAS)
  734. else()
  735. message(FATAL_ERROR "CBLAS requested but package not found")
  736. endif()
  737. endif(USE_CBLAS)
  738. if(USE_ZLIB)
  739. find_package(ZLIB)
  740. if (ZLIB_FOUND)
  741. add_definitions (-D_USE_ZLIB)
  742. else()
  743. message(FATAL_ERROR "ZLIB requested but package not found")
  744. endif()
  745. endif(USE_ZLIB)
  746. if(USE_LIBARCHIVE)
  747. if (WIN32)
  748. if(NOT USE_ZLIB)
  749. message(FATAL ERROR "LIBARCHIVE requires ZLIB")
  750. endif(NOT USE_ZLIB)
  751. find_package(BZip2)
  752. if (BZIP2_FOUND)
  753. add_definitions (-D_USE_BZIP2)
  754. else()
  755. message(FATAL_ERROR "LIBARCHIVE requires BZIP2 but package not found")
  756. endif()
  757. endif (WIN32)
  758. find_package(LIBARCHIVE)
  759. if (LIBARCHIVE_FOUND)
  760. add_definitions (-D_USE_LIBARCHIVE)
  761. else()
  762. message(FATAL_ERROR "LIBARCHIVE requested but package not found")
  763. endif()
  764. endif(USE_LIBARCHIVE)
  765. if(USE_URIPARSER)
  766. find_package(Uriparser)
  767. if (URIPARSER_FOUND)
  768. add_definitions (-D_USE_URIPARSER)
  769. else()
  770. message(FATAL_ERROR "URIPARSER requested but package not found")
  771. endif()
  772. endif(USE_URIPARSER)
  773. if(USE_BOOST_REGEX)
  774. find_package(BOOST_REGEX)
  775. if (BOOST_REGEX_FOUND)
  776. message(STATUS "BOOST_REGEX enabled")
  777. add_definitions (-D_USE_BOOST_REGEX)
  778. else()
  779. message(FATAL_ERROR "BOOST_REGEX requested but package not found")
  780. endif()
  781. else(USE_BOOST_REGEX)
  782. if (USE_C11_REGEX)
  783. if ((NOT CMAKE_COMPILER_IS_GNUCC) OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9.0))
  784. message(STATUS "C11_REGEX enabled")
  785. add_definitions (-D_USE_C11_REGEX)
  786. else()
  787. message(STATUS "C11_REGEX requested but not supported on this platform")
  788. endif()
  789. else(USE_C11_REGEX)
  790. message(STATUS "NO REGEX requested")
  791. endif(USE_C11_REGEX)
  792. endif(USE_BOOST_REGEX)
  793. if(USE_OPENSSL)
  794. find_package(OPENSSL)
  795. if (OPENSSL_FOUND)
  796. add_definitions (-D_USE_OPENSSL)
  797. include_directories(${OPENSSL_INCLUDE_DIR})
  798. link_directories(${OPENSSL_LIBRARY_DIR})
  799. else()
  800. message(FATAL_ERROR "OPENSSL requested but package not found")
  801. endif()
  802. endif(USE_OPENSSL)
  803. if(USE_MYSQL_REPOSITORY)
  804. find_package(MYSQL)
  805. if (MYSQL_FOUND)
  806. add_definitions (-D_USE_MYSQL_REPOSITORY)
  807. else()
  808. message(FATAL_ERROR "MYSQL requested but package not found")
  809. endif()
  810. else()
  811. add_definitions (-D_NO_MYSQL_REPOSITORY)
  812. endif(USE_MYSQL_REPOSITORY)
  813. if(USE_APR)
  814. find_package(APR)
  815. if (APR_FOUND)
  816. add_definitions (-D_USE_APR)
  817. include_directories(${APR_INCLUDE_DIR})
  818. link_directories(${APR_LIBRARY_DIR})
  819. else()
  820. message(FATAL_ERROR "APR requested but package not found")
  821. endif()
  822. if (APRUTIL_FOUND)
  823. include_directories(${APRUTIL_INCLUDE_DIR})
  824. link_directories(${APRUTIL_LIBRARY_DIR})
  825. else()
  826. message(FATAL_ERROR "APRUTIL requested but package not found")
  827. endif()
  828. else()
  829. add_definitions (-D_NO_APR)
  830. endif(USE_APR)
  831. if (USE_NUMA)
  832. find_package(NUMA)
  833. add_definitions (-D_USE_NUMA)
  834. if (NOT NUMA_FOUND)
  835. message(FATAL_ERROR "NUMA requested but package not found")
  836. endif()
  837. endif()
  838. if(USE_TBB)
  839. message(STATUS "Enabled use of TBB")
  840. add_definitions (-D_USE_TBB)
  841. endif(USE_TBB)
  842. if(USE_TBBMALLOC)
  843. message(STATUS "Enabled use of TBBMALLOC")
  844. add_definitions (-D_USE_TBBMALLOC)
  845. if(USE_TBBMALLOC_ROXIE)
  846. message(STATUS "Enabled use of TBBMALLOC_ROXIE")
  847. endif(USE_TBBMALLOC_ROXIE)
  848. endif(USE_TBBMALLOC)
  849. ENDIF()
  850. ###########################################################################
  851. ###
  852. ## The following sets the install directories and names.
  853. ###
  854. if ( PLATFORM OR PLUGIN )
  855. set ( CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" )
  856. else ( )
  857. set ( CMAKE_INSTALL_PREFIX "${INSTALL_DIR}/${version}/clienttools" )
  858. endif ( PLATFORM OR PLUGIN )
  859. if(APPLE)
  860. set(CMAKE_MACOSX_RPATH ON)
  861. endif()
  862. set (CMAKE_SKIP_BUILD_RPATH FALSE)
  863. set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  864. set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_DIR};${CMAKE_INSTALL_PREFIX}/${PLUGINS_DIR};${CMAKE_INSTALL_PREFIX}/${LIB_DIR}/external")
  865. set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  866. MACRO (FETCH_GIT_TAG workdir edition result)
  867. execute_process(COMMAND "${GIT_COMMAND}" describe --tags --dirty --abbrev=6 --match ${edition}*
  868. WORKING_DIRECTORY "${workdir}"
  869. OUTPUT_VARIABLE ${result}
  870. ERROR_QUIET
  871. OUTPUT_STRIP_TRAILING_WHITESPACE)
  872. if ("${${result}}" STREQUAL "")
  873. execute_process(COMMAND "${GIT_COMMAND}" describe --always --tags --all --abbrev=6 --dirty --long
  874. WORKING_DIRECTORY "${workdir}"
  875. OUTPUT_VARIABLE ${result}
  876. ERROR_QUIET
  877. OUTPUT_STRIP_TRAILING_WHITESPACE)
  878. endif()
  879. ENDMACRO()
  880. function(LIST_TO_STRING separator outvar)
  881. set ( tmp_str "" )
  882. list (LENGTH ARGN list_length)
  883. if ( ${list_length} LESS 2 )
  884. set ( tmp_str "${ARGN}" )
  885. else()
  886. math(EXPR last_index "${list_length} - 1")
  887. foreach( index RANGE ${last_index} )
  888. if ( ${index} GREATER 0 )
  889. list( GET ARGN ${index} element )
  890. set( tmp_str "${tmp_str}${separator}${element}")
  891. else()
  892. list( GET ARGN 0 element )
  893. set( tmp_str "${element}")
  894. endif()
  895. endforeach()
  896. endif()
  897. set ( ${outvar} "${tmp_str}" PARENT_SCOPE )
  898. endfunction()
  899. function(STRING_TO_LIST separator outvar stringvar)
  900. set( tmp_list "" )
  901. string(REPLACE "${separator}" ";" tmp_list ${stringvar})
  902. string(STRIP "${tmp_list}" tmp_list)
  903. set( ${outvar} "${tmp_list}" PARENT_SCOPE)
  904. endfunction()
  905. ###########################################################################
  906. ###
  907. ## The following sets the dependency list for a package
  908. ###
  909. ###########################################################################
  910. function(SET_DEPENDENCIES cpackvar)
  911. set(_tmp "")
  912. if(${cpackvar})
  913. STRING_TO_LIST(", " _tmp ${${cpackvar}})
  914. endif()
  915. foreach(element ${ARGN})
  916. list(APPEND _tmp ${element})
  917. endforeach()
  918. list(REMOVE_DUPLICATES _tmp)
  919. LIST_TO_STRING(", " _tmp "${_tmp}")
  920. set(${cpackvar} "${_tmp}" CACHE STRING "" FORCE)
  921. message(STATUS "Updated ${cpackvar} to ${${cpackvar}}")
  922. endfunction()
  923. MACRO(SIGN_MODULE module)
  924. if(SIGN_MODULES)
  925. set(GPG_COMMAND_STR "gpg")
  926. if(DEFINED SIGN_MODULES_PASSPHRASE)
  927. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --passphrase ${SIGN_MODULES_PASSPHRASE}")
  928. endif()
  929. if(DEFINED SIGN_MODULES_KEYID)
  930. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --default-key ${SIGN_MODULES_KEYID}")
  931. endif()
  932. if("${GPG_VERSION}" VERSION_GREATER "2.1")
  933. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --pinentry-mode loopback")
  934. endif()
  935. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --batch --yes --no-tty --output ${CMAKE_CURRENT_BINARY_DIR}/${module} --clearsign ${module}")
  936. add_custom_command(
  937. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${module}
  938. COMMAND bash "-c" "${GPG_COMMAND_STR}"
  939. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${module}
  940. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  941. COMMENT "Adding signed ${module} to project"
  942. )
  943. else()
  944. add_custom_command(
  945. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${module}
  946. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${module} ${CMAKE_CURRENT_BINARY_DIR}/${module}
  947. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${module}
  948. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  949. COMMENT "Adding unsigned ${module} to project"
  950. VERBATIM
  951. )
  952. endif()
  953. # Use custom target to cause build to fail if dependency file isn't generated by gpg or cp commands
  954. get_filename_component(module_without_extension ${module} NAME_WE)
  955. add_custom_target(
  956. ${module_without_extension}-ecl ALL
  957. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${module}
  958. )
  959. if(SIGN_MODULES)
  960. add_dependencies(${module_without_extension}-ecl export-stdlib-pubkey)
  961. endif()
  962. ENDMACRO()
  963. endif ("${COMMONSETUP_DONE}" STREQUAL "")