commonSetup.cmake 25 KB

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