commonSetup.cmake 38 KB

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