commonSetup.cmake 26 KB

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