commonSetup.cmake 44 KB

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