commonSetup.cmake 46 KB

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