commonSetup.cmake 45 KB

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