commonSetup.cmake 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101
  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. if (CMAKE_COMPILER_IS_GNUCXX)
  451. #Ensure that missing symbols are reported as errors at link time (default for osx/windows)
  452. SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
  453. SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,defs")
  454. endif()
  455. macro(HPCC_ADD_EXECUTABLE target)
  456. add_executable(${target} ${ARGN})
  457. endmacro(HPCC_ADD_EXECUTABLE target)
  458. macro(HPCC_ADD_LIBRARY target)
  459. add_library(${target} ${ARGN})
  460. endmacro(HPCC_ADD_LIBRARY target)
  461. # This Macro is provided as Public domain from
  462. # http://www.cmake.org/Wiki/CMakeMacroParseArguments
  463. MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
  464. SET(DEFAULT_ARGS)
  465. FOREACH(arg_name ${arg_names})
  466. SET(${prefix}_${arg_name})
  467. ENDFOREACH(arg_name)
  468. FOREACH(option ${option_names})
  469. SET(${prefix}_${option} FALSE)
  470. ENDFOREACH(option)
  471. SET(current_arg_name DEFAULT_ARGS)
  472. SET(current_arg_list)
  473. FOREACH(arg ${ARGN})
  474. SET(larg_names ${arg_names})
  475. LIST(FIND larg_names "${arg}" is_arg_name)
  476. IF (is_arg_name GREATER -1)
  477. SET(${prefix}_${current_arg_name} ${current_arg_list})
  478. SET(current_arg_name ${arg})
  479. SET(current_arg_list)
  480. ELSE (is_arg_name GREATER -1)
  481. SET(loption_names ${option_names})
  482. LIST(FIND loption_names "${arg}" is_option)
  483. IF (is_option GREATER -1)
  484. SET(${prefix}_${arg} TRUE)
  485. ELSE (is_option GREATER -1)
  486. SET(current_arg_list ${current_arg_list} ${arg})
  487. ENDIF (is_option GREATER -1)
  488. ENDIF (is_arg_name GREATER -1)
  489. ENDFOREACH(arg)
  490. SET(${prefix}_${current_arg_name} ${current_arg_list})
  491. ENDMACRO(PARSE_ARGUMENTS)
  492. # This macro allows for disabling a directory based on the value of a variable passed to the macro.
  493. #
  494. # ex. HPCC_ADD_SUBDIRECORY(roxie ${CLIENTTOOLS_ONLY})
  495. #
  496. # This call will disable the roxie dir if -DCLIENTTOOLS_ONLY=ON is set at config time.
  497. #
  498. macro(HPCC_ADD_SUBDIRECTORY)
  499. set(adddir OFF)
  500. PARSE_ARGUMENTS(_HPCC_SUB "" "" ${ARGN})
  501. LIST(GET _HPCC_SUB_DEFAULT_ARGS 0 subdir)
  502. set(flags ${_HPCC_SUB_DEFAULT_ARGS})
  503. LIST(REMOVE_AT flags 0)
  504. LIST(LENGTH flags length)
  505. if(NOT length)
  506. set(adddir ON)
  507. else()
  508. foreach(f ${flags})
  509. if(${f})
  510. set(adddir ON)
  511. endif()
  512. endforeach()
  513. endif()
  514. if ( adddir )
  515. add_subdirectory(${subdir})
  516. endif()
  517. endmacro(HPCC_ADD_SUBDIRECTORY)
  518. set ( SCM_GENERATED_DIR ${CMAKE_BINARY_DIR}/generated )
  519. ###############################################################
  520. # Macro for Logging Plugin build in CMake
  521. macro(LOG_PLUGIN)
  522. PARSE_ARGUMENTS(pLOG
  523. "OPTION;MDEPS"
  524. ""
  525. ${ARGN})
  526. LIST(GET pLOG_DEFAULT_ARGS 0 PLUGIN_NAME)
  527. if(${pLOG_OPTION})
  528. message(STATUS "Building Plugin: ${PLUGIN_NAME}" )
  529. else()
  530. message(WARNING "Not Building Plugin: ${PLUGIN_NAME}")
  531. foreach (dep ${pLOG_MDEPS})
  532. message(WARNING "Missing dependency: ${dep}")
  533. endforeach()
  534. if(NOT USE_OPTIONAL)
  535. message(FATAL_ERROR "Optional dependencies missing and USE_OPTIONAL OFF")
  536. endif()
  537. endif()
  538. endmacro()
  539. ###############################################################
  540. # Macro for adding an optional plugin to the CMake build.
  541. macro(ADD_PLUGIN)
  542. PARSE_ARGUMENTS(PLUGIN
  543. "PACKAGES;MINVERSION;MAXVERSION"
  544. ""
  545. ${ARGN})
  546. LIST(GET PLUGIN_DEFAULT_ARGS 0 PLUGIN_NAME)
  547. string(TOUPPER ${PLUGIN_NAME} name)
  548. set(ALL_PLUGINS_FOUND 1)
  549. set(PLUGIN_MDEPS ${PLUGIN_NAME}_mdeps)
  550. set(${PLUGIN_MDEPS} "")
  551. foreach(package ${PLUGIN_PACKAGES})
  552. set(findvar ${package}_FOUND)
  553. string(TOUPPER ${findvar} PACKAGE_FOUND)
  554. if("${PLUGIN_MINVERSION}" STREQUAL "")
  555. find_package(${package})
  556. else()
  557. set(findvar ${package}_VERSION_STRING)
  558. string(TOUPPER ${findvar} PACKAGE_VERSION_STRING)
  559. find_package(${package} ${PLUGIN_MINVERSION} )
  560. if ("${${PACKAGE_VERSION_STRING}}" VERSION_GREATER "${PLUGIN_MAXVERSION}")
  561. set(${ALL_PLUGINS_FOUND} 0)
  562. endif()
  563. endif()
  564. if(NOT ${PACKAGE_FOUND})
  565. set(ALL_PLUGINS_FOUND 0)
  566. set(${PLUGIN_MDEPS} ${${PLUGIN_MDEPS}} ${package})
  567. endif()
  568. endforeach()
  569. set(MAKE_${name} ${ALL_PLUGINS_FOUND})
  570. LOG_PLUGIN(${PLUGIN_NAME} OPTION ${ALL_PLUGINS_FOUND} MDEPS ${${PLUGIN_MDEPS}})
  571. if(${ALL_PLUGINS_FOUND})
  572. set(bPLUGINS ${bPLUGINS} ${PLUGIN_NAME})
  573. else()
  574. set(nbPLUGINS ${nbPLUGINS} ${PLUGIN_NAME})
  575. endif()
  576. endmacro()
  577. ##################################################################
  578. # Build tag generation
  579. set(projname ${HPCC_PROJECT})
  580. set(majorver ${HPCC_MAJOR})
  581. set(minorver ${HPCC_MINOR})
  582. set(point ${HPCC_POINT})
  583. if ( "${HPCC_MATURITY}" STREQUAL "release" )
  584. set(stagever "${HPCC_SEQUENCE}")
  585. else()
  586. set(stagever "${HPCC_MATURITY}${HPCC_SEQUENCE}")
  587. endif()
  588. set(version ${majorver}.${minorver}.${point})
  589. IF ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  590. set( stagever "${stagever}Debug" )
  591. ENDIF ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  592. ###########################################################################
  593. if(USE_OPTIONAL)
  594. message(WARNING "USE_OPTIONAL set - missing dependencies for optional features will automatically disable them")
  595. endif()
  596. if(NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
  597. message(STATUS "Using externals directory at ${EXTERNALS_DIRECTORY}")
  598. endif()
  599. IF ( NOT MAKE_DOCS_ONLY )
  600. IF ("${EXTERNALS_DIRECTORY}" STREQUAL "")
  601. SET(bisoncmd "bison")
  602. SET(flexcmd "flex")
  603. ELSE()
  604. IF (WIN32)
  605. SET(bisoncmdprefix "call")
  606. SET(flexcmdprefix "call")
  607. SET(bisoncmd "${EXTERNALS_DIRECTORY}\\bison\\bison.bat")
  608. SET(flexcmd "${EXTERNALS_DIRECTORY}\\bison\\flex.bat")
  609. ELSE ()
  610. SET(bisoncmd "${EXTERNALS_DIRECTORY}/bison/bison")
  611. SET(flexcmd "${EXTERNALS_DIRECTORY}/bison/flex")
  612. ENDIF()
  613. ENDIF()
  614. IF ("${BISON_VERSION}" STREQUAL "")
  615. IF (WIN32)
  616. # cmake bug workaround - it converts path separators fine in add_custom_command but not here
  617. STRING(REPLACE "/" "\\" BISON_exename "${bisoncmd}")
  618. ELSE()
  619. SET(BISON_exename "${bisoncmd}")
  620. ENDIF()
  621. EXECUTE_PROCESS(COMMAND ${BISON_exename} --version
  622. OUTPUT_VARIABLE BISON_version_output
  623. ERROR_VARIABLE BISON_version_error
  624. RESULT_VARIABLE BISON_version_result
  625. OUTPUT_STRIP_TRAILING_WHITESPACE)
  626. STRING(REGEX REPLACE "^[^0-9]*([0-9.]+).*" "\\1" BISON_VERSION "${BISON_version_output}")
  627. ENDIF()
  628. IF ("${FLEX_VERSION}" STREQUAL "")
  629. IF (WIN32)
  630. # cmake bug workaround - it converts path separators fine in add_custom_command but not here
  631. STRING(REPLACE "/" "\\" FLEX_exename "${flexcmd}")
  632. ELSE()
  633. SET(FLEX_exename "${flexcmd}")
  634. ENDIF()
  635. EXECUTE_PROCESS(COMMAND ${FLEX_exename} --version
  636. OUTPUT_VARIABLE FLEX_version_output
  637. ERROR_VARIABLE FLEX_version_error
  638. RESULT_VARIABLE FLEX_version_result
  639. OUTPUT_STRIP_TRAILING_WHITESPACE)
  640. STRING(REGEX REPLACE "^[^0-9]*([0-9.]+).*" "\\1" FLEX_VERSION "${FLEX_version_output}")
  641. ENDIF()
  642. IF ("${BISON_VERSION}" VERSION_LESS "2.4.1")
  643. MESSAGE(FATAL_ERROR "You need bison version 2.4.1 or later to build this project (version ${BISON_VERSION} detected)")
  644. ENDIF()
  645. message(STATUS "Found Bison v${BISON_VERSION}")
  646. IF ("${BISON_VERSION}" VERSION_LESS "2.7.0")
  647. #Ignore all warnings - not recommend to develope on this version!
  648. SET(bisonopt "-Wnone")
  649. ELSE()
  650. SET(bisonopt -Werror -Wno-other)
  651. ENDIF()
  652. IF ("${BISON_VERSION}" VERSION_LESS "3.0.0")
  653. SET(bisonopt ${bisonopt} --name-prefix=eclyy)
  654. SET(ENV{BISON_MAJOR_VER} "2")
  655. ELSE()
  656. SET(bisonopt ${bisonopt} -Dapi.prefix={eclyy})
  657. SET(ENV{BISON_MAJOR_VER} "3")
  658. ENDIF()
  659. IF ("${FLEX_VERSION}" VERSION_LESS "2.5.35")
  660. MESSAGE(FATAL_ERROR "You need flex version 2.5.35 or later to build this project (version ${FLEX_VERSION} detected)")
  661. ENDIF()
  662. IF (CMAKE_COMPILER_IS_GNUCXX)
  663. IF ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.7.3")
  664. MESSAGE(FATAL_ERROR "You need Gnu c++ version 4.7.3 or later to build this project (version ${CMAKE_CXX_COMPILER_VERSION} detected)")
  665. ENDIF()
  666. ENDIF()
  667. ENDIF()
  668. ###########################################################################
  669. # External library setup - some can be optionally selected based on USE_xxx flags, some are required
  670. IF (MAKE_DOCS)
  671. find_package(XSLTPROC)
  672. IF (XSLTPROC_FOUND)
  673. add_definitions (-D_USE_XSLTPROC)
  674. ELSE()
  675. message(FATAL_ERROR "XSLTPROC requested but package not found")
  676. ENDIF()
  677. find_package(FOP)
  678. IF (FOP_FOUND)
  679. add_definitions (-D_USE_FOP)
  680. ELSE()
  681. message(FATAL_ERROR "FOP requested but package not found")
  682. ENDIF()
  683. IF ( DOCS_AUTO )
  684. find_package(SAXON)
  685. IF (SAXON_FOUND)
  686. add_definitions (-D_USE_SAXON)
  687. ELSE()
  688. message(FATAL_ERROR "SAXON, a XSLT and XQuery processor, is required for documentation build but not found.")
  689. ENDIF()
  690. ENDIF()
  691. ENDIF(MAKE_DOCS)
  692. IF ( NOT MAKE_DOCS_ONLY )
  693. IF (USE_OPENLDAP)
  694. find_package(OPENLDAP)
  695. IF (OPENLDAP_FOUND)
  696. add_definitions (-D_USE_OPENLDAP)
  697. ELSE()
  698. message(FATAL_ERROR "OPENLDAP requested but package not found")
  699. ENDIF()
  700. ELSE()
  701. add_definitions (-D_NO_LDAP)
  702. ENDIF(USE_OPENLDAP)
  703. IF (USE_CPPUNIT)
  704. find_package(CPPUNIT)
  705. IF (CPPUNIT_FOUND)
  706. add_definitions (-D_USE_CPPUNIT)
  707. include_directories(${CPPUNIT_INCLUDE_DIR})
  708. ELSE()
  709. message(FATAL_ERROR "CPPUNIT requested but package not found")
  710. ENDIF()
  711. ELSE()
  712. SET(CPPUNIT_INCLUDE_DIR "")
  713. SET(CPPUNIT_LIBRARIES "")
  714. ENDIF(USE_CPPUNIT)
  715. IF (USE_AERON)
  716. add_definitions (-D_USE_AERON)
  717. ENDIF(USE_AERON)
  718. IF (CONTAINERIZED)
  719. add_definitions (-D_CONTAINERIZED)
  720. ENDIF(CONTAINERIZED)
  721. IF (USE_ICU)
  722. find_package(ICU)
  723. IF (ICU_FOUND)
  724. add_definitions (-D_USE_ICU)
  725. IF (NOT WIN32)
  726. add_definitions (-DUCHAR_TYPE=uint16_t)
  727. ENDIF()
  728. include_directories(${ICU_INCLUDE_DIR})
  729. ELSE()
  730. message(FATAL_ERROR "ICU requested but package not found")
  731. ENDIF()
  732. ENDIF(USE_ICU)
  733. if(USE_XALAN)
  734. find_package(XALAN)
  735. if (XALAN_FOUND)
  736. add_definitions (-D_USE_XALAN)
  737. else()
  738. message(FATAL_ERROR "XALAN requested but package not found")
  739. endif()
  740. endif(USE_XALAN)
  741. if(USE_LIBXSLT)
  742. find_package(LIBXSLT)
  743. if (LIBXSLT_FOUND)
  744. add_definitions (-D_USE_LIBXSLT)
  745. else()
  746. message(FATAL_ERROR "LIBXSLT requested but package not found")
  747. endif()
  748. endif(USE_LIBXSLT)
  749. if(USE_XERCES)
  750. find_package(XERCES)
  751. if (XERCES_FOUND)
  752. add_definitions (-D_USE_XERCES)
  753. else()
  754. message(FATAL_ERROR "XERCES requested but package not found")
  755. endif()
  756. endif(USE_XERCES)
  757. if(USE_LIBXML2)
  758. find_package(LIBXML2)
  759. if (LIBXML2_FOUND)
  760. add_definitions (-D_USE_LIBXML2)
  761. else()
  762. message(FATAL_ERROR "LIBXML2 requested but package not found")
  763. endif()
  764. endif(USE_LIBXML2)
  765. if(USE_CBLAS)
  766. find_package(CBLAS)
  767. if(CBLAS_FOUND)
  768. add_definitions(-D_USE_CBLAS)
  769. else()
  770. message(FATAL_ERROR "CBLAS requested but package not found")
  771. endif()
  772. endif(USE_CBLAS)
  773. if(USE_ZLIB)
  774. find_package(ZLIB)
  775. if (ZLIB_FOUND)
  776. add_definitions (-D_USE_ZLIB)
  777. else()
  778. message(FATAL_ERROR "ZLIB requested but package not found")
  779. endif()
  780. endif(USE_ZLIB)
  781. if(USE_LIBARCHIVE)
  782. if (WIN32)
  783. if(NOT USE_ZLIB)
  784. message(FATAL ERROR "LIBARCHIVE requires ZLIB")
  785. endif(NOT USE_ZLIB)
  786. find_package(BZip2)
  787. if (BZIP2_FOUND)
  788. add_definitions (-D_USE_BZIP2)
  789. else()
  790. message(FATAL_ERROR "LIBARCHIVE requires BZIP2 but package not found")
  791. endif()
  792. endif (WIN32)
  793. find_package(LIBARCHIVE)
  794. if (LIBARCHIVE_FOUND)
  795. add_definitions (-D_USE_LIBARCHIVE)
  796. else()
  797. message(FATAL_ERROR "LIBARCHIVE requested but package not found")
  798. endif()
  799. endif(USE_LIBARCHIVE)
  800. if(USE_URIPARSER)
  801. find_package(Uriparser)
  802. if (URIPARSER_FOUND)
  803. add_definitions (-D_USE_URIPARSER)
  804. else()
  805. message(FATAL_ERROR "URIPARSER requested but package not found")
  806. endif()
  807. endif(USE_URIPARSER)
  808. if(USE_BOOST_REGEX)
  809. if(CENTOS_6_BOOST)
  810. include(${CMAKE_MODULE_PATH}/buildBOOST_REGEX.cmake)
  811. message(STATUS "CENTOS_6_BOOST_REGEX enabled")
  812. add_definitions (-D_USE_BOOST_REGEX)
  813. else()
  814. find_package(BOOST_REGEX)
  815. if (BOOST_REGEX_FOUND)
  816. message(STATUS "BOOST_REGEX enabled")
  817. add_definitions (-D_USE_BOOST_REGEX)
  818. else()
  819. message(FATAL_ERROR "BOOST_REGEX requested but package not found")
  820. endif()
  821. endif()
  822. else(USE_BOOST_REGEX)
  823. if (USE_C11_REGEX)
  824. if ((NOT CMAKE_COMPILER_IS_GNUCC) OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9.0))
  825. message(STATUS "C11_REGEX enabled")
  826. add_definitions (-D_USE_C11_REGEX)
  827. else()
  828. message(STATUS "C11_REGEX requested but not supported on this platform")
  829. endif()
  830. else(USE_C11_REGEX)
  831. message(STATUS "NO REGEX requested")
  832. endif(USE_C11_REGEX)
  833. endif(USE_BOOST_REGEX)
  834. if(USE_OPENSSL)
  835. find_package(OPENSSL)
  836. if (OPENSSL_FOUND)
  837. add_definitions (-D_USE_OPENSSL)
  838. include_directories(${OPENSSL_INCLUDE_DIR})
  839. link_directories(${OPENSSL_LIBRARY_DIR})
  840. else()
  841. message(FATAL_ERROR "OPENSSL requested but package not found")
  842. endif()
  843. endif(USE_OPENSSL)
  844. if(USE_MYSQL_REPOSITORY)
  845. find_package(MYSQL)
  846. if (MYSQL_FOUND)
  847. add_definitions (-D_USE_MYSQL_REPOSITORY)
  848. else()
  849. message(FATAL_ERROR "MYSQL requested but package not found")
  850. endif()
  851. else()
  852. add_definitions (-D_NO_MYSQL_REPOSITORY)
  853. endif(USE_MYSQL_REPOSITORY)
  854. if(USE_APR)
  855. find_package(APR)
  856. if (APR_FOUND)
  857. add_definitions (-D_USE_APR)
  858. include_directories(${APR_INCLUDE_DIR})
  859. link_directories(${APR_LIBRARY_DIR})
  860. else()
  861. message(FATAL_ERROR "APR requested but package not found")
  862. endif()
  863. if (APRUTIL_FOUND)
  864. include_directories(${APRUTIL_INCLUDE_DIR})
  865. link_directories(${APRUTIL_LIBRARY_DIR})
  866. else()
  867. message(FATAL_ERROR "APRUTIL requested but package not found")
  868. endif()
  869. else()
  870. add_definitions (-D_NO_APR)
  871. endif(USE_APR)
  872. if (USE_NUMA)
  873. find_package(NUMA)
  874. add_definitions (-D_USE_NUMA)
  875. if (NOT NUMA_FOUND)
  876. message(FATAL_ERROR "NUMA requested but package not found")
  877. endif()
  878. endif()
  879. if(USE_TBB)
  880. message(STATUS "Enabled use of TBB")
  881. add_definitions (-D_USE_TBB)
  882. endif(USE_TBB)
  883. if(USE_TBBMALLOC)
  884. message(STATUS "Enabled use of TBBMALLOC")
  885. add_definitions (-D_USE_TBBMALLOC)
  886. if(USE_TBBMALLOC_ROXIE)
  887. message(STATUS "Enabled use of TBBMALLOC_ROXIE")
  888. endif(USE_TBBMALLOC_ROXIE)
  889. endif(USE_TBBMALLOC)
  890. ENDIF()
  891. ###########################################################################
  892. ###
  893. ## The following sets the install directories and names.
  894. ###
  895. if ( PLATFORM OR PLUGIN )
  896. set ( CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" )
  897. else ( )
  898. set ( CMAKE_INSTALL_PREFIX "${INSTALL_DIR}/${version}/clienttools" )
  899. endif ( PLATFORM OR PLUGIN )
  900. if(APPLE)
  901. set(CMAKE_MACOSX_RPATH ON)
  902. endif()
  903. set (CMAKE_SKIP_BUILD_RPATH FALSE)
  904. set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  905. set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_DIR};${CMAKE_INSTALL_PREFIX}/${PLUGINS_DIR};${CMAKE_INSTALL_PREFIX}/${LIB_DIR}/external")
  906. set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  907. MACRO (FETCH_GIT_TAG workdir edition result)
  908. execute_process(COMMAND "${GIT_COMMAND}" describe --tags --dirty --abbrev=6 --match ${edition}*
  909. WORKING_DIRECTORY "${workdir}"
  910. OUTPUT_VARIABLE ${result}
  911. ERROR_QUIET
  912. OUTPUT_STRIP_TRAILING_WHITESPACE)
  913. if ("${${result}}" STREQUAL "")
  914. execute_process(COMMAND "${GIT_COMMAND}" describe --always --tags --all --abbrev=6 --dirty --long
  915. WORKING_DIRECTORY "${workdir}"
  916. OUTPUT_VARIABLE ${result}
  917. ERROR_QUIET
  918. OUTPUT_STRIP_TRAILING_WHITESPACE)
  919. endif()
  920. ENDMACRO()
  921. function(LIST_TO_STRING separator outvar)
  922. set ( tmp_str "" )
  923. list (LENGTH ARGN list_length)
  924. if ( ${list_length} LESS 2 )
  925. set ( tmp_str "${ARGN}" )
  926. else()
  927. math(EXPR last_index "${list_length} - 1")
  928. foreach( index RANGE ${last_index} )
  929. if ( ${index} GREATER 0 )
  930. list( GET ARGN ${index} element )
  931. set( tmp_str "${tmp_str}${separator}${element}")
  932. else()
  933. list( GET ARGN 0 element )
  934. set( tmp_str "${element}")
  935. endif()
  936. endforeach()
  937. endif()
  938. set ( ${outvar} "${tmp_str}" PARENT_SCOPE )
  939. endfunction()
  940. function(STRING_TO_LIST separator outvar stringvar)
  941. set( tmp_list "" )
  942. string(REPLACE "${separator}" ";" tmp_list ${stringvar})
  943. string(STRIP "${tmp_list}" tmp_list)
  944. set( ${outvar} "${tmp_list}" PARENT_SCOPE)
  945. endfunction()
  946. ###########################################################################
  947. ###
  948. ## The following sets the dependency list for a package
  949. ###
  950. ###########################################################################
  951. function(SET_DEPENDENCIES cpackvar)
  952. set(_tmp "")
  953. if(${cpackvar})
  954. STRING_TO_LIST(", " _tmp ${${cpackvar}})
  955. endif()
  956. foreach(element ${ARGN})
  957. list(APPEND _tmp ${element})
  958. endforeach()
  959. list(REMOVE_DUPLICATES _tmp)
  960. LIST_TO_STRING(", " _tmp "${_tmp}")
  961. set(${cpackvar} "${_tmp}" CACHE STRING "" FORCE)
  962. message(STATUS "Updated ${cpackvar} to ${${cpackvar}}")
  963. endfunction()
  964. MACRO(SIGN_MODULE module)
  965. if(SIGN_MODULES)
  966. set(GPG_COMMAND_STR "gpg")
  967. if(DEFINED SIGN_MODULES_PASSPHRASE)
  968. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --passphrase ${SIGN_MODULES_PASSPHRASE}")
  969. endif()
  970. if(DEFINED SIGN_MODULES_KEYID)
  971. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --default-key ${SIGN_MODULES_KEYID}")
  972. endif()
  973. if("${GPG_VERSION}" VERSION_GREATER "2.1")
  974. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --pinentry-mode loopback")
  975. endif()
  976. set(GPG_COMMAND_STR "${GPG_COMMAND_STR} --batch --yes --no-tty --output ${CMAKE_CURRENT_BINARY_DIR}/${module} --clearsign ${module}")
  977. add_custom_command(
  978. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${module}
  979. COMMAND bash "-c" "${GPG_COMMAND_STR}"
  980. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${module}
  981. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  982. COMMENT "Adding signed ${module} to project"
  983. )
  984. else()
  985. add_custom_command(
  986. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${module}
  987. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${module} ${CMAKE_CURRENT_BINARY_DIR}/${module}
  988. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${module}
  989. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  990. COMMENT "Adding unsigned ${module} to project"
  991. VERBATIM
  992. )
  993. endif()
  994. # Use custom target to cause build to fail if dependency file isn't generated by gpg or cp commands
  995. get_filename_component(module_without_extension ${module} NAME_WE)
  996. add_custom_target(
  997. ${module_without_extension}-ecl ALL
  998. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${module}
  999. )
  1000. if(SIGN_MODULES)
  1001. add_dependencies(${module_without_extension}-ecl export-stdlib-pubkey)
  1002. endif()
  1003. ENDMACRO()
  1004. endif ("${COMMONSETUP_DONE}" STREQUAL "")