commonSetup.cmake 38 KB

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