commonSetup.cmake 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. ################################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ################################################################################
  16. # File : commonSetup.cmake
  17. #
  18. #########################################################
  19. # Description:
  20. # ------------
  21. # sets up various cmake options.
  22. #########################################################
  23. IF ("${COMMONSETUP_DONE}" STREQUAL "")
  24. SET (COMMONSETUP_DONE 1)
  25. MACRO (MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage)
  26. STRING(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource)
  27. IF (insource)
  28. MESSAGE(FATAL_ERROR "${_errorMessage}")
  29. ENDIF(insource)
  30. ENDMACRO (MACRO_ENSURE_OUT_OF_SOURCE_BUILD)
  31. macro_ensure_out_of_source_build("The LexisNexis Hpcc requires an out of source build.
  32. Please remove the directory ${CMAKE_BINARY_DIR}/CMakeFiles
  33. and the file ${CMAKE_BINARY_DIR}/CMakeCache.txt,
  34. then create a separate build directory and run 'cmake path_to_source [options]' there.")
  35. cmake_policy ( SET CMP0011 NEW )
  36. if (NOT (CMAKE_MAJOR_VERSION LESS 3))
  37. cmake_policy ( SET CMP0026 OLD )
  38. if (NOT (CMAKE_MINOR_VERSION LESS 1))
  39. cmake_policy ( SET CMP0054 NEW )
  40. endif()
  41. endif()
  42. option(CONTAINERIZED "Build for container images." OFF)
  43. option(CLIENTTOOLS "Enable the building/inclusion of a Client Tools component." ON)
  44. option(PLATFORM "Enable the building/inclusion of a Platform component." ON)
  45. option(DEVEL "Enable the building/inclusion of a Development component." OFF)
  46. option(CLIENTTOOLS_ONLY "Enable the building of Client Tools only." OFF)
  47. option(INCLUDE_PLUGINS "Enable the building of platform and all plugins for testing purposes" OFF)
  48. option(USE_CASSANDRA "Include the Cassandra plugin in the base package" ON)
  49. option(PLUGIN "Enable building of a plugin" OFF)
  50. option(USE_SHLIBDEPS "Enable the use of dpkg-shlibdeps on ubuntu packaging" OFF)
  51. option(SIGN_MODULES "Enable signing of ecl standard library modules" OFF)
  52. option(USE_CPPUNIT "Enable unit tests (requires cppunit)" OFF)
  53. option(USE_OPENLDAP "Enable OpenLDAP support (requires OpenLDAP)" ON)
  54. option(USE_ICU "Enable unicode support (requires ICU)" ON)
  55. option(USE_BOOST_REGEX "Configure use of boost regex" ON)
  56. option(CENTOS_6_BOOST "Supply regex library on CentOS 6" OFF)
  57. # USE_C11_REGEX is only checked if USE_BOOST_REGEX is OFF
  58. # to disable REGEX altogether turn both off
  59. option(USE_C11_REGEX "Configure use of c++11 std::regex" ON)
  60. option(Boost_USE_STATIC_LIBS "Use boost_regex static library for RPM BUILD" OFF)
  61. option(USE_OPENSSL "Configure use of OpenSSL" ON)
  62. option(USE_ZLIB "Configure use of zlib" ON)
  63. option(USE_CBLAS "Configure use of cblas" ON)
  64. option(USE_AZURE "Configure use of azure" ON)
  65. option(USE_H3 "Configure use of Uber H3 geospatial indexing" ON)
  66. if (WIN32)
  67. option(USE_AERON "Include the Aeron message protocol" OFF)
  68. option(USE_GIT "Configure use of GIT (Hooks)" OFF)
  69. else()
  70. option(USE_AERON "Include the Aeron message protocol" ON)
  71. option(USE_GIT "Configure use of GIT (Hooks)" ON)
  72. endif()
  73. option(USE_LIBARCHIVE "Configure use of libarchive" ON)
  74. option(USE_URIPARSER "Configure use of uriparser" OFF)
  75. if (APPLE OR WIN32)
  76. option(USE_NUMA "Configure use of numa" OFF)
  77. else()
  78. option(USE_NUMA "Configure use of numa" ON)
  79. endif()
  80. option(USE_AWS "Configure use of aws" ON)
  81. IF (WIN32)
  82. option(USE_NATIVE_LIBRARIES "Search standard OS locations (otherwise in EXTERNALS_DIRECTORY) for 3rd party libraries" OFF)
  83. ELSE()
  84. option(USE_NATIVE_LIBRARIES "Search standard OS locations (otherwise in EXTERNALS_DIRECTORY) for 3rd party libraries" ON)
  85. ENDIF()
  86. option(USE_GIT_DESCRIBE "Use git describe to generate build tag" ON)
  87. option(CHECK_GIT_TAG "Require git tag to match the generated build tag" OFF)
  88. option(USE_XALAN "Configure use of xalan" OFF)
  89. option(USE_APR "Configure use of Apache Software Foundation (ASF) Portable Runtime (APR) libraries" ON)
  90. option(USE_LIBXSLT "Configure use of libxslt" ON)
  91. option(MAKE_DOCS "Create documentation at build time." OFF)
  92. option(MAKE_DOCS_ONLY "Create a base build with only docs." OFF)
  93. option(DOCS_DRUPAL "Create Drupal HTML Docs" OFF)
  94. option(DOCS_EPUB "Create EPUB Docs" OFF)
  95. option(DOCS_MOBI "Create Mobi Docs" OFF)
  96. option(DOCS_AUTO "DOCS automation" OFF)
  97. option(USE_RESOURCE "Use resource download in ECLWatch" OFF)
  98. option(GENERATE_COVERAGE_INFO "Generate coverage info for gcov" OFF)
  99. option(USE_SIGNED_CHAR "Build system with default char type is signed" OFF)
  100. option(USE_UNSIGNED_CHAR "Build system with default char type is unsigned" OFF)
  101. option(USE_MYSQL "Enable mysql support" ON)
  102. option(USE_LIBMEMCACHED "Enable libmemcached support" ON)
  103. option(USE_PYTHON2 "Enable python2 language support for platform build" OFF)
  104. option(USE_PYTHON3 "Enable python3 language support for platform build" ON)
  105. option(USE_OPTIONAL "Automatically disable requested features with missing dependencies" ON)
  106. option(JLIB_ONLY "Build JLIB for other projects such as Configurator, Ganglia Monitoring, etc" OFF)
  107. # Generates code that is more efficient, but will cause problems if target platforms do not support it.
  108. if (CMAKE_SIZEOF_VOID_P EQUAL 8)
  109. option(USE_INLINE_TSC "Inline calls to read TSC (time stamp counter)" ON)
  110. else()
  111. option(USE_INLINE_TSC "Inline calls to read TSC (time stamp counter)" OFF)
  112. endif()
  113. if (APPLE OR WIN32)
  114. option(USE_TBB "Enable Threading Building Block support" OFF)
  115. else()
  116. option(USE_TBB "Enable Threading Building Block support" OFF)
  117. option(USE_TBBMALLOC "Enable Threading Building Block scalable allocator proxy support" OFF)
  118. option(USE_TBBMALLOC_ROXIE "Enable Threading Building Block scalable allocator proxy support in Roxie" OFF)
  119. endif()
  120. option(LOGGING_SERVICE "Configure use of logging service" ON)
  121. option(WSSQL_SERVICE "Configure use of ws_sql service" ON)
  122. option(USE_DIGISIGN "Use digisign" ON)
  123. option(INCLUDE_EE_PLUGINS "Install EE Plugins in Clienttool" OFF)
  124. set(CUSTOM_PACKAGE_SUFFIX "" CACHE STRING "Custom package suffix to differentiate development builds")
  125. MACRO(SET_PLUGIN_PACKAGE plugin)
  126. string(TOLOWER "${plugin}" pname)
  127. if(DEFINED pluginname)
  128. message(FATAL_ERROR "Cannot enable ${pname}, already declared ${pluginname}")
  129. else()
  130. set(pluginname "${pname}")
  131. endif()
  132. foreach(p in ${PLUGINS_LIST})
  133. if(NOT "${p}" STREQUAL "${plugin}" AND ${p})
  134. message(FATAL_ERROR "Cannot declare multiple plugins in a plugin package")
  135. endif()
  136. endforeach()
  137. set(PLUGIN ON)
  138. set(CLIENTTOOLS OFF)
  139. set(PLATFORM OFF)
  140. set(INCLUDE_PLUGINS OFF)
  141. set(SIGN_MODULES OFF)
  142. set(USE_OPTIONAL OFF) # Force failure if we can't find the plugin dependencies
  143. ENDMACRO()
  144. # Plugin options
  145. set(PLUGINS_LIST
  146. REMBED
  147. V8EMBED
  148. MEMCACHED
  149. REDIS
  150. SQS
  151. MYSQLEMBED
  152. JAVAEMBED
  153. SQLITE3EMBED
  154. KAFKA
  155. COUCHBASEEMBED
  156. SPARK
  157. EXAMPLEPLUGIN)
  158. foreach(plugin ${PLUGINS_LIST})
  159. option(${plugin} "Create a package with ONLY the ${plugin} plugin" OFF)
  160. option(INCLUDE_${plugin} "Include ${plugin} within package for testing" OFF)
  161. option(SUPPRESS_${plugin} "Suppress ${plugin} from INCLUDE_PLUGINS build" OFF)
  162. # Plugin Release build for individual package
  163. if(${plugin})
  164. SET_PLUGIN_PACKAGE("${plugin}")
  165. # Development build with all plugins for testing
  166. # Development build with addition of plugin
  167. elseif((INCLUDE_PLUGINS OR INCLUDE_${plugin}) AND (NOT SUPPRESS_${plugin}) AND (NOT PLUGIN))
  168. set(${plugin} ON)
  169. endif()
  170. endforeach()
  171. #"cmake -DEXAMPLEPLUGIN=ON <path-to/HPCC-Platform/>" will configure the plugin makefiles to be built with "make".
  172. set(CMAKE_MODULE_PATH "${HPCC_SOURCE_DIR}/cmake_modules/")
  173. if ( NOT MAKE_DOCS_ONLY )
  174. set(LIBMEMCACHED_MINVERSION "1.0.10")
  175. if(USE_LIBMEMCACHED)
  176. if(WIN32)
  177. message(STATUS "libmemcached not available on Windows. Disabling for build")
  178. set(USE_LIBMEMCACHED OFF)
  179. elseif(APPLE)
  180. message(STATUS "libmemcached not available on macOS. Disabling for build")
  181. set(USE_LIBMEMCACHED OFF)
  182. else()
  183. find_package(LIBMEMCACHED ${LIBMEMCACHED_MINVERSION} REQUIRED)
  184. add_definitions(-DUSE_LIBMEMCACHED)
  185. include_directories(${LIBMEMCACHED_INCLUDE_DIR})
  186. endif()
  187. endif()
  188. endif()
  189. if (SIGN_MODULES)
  190. message(STATUS "GPG signing check")
  191. execute_process(COMMAND bash "-c" "gpg --version | awk 'NR==1{print $3}'"
  192. OUTPUT_VARIABLE GPG_VERSION
  193. OUTPUT_STRIP_TRAILING_WHITESPACE
  194. ERROR_QUIET)
  195. set(GPG_COMMAND_STR "gpg")
  196. if(${GPG_VERSION} VERSION_GREATER "2.1")
  197. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --pinentry-mode loopback --batch --no-tty")
  198. else()
  199. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --batch --no-tty")
  200. endif()
  201. if(DEFINED SIGN_MODULES_PASSPHRASE)
  202. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --passphrase ${SIGN_MODULES_PASSPHRASE}")
  203. endif()
  204. if(DEFINED SIGN_MODULES_KEYID)
  205. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --default-key ${SIGN_MODULES_KEYID}")
  206. endif()
  207. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --output sm_keycheck.asc --clearsign sm_keycheck.tmp")
  208. execute_process(COMMAND rm -f sm_keycheck.tmp sm_keycheck.asc TIMEOUT 5
  209. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} OUTPUT_QUIET ERROR_QUIET)
  210. execute_process(COMMAND touch sm_keycheck.tmp TIMEOUT 5
  211. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} RESULT_VARIABLE t_rc
  212. OUTPUT_QUIET ERROR_QUIET)
  213. if(NOT "${t_rc}" STREQUAL "0")
  214. message(FATAL_ERROR "Failed to create sm_keycheck.tmp for signing")
  215. endif()
  216. execute_process(
  217. COMMAND bash "-c" "${GPG_COMMAND_STR}"
  218. TIMOUT 120
  219. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  220. RESULT_VARIABLE rc_var
  221. OUTPUT_VARIABLE out_var
  222. ERROR_VARIABLE err_var
  223. )
  224. if(NOT "${rc_var}" STREQUAL "0")
  225. message(STATUS "GPG signing check - failed")
  226. message(FATAL_ERROR "gpg signing of std ecllibrary unsupported in current environment. \
  227. If you wish to build without a signed std ecllibrary add -DSIGN_MODULES=OFF to your \
  228. cmake invocation.\n${err_var}")
  229. else()
  230. message(STATUS "GPG signing check - done")
  231. endif()
  232. endif()
  233. if ( USE_XALAN AND USE_LIBXSLT )
  234. set(USE_LIBXSLT OFF)
  235. endif()
  236. if ( USE_LIBXSLT )
  237. set(USE_LIBXML2 ON)
  238. endif()
  239. if ( USE_XALAN )
  240. set(USE_XERCES ON)
  241. endif()
  242. if ( MAKE_DOCS AND CLIENTTOOLS_ONLY )
  243. set( MAKE_DOCS OFF )
  244. endif()
  245. if ( MAKE_DOCS_ONLY AND NOT CLIENTTOOLS_ONLY )
  246. set( MAKE_DOCS ON )
  247. if ( USE_DOCS_AUTO )
  248. set ( DOCS_AUTO ON)
  249. endif()
  250. endif()
  251. if ( CLIENTTOOLS_ONLY )
  252. set(PLATFORM OFF)
  253. set(DEVEL OFF)
  254. endif()
  255. option(PORTALURL "Set url to hpccsystems portal download page")
  256. if ( NOT PORTALURL )
  257. set( PORTALURL "http://hpccsystems.com/download" )
  258. endif()
  259. if(UNIX AND SIGN_MODULES)
  260. execute_process(COMMAND bash "-c" "gpg --version | awk 'NR==1{print $3}'"
  261. OUTPUT_VARIABLE GPG_VERSION
  262. OUTPUT_STRIP_TRAILING_WHITESPACE
  263. ERROR_QUIET)
  264. message(STATUS "gpg version ${GPG_VERSION}")
  265. #export gpg public key used for signing to new installation
  266. add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/pub.key
  267. COMMAND bash "-c" "gpg --output=${CMAKE_BINARY_DIR}/pub.key --batch --no-tty --export ${SIGN_MODULES_KEYID}"
  268. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  269. COMMENT "Exporting public key for eclcc signed modules to ${CMAKE_BINARY_DIR}/pub.key"
  270. VERBATIM
  271. )
  272. add_custom_target(export-stdlib-pubkey ALL
  273. DEPENDS ${CMAKE_BINARY_DIR}/pub.key
  274. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  275. )
  276. install(FILES ${CMAKE_BINARY_DIR}/pub.key DESTINATION .${CONFIG_DIR}/rpmnew COMPONENT Runtime)
  277. install(PROGRAMS ${CMAKE_MODULE_PATH}publickey.install DESTINATION etc/init.d/install COMPONENT Runtime)
  278. endif()
  279. ##########################################################
  280. # common compiler/linker flags
  281. if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
  282. set ( CMAKE_BUILD_TYPE "Release" )
  283. elseif (NOT "${CMAKE_BUILD_TYPE}" MATCHES "^Debug$|^Release$|^RelWithDebInfo$")
  284. message (FATAL_ERROR "Unknown build type ${CMAKE_BUILD_TYPE}")
  285. endif ()
  286. message ("-- Making ${CMAKE_BUILD_TYPE} system")
  287. if (CMAKE_SIZEOF_VOID_P EQUAL 8)
  288. set ( ARCH64BIT 1 )
  289. else ()
  290. set ( ARCH64BIT 0 )
  291. endif ()
  292. message ("-- 64bit architecture is ${ARCH64BIT}")
  293. set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DDEBUG")
  294. IF (USE_INLINE_TSC)
  295. add_definitions (-DINLINE_GET_CYCLES_NOW)
  296. ENDIF()
  297. set (CMAKE_THREAD_PREFER_PTHREAD 1)
  298. find_package(Threads)
  299. IF (NOT THREADS_FOUND)
  300. message(FATAL_ERROR "No threading support found")
  301. ENDIF()
  302. if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
  303. set (CMAKE_COMPILER_IS_CLANGXX 1)
  304. endif()
  305. if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
  306. set (CMAKE_COMPILER_IS_CLANG 1)
  307. endif()
  308. if ((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) AND (NOT ${CMAKE_C_COMPILER_VERSION} MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+"))
  309. execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE CMAKE_C_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
  310. endif ()
  311. if ((CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) AND (NOT ${CMAKE_CXX_COMPILER_VERSION} MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+"))
  312. execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
  313. endif()
  314. if (CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
  315. add_definitions (-fvisibility=hidden)
  316. endif ()
  317. if (CMAKE_COMPILER_IS_CLANGXX AND CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "10.0.0")
  318. add_definitions (-fsanitize=undefined -fno-sanitize=alignment -fsanitize-trap=undefined)
  319. SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=undefined")
  320. SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
  321. endif ()
  322. if ((CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0.0) AND CMAKE_BUILD_TYPE STREQUAL "Debug")
  323. add_definitions (-fsanitize=undefined -fno-sanitize=alignment -fsanitize-undefined-trap-on-error)
  324. SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=undefined")
  325. SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
  326. endif ()
  327. if (CMAKE_COMPILER_IS_CLANGXX)
  328. execute_process( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string )
  329. if (${clang_full_version_string} MATCHES "Apple LLVM version ([0-9]+\\.[0-9]+\\.[0-9]+).*")
  330. string (REGEX REPLACE "Apple LLVM version ([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1" APPLE_CLANG_VERSION ${clang_full_version_string})
  331. endif()
  332. if (${clang_full_version_string} MATCHES ".*based on LLVM ([0-9]+\\.[0-9]+).*")
  333. string (REGEX REPLACE ".*based on LLVM ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION ${clang_full_version_string})
  334. else()
  335. if (${clang_full_version_string} MATCHES ".*clang version ([0-9]+\\.[0-9]+).*")
  336. string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION ${clang_full_version_string})
  337. endif()
  338. endif()
  339. endif ()
  340. if (WIN32)
  341. # On windows, the vcproj generator generates both windows and debug build capabilities, and the release mode is appended to the directory later
  342. # This output location matches what our existing windows release scripts expect - might make sense to move out of tree sometime though
  343. set ( EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" )
  344. set ( LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" )
  345. # Workaround CMake's odd decision to default windows stack size to 10000000
  346. STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
  347. SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
  348. if (${ARCH64BIT} EQUAL 1)
  349. add_definitions(/bigobj)
  350. endif ()
  351. if ("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
  352. if (${ARCH64BIT} EQUAL 0)
  353. add_definitions(/ZI)
  354. else()
  355. add_definitions(/Zi)
  356. endif ()
  357. endif ()
  358. if ("${GIT_COMMAND}" STREQUAL "")
  359. set ( GIT_COMMAND "git.cmd" )
  360. endif ()
  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(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. IF ("${EXTERNALS_DIRECTORY}" STREQUAL "")
  619. SET(bisoncmd "bison")
  620. SET(flexcmd "flex")
  621. ELSE()
  622. IF (WIN32)
  623. SET(bisoncmdprefix "call")
  624. SET(flexcmdprefix "call")
  625. SET(bisoncmd "${EXTERNALS_DIRECTORY}\\bison\\bison.bat")
  626. SET(flexcmd "${EXTERNALS_DIRECTORY}\\bison\\flex.bat")
  627. ELSE ()
  628. SET(bisoncmd "${EXTERNALS_DIRECTORY}/bison/bison")
  629. SET(flexcmd "${EXTERNALS_DIRECTORY}/bison/flex")
  630. ENDIF()
  631. ENDIF()
  632. IF ("${BISON_VERSION}" STREQUAL "")
  633. IF (WIN32)
  634. # cmake bug workaround - it converts path separators fine in add_custom_command but not here
  635. STRING(REPLACE "/" "\\" BISON_exename "${bisoncmd}")
  636. ELSE()
  637. SET(BISON_exename "${bisoncmd}")
  638. ENDIF()
  639. EXECUTE_PROCESS(COMMAND ${BISON_exename} --version
  640. OUTPUT_VARIABLE BISON_version_output
  641. ERROR_VARIABLE BISON_version_error
  642. RESULT_VARIABLE BISON_version_result
  643. OUTPUT_STRIP_TRAILING_WHITESPACE)
  644. STRING(REGEX REPLACE "^[^0-9]*([0-9.]+).*" "\\1" BISON_VERSION "${BISON_version_output}")
  645. ENDIF()
  646. IF ("${FLEX_VERSION}" STREQUAL "")
  647. IF (WIN32)
  648. # cmake bug workaround - it converts path separators fine in add_custom_command but not here
  649. STRING(REPLACE "/" "\\" FLEX_exename "${flexcmd}")
  650. ELSE()
  651. SET(FLEX_exename "${flexcmd}")
  652. ENDIF()
  653. EXECUTE_PROCESS(COMMAND ${FLEX_exename} --version
  654. OUTPUT_VARIABLE FLEX_version_output
  655. ERROR_VARIABLE FLEX_version_error
  656. RESULT_VARIABLE FLEX_version_result
  657. OUTPUT_STRIP_TRAILING_WHITESPACE)
  658. STRING(REGEX REPLACE "^[^0-9]*([0-9.]+).*" "\\1" FLEX_VERSION "${FLEX_version_output}")
  659. ENDIF()
  660. IF ("${BISON_VERSION}" VERSION_LESS "2.4.1")
  661. MESSAGE(FATAL_ERROR "You need bison version 2.4.1 or later to build this project (version ${BISON_VERSION} detected)")
  662. ENDIF()
  663. message(STATUS "Found Bison v${BISON_VERSION}")
  664. IF ("${BISON_VERSION}" VERSION_LESS "2.7.0")
  665. #Ignore all warnings - not recommend to develope on this version!
  666. SET(bisonopt "-Wnone")
  667. ELSE()
  668. SET(bisonopt -Werror -Wno-other)
  669. ENDIF()
  670. IF ("${BISON_VERSION}" VERSION_LESS "3.0.0")
  671. SET(bisonopt ${bisonopt} --name-prefix=eclyy)
  672. SET(ENV{BISON_MAJOR_VER} "2")
  673. ELSE()
  674. SET(bisonopt ${bisonopt} -Dapi.prefix={eclyy})
  675. SET(ENV{BISON_MAJOR_VER} "3")
  676. ENDIF()
  677. IF ("${FLEX_VERSION}" VERSION_LESS "2.5.35")
  678. MESSAGE(FATAL_ERROR "You need flex version 2.5.35 or later to build this project (version ${FLEX_VERSION} detected)")
  679. ENDIF()
  680. IF (CMAKE_COMPILER_IS_GNUCXX)
  681. IF ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "7.3.0")
  682. MESSAGE(FATAL_ERROR "You need Gnu c++ version 7.3.0 or later to build this project (version ${CMAKE_CXX_COMPILER_VERSION} detected)")
  683. ENDIF()
  684. ENDIF()
  685. ENDIF()
  686. ###########################################################################
  687. # External library setup - some can be optionally selected based on USE_xxx flags, some are required
  688. IF (MAKE_DOCS)
  689. find_package(XSLTPROC)
  690. IF (XSLTPROC_FOUND)
  691. add_definitions (-D_USE_XSLTPROC)
  692. ELSE()
  693. message(FATAL_ERROR "XSLTPROC requested but package not found")
  694. ENDIF()
  695. find_package(FOP)
  696. IF (FOP_FOUND)
  697. add_definitions (-D_USE_FOP)
  698. ELSE()
  699. message(FATAL_ERROR "FOP requested but package not found")
  700. ENDIF()
  701. IF ( DOCS_AUTO )
  702. find_package(SAXON)
  703. IF (SAXON_FOUND)
  704. add_definitions (-D_USE_SAXON)
  705. ELSE()
  706. message(FATAL_ERROR "SAXON, a XSLT and XQuery processor, is required for documentation build but not found.")
  707. ENDIF()
  708. ENDIF()
  709. ENDIF(MAKE_DOCS)
  710. IF ( NOT MAKE_DOCS_ONLY )
  711. IF (USE_OPENLDAP)
  712. find_package(OPENLDAP)
  713. IF (OPENLDAP_FOUND)
  714. add_definitions (-D_USE_OPENLDAP)
  715. ELSE()
  716. message(FATAL_ERROR "OPENLDAP requested but package not found")
  717. ENDIF()
  718. ELSE()
  719. add_definitions (-D_NO_LDAP)
  720. ENDIF(USE_OPENLDAP)
  721. IF (USE_CPPUNIT)
  722. find_package(CPPUNIT)
  723. IF (CPPUNIT_FOUND)
  724. add_definitions (-D_USE_CPPUNIT)
  725. include_directories(${CPPUNIT_INCLUDE_DIR})
  726. ELSE()
  727. message(FATAL_ERROR "CPPUNIT requested but package not found")
  728. ENDIF()
  729. ELSE()
  730. SET(CPPUNIT_INCLUDE_DIR "")
  731. SET(CPPUNIT_LIBRARIES "")
  732. ENDIF(USE_CPPUNIT)
  733. IF (USE_AERON)
  734. add_definitions (-D_USE_AERON)
  735. ENDIF(USE_AERON)
  736. IF (CONTAINERIZED)
  737. add_definitions (-D_CONTAINERIZED)
  738. ENDIF(CONTAINERIZED)
  739. IF (USE_ICU)
  740. find_package(ICU)
  741. IF (ICU_FOUND)
  742. add_definitions (-D_USE_ICU)
  743. IF (NOT WIN32)
  744. add_definitions (-DUCHAR_TYPE=uint16_t)
  745. ENDIF()
  746. include_directories(${ICU_INCLUDE_DIR})
  747. ELSE()
  748. message(FATAL_ERROR "ICU requested but package not found")
  749. ENDIF()
  750. ENDIF(USE_ICU)
  751. if(USE_XALAN)
  752. find_package(XALAN)
  753. if (XALAN_FOUND)
  754. add_definitions (-D_USE_XALAN)
  755. else()
  756. message(FATAL_ERROR "XALAN requested but package not found")
  757. endif()
  758. endif(USE_XALAN)
  759. if(USE_LIBXSLT)
  760. find_package(LIBXSLT)
  761. if (LIBXSLT_FOUND)
  762. add_definitions (-D_USE_LIBXSLT)
  763. else()
  764. message(FATAL_ERROR "LIBXSLT requested but package not found")
  765. endif()
  766. endif(USE_LIBXSLT)
  767. if(USE_XERCES)
  768. find_package(XERCES)
  769. if (XERCES_FOUND)
  770. add_definitions (-D_USE_XERCES)
  771. else()
  772. message(FATAL_ERROR "XERCES requested but package not found")
  773. endif()
  774. endif(USE_XERCES)
  775. if(USE_LIBXML2)
  776. find_package(LIBXML2)
  777. if (LIBXML2_FOUND)
  778. add_definitions (-D_USE_LIBXML2)
  779. else()
  780. message(FATAL_ERROR "LIBXML2 requested but package not found")
  781. endif()
  782. endif(USE_LIBXML2)
  783. if(USE_CBLAS)
  784. find_package(CBLAS)
  785. if(CBLAS_FOUND)
  786. add_definitions(-D_USE_CBLAS)
  787. else()
  788. message(FATAL_ERROR "CBLAS requested but package not found")
  789. endif()
  790. endif(USE_CBLAS)
  791. if(USE_ZLIB)
  792. find_package(ZLIB)
  793. if (ZLIB_FOUND)
  794. add_definitions (-D_USE_ZLIB)
  795. else()
  796. message(FATAL_ERROR "ZLIB requested but package not found")
  797. endif()
  798. endif(USE_ZLIB)
  799. if(USE_LIBARCHIVE)
  800. if (WIN32)
  801. if(NOT USE_ZLIB)
  802. message(FATAL ERROR "LIBARCHIVE requires ZLIB")
  803. endif(NOT USE_ZLIB)
  804. find_package(BZip2)
  805. if (BZIP2_FOUND)
  806. add_definitions (-D_USE_BZIP2)
  807. else()
  808. message(FATAL_ERROR "LIBARCHIVE requires BZIP2 but package not found")
  809. endif()
  810. endif (WIN32)
  811. find_package(LIBARCHIVE)
  812. if (LIBARCHIVE_FOUND)
  813. add_definitions (-D_USE_LIBARCHIVE)
  814. else()
  815. message(FATAL_ERROR "LIBARCHIVE requested but package not found")
  816. endif()
  817. endif(USE_LIBARCHIVE)
  818. if(USE_URIPARSER)
  819. find_package(Uriparser)
  820. if (URIPARSER_FOUND)
  821. add_definitions (-D_USE_URIPARSER)
  822. else()
  823. message(FATAL_ERROR "URIPARSER requested but package not found")
  824. endif()
  825. endif(USE_URIPARSER)
  826. if(USE_BOOST_REGEX)
  827. if(CENTOS_6_BOOST)
  828. include(${CMAKE_MODULE_PATH}/buildBOOST_REGEX.cmake)
  829. message(STATUS "CENTOS_6_BOOST_REGEX enabled")
  830. add_definitions (-D_USE_BOOST_REGEX)
  831. else()
  832. find_package(BOOST_REGEX)
  833. if (BOOST_REGEX_FOUND)
  834. message(STATUS "BOOST_REGEX enabled")
  835. add_definitions (-D_USE_BOOST_REGEX)
  836. else()
  837. message(FATAL_ERROR "BOOST_REGEX requested but package not found")
  838. endif()
  839. endif()
  840. else(USE_BOOST_REGEX)
  841. if (USE_C11_REGEX)
  842. if ((NOT CMAKE_COMPILER_IS_GNUCC) OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9.0))
  843. message(STATUS "C11_REGEX enabled")
  844. add_definitions (-D_USE_C11_REGEX)
  845. else()
  846. message(STATUS "C11_REGEX requested but not supported on this platform")
  847. endif()
  848. else(USE_C11_REGEX)
  849. message(STATUS "NO REGEX requested")
  850. endif(USE_C11_REGEX)
  851. endif(USE_BOOST_REGEX)
  852. if(USE_OPENSSL)
  853. find_package(OPENSSL)
  854. if (OPENSSL_FOUND)
  855. add_definitions (-D_USE_OPENSSL)
  856. include_directories(${OPENSSL_INCLUDE_DIR})
  857. link_directories(${OPENSSL_LIBRARY_DIR})
  858. else()
  859. message(FATAL_ERROR "OPENSSL requested but package not found")
  860. endif()
  861. endif(USE_OPENSSL)
  862. if(USE_MYSQL_REPOSITORY)
  863. find_package(MYSQL)
  864. if (MYSQL_FOUND)
  865. add_definitions (-D_USE_MYSQL_REPOSITORY)
  866. else()
  867. message(FATAL_ERROR "MYSQL requested but package not found")
  868. endif()
  869. else()
  870. add_definitions (-D_NO_MYSQL_REPOSITORY)
  871. endif(USE_MYSQL_REPOSITORY)
  872. if(USE_APR)
  873. find_package(APR)
  874. if (APR_FOUND)
  875. add_definitions (-D_USE_APR)
  876. include_directories(${APR_INCLUDE_DIR})
  877. link_directories(${APR_LIBRARY_DIR})
  878. else()
  879. message(FATAL_ERROR "APR requested but package not found")
  880. endif()
  881. if (APRUTIL_FOUND)
  882. include_directories(${APRUTIL_INCLUDE_DIR})
  883. link_directories(${APRUTIL_LIBRARY_DIR})
  884. else()
  885. message(FATAL_ERROR "APRUTIL requested but package not found")
  886. endif()
  887. else()
  888. add_definitions (-D_NO_APR)
  889. endif(USE_APR)
  890. if (USE_NUMA)
  891. find_package(NUMA)
  892. add_definitions (-D_USE_NUMA)
  893. if (NOT NUMA_FOUND)
  894. message(FATAL_ERROR "NUMA requested but package not found")
  895. endif()
  896. endif()
  897. if(USE_TBB)
  898. message(STATUS "Enabled use of TBB")
  899. add_definitions (-D_USE_TBB)
  900. endif(USE_TBB)
  901. if(USE_TBBMALLOC)
  902. message(STATUS "Enabled use of TBBMALLOC")
  903. add_definitions (-D_USE_TBBMALLOC)
  904. if(USE_TBBMALLOC_ROXIE)
  905. message(STATUS "Enabled use of TBBMALLOC_ROXIE")
  906. endif(USE_TBBMALLOC_ROXIE)
  907. endif(USE_TBBMALLOC)
  908. ENDIF()
  909. ###########################################################################
  910. ###
  911. ## The following sets the install directories and names.
  912. ###
  913. if ( PLATFORM OR PLUGIN )
  914. set ( CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" )
  915. else ( )
  916. set ( CMAKE_INSTALL_PREFIX "${INSTALL_DIR}/${version}/clienttools" )
  917. endif ( PLATFORM OR PLUGIN )
  918. if(APPLE)
  919. set(CMAKE_MACOSX_RPATH ON)
  920. endif()
  921. set (CMAKE_SKIP_BUILD_RPATH FALSE)
  922. set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  923. set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_DIR};${CMAKE_INSTALL_PREFIX}/${PLUGINS_DIR};${CMAKE_INSTALL_PREFIX}/${LIB_DIR}/external")
  924. set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  925. MACRO (FETCH_GIT_TAG workdir edition result)
  926. execute_process(COMMAND "${GIT_COMMAND}" describe --tags --dirty --abbrev=6 --match ${edition}*
  927. WORKING_DIRECTORY "${workdir}"
  928. OUTPUT_VARIABLE ${result}
  929. ERROR_QUIET
  930. OUTPUT_STRIP_TRAILING_WHITESPACE)
  931. if ("${${result}}" STREQUAL "")
  932. execute_process(COMMAND "${GIT_COMMAND}" describe --always --tags --all --abbrev=6 --dirty --long
  933. WORKING_DIRECTORY "${workdir}"
  934. OUTPUT_VARIABLE ${result}
  935. ERROR_QUIET
  936. OUTPUT_STRIP_TRAILING_WHITESPACE)
  937. endif()
  938. ENDMACRO()
  939. function(LIST_TO_STRING separator outvar)
  940. set ( tmp_str "" )
  941. list (LENGTH ARGN list_length)
  942. if ( ${list_length} LESS 2 )
  943. set ( tmp_str "${ARGN}" )
  944. else()
  945. math(EXPR last_index "${list_length} - 1")
  946. foreach( index RANGE ${last_index} )
  947. if ( ${index} GREATER 0 )
  948. list( GET ARGN ${index} element )
  949. set( tmp_str "${tmp_str}${separator}${element}")
  950. else()
  951. list( GET ARGN 0 element )
  952. set( tmp_str "${element}")
  953. endif()
  954. endforeach()
  955. endif()
  956. set ( ${outvar} "${tmp_str}" PARENT_SCOPE )
  957. endfunction()
  958. function(STRING_TO_LIST separator outvar stringvar)
  959. set( tmp_list "" )
  960. string(REPLACE "${separator}" ";" tmp_list ${stringvar})
  961. string(STRIP "${tmp_list}" tmp_list)
  962. set( ${outvar} "${tmp_list}" PARENT_SCOPE)
  963. endfunction()
  964. ###########################################################################
  965. ###
  966. ## The following sets the dependency list for a package
  967. ###
  968. ###########################################################################
  969. function(SET_DEPENDENCIES cpackvar)
  970. set(_tmp "")
  971. if(${cpackvar})
  972. STRING_TO_LIST(", " _tmp ${${cpackvar}})
  973. endif()
  974. foreach(element ${ARGN})
  975. list(APPEND _tmp ${element})
  976. endforeach()
  977. list(REMOVE_DUPLICATES _tmp)
  978. LIST_TO_STRING(", " _tmp "${_tmp}")
  979. set(${cpackvar} "${_tmp}" CACHE STRING "" FORCE)
  980. message(STATUS "Updated ${cpackvar} to ${${cpackvar}}")
  981. endfunction()
  982. MACRO(SIGN_MODULE module)
  983. if(SIGN_MODULES)
  984. set(GPG_COMMAND_STR "gpg")
  985. if(DEFINED SIGN_MODULES_PASSPHRASE)
  986. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --passphrase ${SIGN_MODULES_PASSPHRASE}")
  987. endif()
  988. if(DEFINED SIGN_MODULES_KEYID)
  989. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --default-key ${SIGN_MODULES_KEYID}")
  990. endif()
  991. if("${GPG_VERSION}" VERSION_GREATER "2.1")
  992. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --pinentry-mode loopback")
  993. endif()
  994. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --batch --yes --no-tty --output ${CMAKE_CURRENT_BINARY_DIR}/${module} --clearsign ${module}")
  995. add_custom_command(
  996. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${module}
  997. COMMAND bash "-c" "${GPG_COMMAND_STR}"
  998. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${module}
  999. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  1000. COMMENT "Adding signed ${module} to project"
  1001. )
  1002. else()
  1003. add_custom_command(
  1004. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${module}
  1005. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${module} ${CMAKE_CURRENT_BINARY_DIR}/${module}
  1006. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${module}
  1007. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  1008. COMMENT "Adding unsigned ${module} to project"
  1009. VERBATIM
  1010. )
  1011. endif()
  1012. # Use custom target to cause build to fail if dependency file isn't generated by gpg or cp commands
  1013. get_filename_component(module_without_extension ${module} NAME_WE)
  1014. add_custom_target(
  1015. ${module_without_extension}-ecl ALL
  1016. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${module}
  1017. )
  1018. if(SIGN_MODULES)
  1019. add_dependencies(${module_without_extension}-ecl export-stdlib-pubkey)
  1020. endif()
  1021. ENDMACRO()
  1022. endif ("${COMMONSETUP_DONE}" STREQUAL "")