commonSetup.cmake 43 KB

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