commonSetup.cmake 42 KB

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