commonSetup.cmake 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  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. endif()
  39. option(CLIENTTOOLS "Enable the building/inclusion of a Client Tools component." ON)
  40. option(PLATFORM "Enable the building/inclusion of a Platform component." ON)
  41. option(DEVEL "Enable the building/inclusion of a Development component." OFF)
  42. option(CLIENTTOOLS_ONLY "Enable the building of Client Tools only." OFF)
  43. if (APPLE OR WIN32)
  44. option(USE_BINUTILS "Enable use of binutils to embed workunit info into shared objects" OFF)
  45. else()
  46. option(USE_BINUTILS "Enable use of binutils to embed workunit info into shared objects" ON)
  47. endif()
  48. option(USE_CPPUNIT "Enable unit tests (requires cppunit)" OFF)
  49. option(USE_OPENLDAP "Enable OpenLDAP support (requires OpenLDAP)" ON)
  50. option(USE_ICU "Enable unicode support (requires ICU)" ON)
  51. option(USE_BOOST_REGEX "Configure use of boost regex" ON)
  52. option(Boost_USE_STATIC_LIBS "Use boost_regex static library for RPM BUILD" OFF)
  53. option(USE_OPENSSL "Configure use of OpenSSL" ON)
  54. option(USE_ZLIB "Configure use of zlib" ON)
  55. if (WIN32)
  56. option(USE_GIT "Configure use of GIT (Hooks)" OFF)
  57. else()
  58. option(USE_GIT "Configure use of GIT (Hooks)" ON)
  59. endif()
  60. option(USE_LIBARCHIVE "Configure use of libarchive" ON)
  61. option(USE_URIPARSER "Configure use of uriparser" OFF)
  62. option(USE_NATIVE_LIBRARIES "Search standard OS locations for thirdparty libraries" ON)
  63. option(USE_GIT_DESCRIBE "Use git describe to generate build tag" ON)
  64. option(CHECK_GIT_TAG "Require git tag to match the generated build tag" OFF)
  65. option(USE_XALAN "Configure use of xalan" OFF)
  66. option(USE_APR "Configure use of Apache Software Foundation (ASF) Portable Runtime (APR) libraries" ON)
  67. option(USE_LIBXSLT "Configure use of libxslt" ON)
  68. option(MAKE_DOCS "Create documentation at build time." OFF)
  69. option(MAKE_DOCS_ONLY "Create a base build with only docs." OFF)
  70. option(DOCS_DRUPAL "Create Drupal HTML Docs" OFF)
  71. option(DOCS_EPUB "Create EPUB Docs" OFF)
  72. option(DOCS_MOBI "Create Mobi Docs" OFF)
  73. option(DOCS_AUTO "DOCS automation" OFF)
  74. option(USE_RESOURCE "Use resource download in ECLWatch" OFF)
  75. option(GENERATE_COVERAGE_INFO "Generate coverage info for gcov" OFF)
  76. option(USE_SIGNED_CHAR "Build system with default char type is signed" OFF)
  77. option(USE_UNSIGNED_CHAR "Build system with default char type is unsigned" OFF)
  78. option(USE_MYSQL "Enable MySQL support" ON)
  79. option(USE_CASSANDRA "Enable Cassandra support" ON)
  80. option(USE_SQLITE3 "Enable SqLite3 support" ON)
  81. option(USE_PYTHON "Enable Python support" ON)
  82. option(USE_V8 "Enable V8 JavaScript support" ON)
  83. option(USE_JNI "Enable Java JNI support" ON)
  84. option(USE_RINSIDE "Enable R support" ON)
  85. option(USE_MEMCACHED "Enable Memcached support" ON)
  86. option(USE_REDIS "Enable Redis support" ON)
  87. if (APPLE OR WIN32)
  88. option(USE_TBB "Enable Threading Building Block support" OFF)
  89. else()
  90. option(USE_TBB "Enable Threading Building Block support" ON)
  91. endif()
  92. option(USE_OPTIONAL "Automatically disable requested features with missing dependencies" ON)
  93. if ( USE_PYTHON OR USE_V8 OR USE_JNI OR USE_RINSIDE OR USE_SQLITE3 OR USE_MYSQL OR USE_CASSANDRA OR USE_MEMCACHED OR USE_REDIS)
  94. set( WITH_PLUGINS ON )
  95. endif()
  96. if ( USE_XALAN AND USE_LIBXSLT )
  97. set(USE_LIBXSLT OFF)
  98. endif()
  99. if ( USE_LIBXSLT )
  100. set(USE_LIBXML2 ON)
  101. endif()
  102. if ( USE_XALAN )
  103. set(USE_XERCES ON)
  104. endif()
  105. if ( MAKE_DOCS AND CLIENTTOOLS_ONLY )
  106. set( MAKE_DOCS OFF )
  107. endif()
  108. if ( MAKE_DOCS_ONLY AND NOT CLIENTTOOLS_ONLY )
  109. set( MAKE_DOCS ON )
  110. if ( USE_DOCS_AUTO )
  111. set ( DOCS_AUTO ON)
  112. endif()
  113. endif()
  114. if ( CLIENTTOOLS_ONLY )
  115. set(PLATFORM OFF)
  116. set(DEVEL OFF)
  117. endif()
  118. option(PORTALURL "Set url to hpccsystems portal download page")
  119. if ( NOT PORTALURL )
  120. set( PORTALURL "http://hpccsystems.com/download" )
  121. endif()
  122. set(CMAKE_MODULE_PATH "${HPCC_SOURCE_DIR}/cmake_modules/")
  123. ##########################################################
  124. # common compiler/linker flags
  125. if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
  126. set ( CMAKE_BUILD_TYPE "Release" )
  127. elseif (NOT "${CMAKE_BUILD_TYPE}" MATCHES "Debug|Release|RelWithDebInfo")
  128. message (FATAL_ERROR "Unknown build type ${CMAKE_BUILD_TYPE}")
  129. endif ()
  130. message ("-- Making ${CMAKE_BUILD_TYPE} system")
  131. if (CMAKE_SIZEOF_VOID_P EQUAL 8)
  132. set ( ARCH64BIT 1 )
  133. else ()
  134. set ( ARCH64BIT 0 )
  135. endif ()
  136. message ("-- 64bit architecture is ${ARCH64BIT}")
  137. set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DDEBUG")
  138. set (CMAKE_THREAD_PREFER_PTHREAD 1)
  139. find_package(Threads)
  140. IF (NOT THREADS_FOUND)
  141. message(FATAL_ERROR "No threading support found")
  142. ENDIF()
  143. if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
  144. set (CMAKE_COMPILER_IS_CLANGXX 1)
  145. endif()
  146. if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
  147. set (CMAKE_COMPILER_IS_CLANG 1)
  148. endif()
  149. if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
  150. execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE CMAKE_C_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
  151. endif ()
  152. if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
  153. execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
  154. endif()
  155. if (CMAKE_COMPILER_IS_CLANGXX)
  156. execute_process( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string )
  157. if (${clang_full_version_string} MATCHES ".*based on LLVM ([0-9]+\\.[0-9]+).*")
  158. string (REGEX REPLACE ".*based on LLVM ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION ${clang_full_version_string})
  159. else ()
  160. string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION ${clang_full_version_string})
  161. endif()
  162. endif ()
  163. if (WIN32)
  164. # On windows, the vcproj generator generates both windows and debug build capabilities, and the release mode is appended to the directory later
  165. # This output location matches what our existing windows release scripts expect - might make sense to move out of tree sometime though
  166. set ( EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" )
  167. set ( LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" )
  168. # Workaround CMake's odd decision to default windows stack size to 10000000
  169. STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
  170. SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
  171. if (${ARCH64BIT} EQUAL 1)
  172. add_definitions(/bigobj)
  173. endif ()
  174. if ("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
  175. if (${ARCH64BIT} EQUAL 0)
  176. add_definitions(/ZI)
  177. else()
  178. add_definitions(/Zi)
  179. endif ()
  180. endif ()
  181. if ("${GIT_COMMAND}" STREQUAL "")
  182. set ( GIT_COMMAND "git.cmd" )
  183. endif ()
  184. if (USE_SIGNED_CHAR AND USE_UNSIGNED_CHAR )
  185. message (FATAL_ERROR "Can't use USE_SIGNED_CHAR and USE_UNSIGNED_CHAR together!")
  186. else()
  187. if (USE_SIGNED_CHAR)
  188. message ("Build system with signed char type.")
  189. # This is default for MSVC
  190. endif ()
  191. if (USE_UNSIGNED_CHAR )
  192. message ("Build system with unsigned char type.")
  193. add_definitions(/J)
  194. endif ()
  195. endif ()
  196. else ()
  197. if (NOT CMAKE_USE_PTHREADS_INIT)
  198. message (FATAL_ERROR "pthreads support not detected")
  199. endif ()
  200. set ( EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/bin" )
  201. set ( LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/libs" )
  202. if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
  203. message ("Using compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} ${CLANG_VERSION}")
  204. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti -fPIC -fmessage-length=0 -Wformat -Wformat-security -Wformat-nonliteral -pthread -Wuninitialized")
  205. SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic")
  206. SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -fno-inline-functions")
  207. if (CMAKE_COMPILER_IS_GNUCXX)
  208. SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -fno-default-inline")
  209. if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.2.4 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.2.4)
  210. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type")
  211. endif ()
  212. if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.4.0)
  213. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi")
  214. endif ()
  215. if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 2.95.3 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 2.95.3)
  216. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wparentheses")
  217. endif ()
  218. endif ()
  219. if (GENERATE_COVERAGE_INFO)
  220. message ("Build system with coverage.")
  221. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
  222. endif()
  223. # Handle forced default char type
  224. if (USE_SIGNED_CHAR AND USE_UNSIGNED_CHAR )
  225. message (FATAL_ERROR "Can't use USE_SIGNED_CHAR and USE_UNSIGNED_CHAR together!")
  226. else()
  227. if (USE_SIGNED_CHAR)
  228. message ("Build system with signed char type.")
  229. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char")
  230. endif ()
  231. if (USE_UNSIGNED_CHAR )
  232. message ("Build system with unsigned char type.")
  233. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funsigned-char")
  234. endif ()
  235. endif ()
  236. endif ()
  237. if (CMAKE_COMPILER_IS_CLANGXX)
  238. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=logical-op-parentheses -Werror=bool-conversions -Werror=return-type -Werror=comment")
  239. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=bitwise-op-parentheses -Werror=tautological-compare")
  240. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch-enum -Wno-format-zero-length -Wno-switch")
  241. if (CLANG_VERSION VERSION_GREATER 3.6 OR CLANG_VERSION VERSION_EQUAL 3.6)
  242. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pointer-bool-conversion")
  243. endif()
  244. endif()
  245. # All of these are defined in platform.h too, but need to be defned before any system header is included
  246. ADD_DEFINITIONS (-D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -D__USE_LARGEFILE64=1 -D__USE_FILE_OFFSET64=1)
  247. if ("${GIT_COMMAND}" STREQUAL "")
  248. set ( GIT_COMMAND "git" )
  249. endif ()
  250. endif ()
  251. macro(HPCC_ADD_EXECUTABLE target)
  252. add_executable(${target} ${ARGN})
  253. endmacro(HPCC_ADD_EXECUTABLE target)
  254. macro(HPCC_ADD_LIBRARY target)
  255. add_library(${target} ${ARGN})
  256. endmacro(HPCC_ADD_LIBRARY target)
  257. # This Macro is provided as Public domain from
  258. # http://www.cmake.org/Wiki/CMakeMacroParseArguments
  259. MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
  260. SET(DEFAULT_ARGS)
  261. FOREACH(arg_name ${arg_names})
  262. SET(${prefix}_${arg_name})
  263. ENDFOREACH(arg_name)
  264. FOREACH(option ${option_names})
  265. SET(${prefix}_${option} FALSE)
  266. ENDFOREACH(option)
  267. SET(current_arg_name DEFAULT_ARGS)
  268. SET(current_arg_list)
  269. FOREACH(arg ${ARGN})
  270. SET(larg_names ${arg_names})
  271. LIST(FIND larg_names "${arg}" is_arg_name)
  272. IF (is_arg_name GREATER -1)
  273. SET(${prefix}_${current_arg_name} ${current_arg_list})
  274. SET(current_arg_name ${arg})
  275. SET(current_arg_list)
  276. ELSE (is_arg_name GREATER -1)
  277. SET(loption_names ${option_names})
  278. LIST(FIND loption_names "${arg}" is_option)
  279. IF (is_option GREATER -1)
  280. SET(${prefix}_${arg} TRUE)
  281. ELSE (is_option GREATER -1)
  282. SET(current_arg_list ${current_arg_list} ${arg})
  283. ENDIF (is_option GREATER -1)
  284. ENDIF (is_arg_name GREATER -1)
  285. ENDFOREACH(arg)
  286. SET(${prefix}_${current_arg_name} ${current_arg_list})
  287. ENDMACRO(PARSE_ARGUMENTS)
  288. # This macro allows for disabling a directory based on the value of a variable passed to the macro.
  289. #
  290. # ex. HPCC_ADD_SUBDIRECORY(roxie ${CLIENTTOOLS_ONLY})
  291. #
  292. # This call will disable the roxie dir if -DCLIENTTOOLS_ONLY=ON is set at config time.
  293. #
  294. macro(HPCC_ADD_SUBDIRECTORY)
  295. set(adddir OFF)
  296. PARSE_ARGUMENTS(_HPCC_SUB "" "" ${ARGN})
  297. LIST(GET _HPCC_SUB_DEFAULT_ARGS 0 subdir)
  298. set(flags ${_HPCC_SUB_DEFAULT_ARGS})
  299. LIST(REMOVE_AT flags 0)
  300. LIST(LENGTH flags length)
  301. if(NOT length)
  302. set(adddir ON)
  303. else()
  304. foreach(f ${flags})
  305. if(${f})
  306. set(adddir ON)
  307. endif()
  308. endforeach()
  309. endif()
  310. if ( adddir )
  311. add_subdirectory(${subdir})
  312. endif()
  313. endmacro(HPCC_ADD_SUBDIRECTORY)
  314. set ( SCM_GENERATED_DIR ${CMAKE_BINARY_DIR}/generated )
  315. ###############################################################
  316. # Macro for Logging Plugin build in CMake
  317. macro(LOG_PLUGIN)
  318. PARSE_ARGUMENTS(pLOG
  319. "OPTION;MDEPS"
  320. ""
  321. ${ARGN}
  322. )
  323. LIST(GET pLOG_DEFAULT_ARGS 0 PLUGIN_NAME)
  324. if ( ${pLOG_OPTION} )
  325. message(STATUS "Building Plugin: ${PLUGIN_NAME}" )
  326. else()
  327. message("---- WARNING -- Not Building Plugin: ${PLUGIN_NAME}")
  328. foreach (dep ${pLOG_MDEPS})
  329. MESSAGE("---- WARNING -- Missing dependency: ${dep}")
  330. endforeach()
  331. if (NOT USE_OPTIONAL)
  332. message(FATAL_ERROR "Optional dependencies missing and USE_OPTIONAL not set")
  333. endif()
  334. endif()
  335. endmacro()
  336. ###############################################################
  337. # Macro for adding an optional plugin to the CMake build.
  338. macro(ADD_PLUGIN)
  339. PARSE_ARGUMENTS(PLUGIN
  340. "PACKAGES;OPTION;MINVERSION;MAXVERSION"
  341. ""
  342. ${ARGN}
  343. )
  344. LIST(GET PLUGIN_DEFAULT_ARGS 0 PLUGIN_NAME)
  345. string(TOUPPER ${PLUGIN_NAME} name)
  346. set(ALL_PLUGINS_FOUND 1)
  347. set(PLUGIN_MDEPS ${PLUGIN_NAME}_mdeps)
  348. set(${PLUGIN_MDEPS} "")
  349. FOREACH(package ${PLUGIN_PACKAGES})
  350. set(findvar ${package}_FOUND)
  351. string(TOUPPER ${findvar} PACKAGE_FOUND)
  352. if ("${PLUGIN_MINVERSION}" STREQUAL "")
  353. find_package(${package})
  354. else()
  355. set(findvar ${package}_VERSION_STRING)
  356. string(TOUPPER ${findvar} PACKAGE_VERSION_STRING)
  357. find_package(${package} ${PLUGIN_MINVERSION} )
  358. if ("${${PACKAGE_VERSION_STRING}}" VERSION_GREATER "${PLUGIN_MAXVERSION}")
  359. set(${ALL_PLUGINS_FOUND} 0)
  360. endif()
  361. endif()
  362. if (NOT ${PACKAGE_FOUND})
  363. set(ALL_PLUGINS_FOUND 0)
  364. set(${PLUGIN_MDEPS} ${${PLUGIN_MDEPS}} ${package})
  365. endif()
  366. ENDFOREACH()
  367. option(${PLUGIN_OPTION} "Turn on optional plugin based on availability of dependencies" ${ALL_PLUGINS_FOUND})
  368. LOG_PLUGIN(${PLUGIN_NAME} OPTION ${PLUGIN_OPTION} MDEPS ${${PLUGIN_MDEPS}})
  369. if(${ALL_PLUGINS_FOUND})
  370. set(bPLUGINS ${bPLUGINS} ${PLUGIN_NAME})
  371. else()
  372. set(nbPLUGINS ${nbPLUGINS} ${PLUGIN_NAME})
  373. endif()
  374. endmacro()
  375. ##################################################################
  376. # Build tag generation
  377. set(projname ${HPCC_PROJECT})
  378. set(majorver ${HPCC_MAJOR})
  379. set(minorver ${HPCC_MINOR})
  380. set(point ${HPCC_POINT})
  381. if ( "${HPCC_MATURITY}" STREQUAL "release" )
  382. set(stagever "${HPCC_SEQUENCE}")
  383. else()
  384. set(stagever "${HPCC_MATURITY}${HPCC_SEQUENCE}")
  385. endif()
  386. set(version ${majorver}.${minorver}.${point})
  387. IF ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  388. set( stagever "${stagever}Debug" )
  389. ENDIF ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  390. ###########################################################################
  391. if (USE_OPTIONAL)
  392. message ("-- USE_OPTIONAL set - missing dependencies for optional features will automatically disable them")
  393. endif()
  394. if (NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
  395. message ("-- Using externals directory at ${EXTERNALS_DIRECTORY}")
  396. endif()
  397. IF ( NOT MAKE_DOCS_ONLY )
  398. IF ("${EXTERNALS_DIRECTORY}" STREQUAL "")
  399. SET(bisoncmd "bison")
  400. SET(flexcmd "flex")
  401. ELSE()
  402. IF (WIN32)
  403. SET(bisoncmdprefix "call")
  404. SET(flexcmdprefix "call")
  405. SET(bisoncmd "${EXTERNALS_DIRECTORY}\\bison\\bison.bat")
  406. SET(flexcmd "${EXTERNALS_DIRECTORY}\\bison\\flex.bat")
  407. ELSE ()
  408. SET(bisoncmd "${EXTERNALS_DIRECTORY}/bison/bison")
  409. SET(flexcmd "${EXTERNALS_DIRECTORY}/bison/flex")
  410. ENDIF()
  411. ENDIF()
  412. IF ("${BISON_VERSION}" STREQUAL "")
  413. IF (WIN32)
  414. # cmake bug workaround - it converts path separators fine in add_custom_command but not here
  415. STRING(REPLACE "/" "\\" BISON_exename "${bisoncmd}")
  416. ELSE()
  417. SET(BISON_exename "${bisoncmd}")
  418. ENDIF()
  419. EXECUTE_PROCESS(COMMAND ${BISON_exename} --version
  420. OUTPUT_VARIABLE BISON_version_output
  421. ERROR_VARIABLE BISON_version_error
  422. RESULT_VARIABLE BISON_version_result
  423. OUTPUT_STRIP_TRAILING_WHITESPACE)
  424. STRING(REGEX REPLACE "^[^0-9]*([0-9.]+).*" "\\1" BISON_VERSION "${BISON_version_output}")
  425. ENDIF()
  426. IF ("${FLEX_VERSION}" STREQUAL "")
  427. IF (WIN32)
  428. # cmake bug workaround - it converts path separators fine in add_custom_command but not here
  429. STRING(REPLACE "/" "\\" FLEX_exename "${flexcmd}")
  430. ELSE()
  431. SET(FLEX_exename "${flexcmd}")
  432. ENDIF()
  433. EXECUTE_PROCESS(COMMAND ${FLEX_exename} --version
  434. OUTPUT_VARIABLE FLEX_version_output
  435. ERROR_VARIABLE FLEX_version_error
  436. RESULT_VARIABLE FLEX_version_result
  437. OUTPUT_STRIP_TRAILING_WHITESPACE)
  438. STRING(REGEX REPLACE "^[^0-9]*([0-9.]+).*" "\\1" FLEX_VERSION "${FLEX_version_output}")
  439. ENDIF()
  440. IF ("${BISON_VERSION}" VERSION_LESS "2.4.1")
  441. MESSAGE(FATAL_ERROR "You need bison version 2.4.1 or later to build this project (version ${BISON_VERSION} detected)")
  442. ENDIF()
  443. IF ("${FLEX_VERSION}" VERSION_LESS "2.5.35")
  444. MESSAGE(FATAL_ERROR "You need flex version 2.5.35 or later to build this project (version ${FLEX_VERSION} detected)")
  445. ENDIF()
  446. IF (CMAKE_COMPILER_IS_GNUCXX)
  447. IF ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.1.1")
  448. MESSAGE(FATAL_ERROR "You need Gnu c++ version 4.1.1 or later to build this project (version ${CMAKE_CXX_COMPILER_VERSION} detected)")
  449. ENDIF()
  450. ENDIF()
  451. ENDIF()
  452. ###########################################################################
  453. # External library setup - some can be optionally selected based on USE_xxx flags, some are required
  454. IF (MAKE_DOCS)
  455. find_package(XSLTPROC)
  456. IF (XSLTPROC_FOUND)
  457. add_definitions (-D_USE_XSLTPROC)
  458. ELSE()
  459. message(FATAL_ERROR "XSLTPROC requested but package not found")
  460. ENDIF()
  461. find_package(FOP)
  462. IF (FOP_FOUND)
  463. add_definitions (-D_USE_FOP)
  464. ELSE()
  465. message(FATAL_ERROR "FOP requested but package not found")
  466. ENDIF()
  467. if (DOCS_AUTO)
  468. if ("${CONFIGURATOR_DIRECTORY}" STREQUAL "")
  469. set(CONFIGURATOR_DIRECTORY ${HPCC_SOURCE_DIR}/../configurator)
  470. endif()
  471. endif()
  472. ENDIF(MAKE_DOCS)
  473. IF ( NOT MAKE_DOCS_ONLY )
  474. IF (USE_BINUTILS AND NOT WIN32 AND NOT APPLE)
  475. find_package(BINUTILS)
  476. IF (BINUTILS_FOUND)
  477. add_definitions (-D_USE_BINUTILS)
  478. ELSE()
  479. message(FATAL_ERROR "BINUTILS requested but package not found")
  480. ENDIF()
  481. ENDIF()
  482. IF (USE_OPENLDAP)
  483. find_package(OPENLDAP)
  484. IF (OPENLDAP_FOUND)
  485. add_definitions (-D_USE_OPENLDAP)
  486. ELSE()
  487. message(FATAL_ERROR "OPENLDAP requested but package not found")
  488. ENDIF()
  489. ELSE()
  490. add_definitions (-D_NO_LDAP)
  491. ENDIF(USE_OPENLDAP)
  492. IF (USE_CPPUNIT)
  493. find_package(CPPUNIT)
  494. IF (CPPUNIT_FOUND)
  495. add_definitions (-D_USE_CPPUNIT)
  496. include_directories(${CPPUNIT_INCLUDE_DIR})
  497. ELSE()
  498. message(FATAL_ERROR "CPPUNIT requested but package not found")
  499. ENDIF()
  500. ELSE()
  501. SET(CPPUNIT_INCLUDE_DIR "")
  502. SET(CPPUNIT_LIBRARIES "")
  503. ENDIF(USE_CPPUNIT)
  504. IF (USE_ICU)
  505. find_package(ICU)
  506. IF (ICU_FOUND)
  507. add_definitions (-D_USE_ICU)
  508. include_directories(${ICU_INCLUDE_DIR})
  509. ELSE()
  510. message(FATAL_ERROR "ICU requested but package not found")
  511. ENDIF()
  512. ENDIF(USE_ICU)
  513. if(USE_XALAN)
  514. find_package(XALAN)
  515. if (XALAN_FOUND)
  516. add_definitions (-D_USE_XALAN)
  517. else()
  518. message(FATAL_ERROR "XALAN requested but package not found")
  519. endif()
  520. endif(USE_XALAN)
  521. if(USE_LIBXSLT)
  522. find_package(LIBXSLT)
  523. if (LIBXSLT_FOUND)
  524. add_definitions (-D_USE_LIBXSLT)
  525. else()
  526. message(FATAL_ERROR "LIBXSLT requested but package not found")
  527. endif()
  528. endif(USE_LIBXSLT)
  529. if(USE_XERCES)
  530. find_package(XERCES)
  531. if (XERCES_FOUND)
  532. add_definitions (-D_USE_XERCES)
  533. else()
  534. message(FATAL_ERROR "XERCES requested but package not found")
  535. endif()
  536. endif(USE_XERCES)
  537. if(USE_LIBXML2)
  538. find_package(LIBXML2)
  539. if (LIBXML2_FOUND)
  540. add_definitions (-D_USE_LIBXML2)
  541. else()
  542. message(FATAL_ERROR "LIBXML2 requested but package not found")
  543. endif()
  544. endif(USE_LIBXML2)
  545. if(USE_ZLIB)
  546. find_package(ZLIB)
  547. if (ZLIB_FOUND)
  548. add_definitions (-D_USE_ZLIB)
  549. else()
  550. message(FATAL_ERROR "ZLIB requested but package not found")
  551. endif()
  552. endif(USE_ZLIB)
  553. if(USE_LIBARCHIVE)
  554. if (WIN32)
  555. if(NOT USE_ZLIB)
  556. message(FATAL ERROR "LIBARCHIVE requires ZLIB")
  557. endif(NOT USE_ZLIB)
  558. find_package(BZip2)
  559. if (BZIP2_FOUND)
  560. add_definitions (-D_USE_BZIP2)
  561. else()
  562. message(FATAL_ERROR "LIBARCHIVE requires BZIP2 but package not found")
  563. endif()
  564. endif (WIN32)
  565. find_package(LIBARCHIVE)
  566. if (LIBARCHIVE_FOUND)
  567. add_definitions (-D_USE_LIBARCHIVE)
  568. else()
  569. message(FATAL_ERROR "LIBARCHIVE requested but package not found")
  570. endif()
  571. endif(USE_LIBARCHIVE)
  572. if(USE_URIPARSER)
  573. find_package(Uriparser)
  574. if (URIPARSER_FOUND)
  575. add_definitions (-D_USE_URIPARSER)
  576. else()
  577. message(FATAL_ERROR "URIPARSER requested but package not found")
  578. endif()
  579. endif(USE_URIPARSER)
  580. if(USE_BOOST_REGEX)
  581. find_package(BOOST_REGEX)
  582. if (BOOST_REGEX_FOUND)
  583. add_definitions (-D_USE_BOOST_REGEX)
  584. else()
  585. message(FATAL_ERROR "BOOST_REGEX requested but package not found")
  586. endif()
  587. endif(USE_BOOST_REGEX)
  588. if(USE_OPENSSL)
  589. find_package(OPENSSL)
  590. if (OPENSSL_FOUND)
  591. add_definitions (-D_USE_OPENSSL)
  592. include_directories(${OPENSSL_INCLUDE_DIR})
  593. link_directories(${OPENSSL_LIBRARY_DIR})
  594. else()
  595. message(FATAL_ERROR "OPENSSL requested but package not found")
  596. endif()
  597. endif(USE_OPENSSL)
  598. if(USE_MYSQL_REPOSITORY)
  599. find_package(MYSQL)
  600. if (MYSQL_FOUND)
  601. add_definitions (-D_USE_MYSQL_REPOSITORY)
  602. else()
  603. message(FATAL_ERROR "MYSQL requested but package not found")
  604. endif()
  605. else()
  606. add_definitions (-D_NO_MYSQL_REPOSITORY)
  607. endif(USE_MYSQL_REPOSITORY)
  608. if(USE_APR)
  609. find_package(APR)
  610. if (APR_FOUND)
  611. add_definitions (-D_USE_APR)
  612. include_directories(${APR_INCLUDE_DIR})
  613. link_directories(${APR_LIBRARY_DIR})
  614. else()
  615. message(FATAL_ERROR "APR requested but package not found")
  616. endif()
  617. if (APRUTIL_FOUND)
  618. include_directories(${APRUTIL_INCLUDE_DIR})
  619. link_directories(${APRUTIL_LIBRARY_DIR})
  620. else()
  621. message(FATAL_ERROR "APRUTIL requested but package not found")
  622. endif()
  623. else()
  624. add_definitions (-D_NO_APR)
  625. endif(USE_APR)
  626. if(USE_TBB)
  627. find_package(TBB)
  628. if (TBB_FOUND)
  629. add_definitions (-D_USE_TBB)
  630. else()
  631. message(FATAL_ERROR "TBB requested but package not found")
  632. endif()
  633. else()
  634. set(TBB_INCLUDE_DIR "")
  635. endif(USE_TBB)
  636. ENDIF()
  637. ###########################################################################
  638. ###
  639. ## The following sets the install directories and names.
  640. ###
  641. if ( PLATFORM )
  642. set ( CMAKE_INSTALL_PREFIX "${PREFIX}/${DIR_NAME}" )
  643. else ( PLATFORM )
  644. set ( CMAKE_INSTALL_PREFIX "${PREFIX}/${DIR_NAME}/${version}/clienttools" )
  645. endif ( PLATFORM )
  646. set (CMAKE_SKIP_BUILD_RPATH FALSE)
  647. set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  648. set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
  649. set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  650. if (APPLE)
  651. # used to locate libraries when compiling ECL
  652. set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
  653. endif()
  654. MACRO (FETCH_GIT_TAG workdir edition result)
  655. execute_process(COMMAND "${GIT_COMMAND}" describe --tags --dirty --abbrev=6 --match ${edition}*
  656. WORKING_DIRECTORY "${workdir}"
  657. OUTPUT_VARIABLE ${result}
  658. ERROR_QUIET
  659. OUTPUT_STRIP_TRAILING_WHITESPACE)
  660. if ("${${result}}" STREQUAL "")
  661. execute_process(COMMAND "${GIT_COMMAND}" describe --always --tags --all --abbrev=6 --dirty --long
  662. WORKING_DIRECTORY "${workdir}"
  663. OUTPUT_VARIABLE ${result}
  664. ERROR_QUIET
  665. OUTPUT_STRIP_TRAILING_WHITESPACE)
  666. endif()
  667. ENDMACRO()
  668. endif ("${COMMONSETUP_DONE}" STREQUAL "")