commonSetup.cmake 39 KB

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