commonSetup.cmake 37 KB

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