commonSetup.cmake 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  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. endif ()
  185. if (GENERATE_COVERAGE_INFO)
  186. message ("Build system with coverage.")
  187. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
  188. endif()
  189. # Handle forced default char type
  190. if (USE_SIGNED_CHAR AND USE_UNSIGNED_CHAR )
  191. message (FATAL_ERROR "Can't use USE_SIGNED_CHAR and USE_UNSIGNED_CHAR together!")
  192. else()
  193. if (USE_SIGNED_CHAR)
  194. message ("Build system with signed char type.")
  195. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char")
  196. endif ()
  197. if (USE_UNSIGNED_CHAR )
  198. message ("Build system with unsigned char type.")
  199. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funsigned-char")
  200. endif ()
  201. endif ()
  202. endif ()
  203. if (CMAKE_COMPILER_IS_CLANGXX)
  204. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=logical-op-parentheses -Werror=bool-conversions -Werror=return-type -Werror=comment")
  205. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=bitwise-op-parentheses -Werror=tautological-compare")
  206. SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch-enum -Wno-format-zero-length")
  207. endif()
  208. # All of these are defined in platform.h too, but need to be defned before any system header is included
  209. ADD_DEFINITIONS (-D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -D__USE_LARGEFILE64=1 -D__USE_FILE_OFFSET64=1)
  210. if ("${GIT_COMMAND}" STREQUAL "")
  211. set ( GIT_COMMAND "git" )
  212. endif ()
  213. endif ()
  214. macro(HPCC_ADD_EXECUTABLE target)
  215. add_executable(${target} ${ARGN})
  216. endmacro(HPCC_ADD_EXECUTABLE target)
  217. macro(HPCC_ADD_LIBRARY target)
  218. add_library(${target} ${ARGN})
  219. endmacro(HPCC_ADD_LIBRARY target)
  220. # This Macro is provided as Public domain from
  221. # http://www.cmake.org/Wiki/CMakeMacroParseArguments
  222. MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
  223. SET(DEFAULT_ARGS)
  224. FOREACH(arg_name ${arg_names})
  225. SET(${prefix}_${arg_name})
  226. ENDFOREACH(arg_name)
  227. FOREACH(option ${option_names})
  228. SET(${prefix}_${option} FALSE)
  229. ENDFOREACH(option)
  230. SET(current_arg_name DEFAULT_ARGS)
  231. SET(current_arg_list)
  232. FOREACH(arg ${ARGN})
  233. SET(larg_names ${arg_names})
  234. LIST(FIND larg_names "${arg}" is_arg_name)
  235. IF (is_arg_name GREATER -1)
  236. SET(${prefix}_${current_arg_name} ${current_arg_list})
  237. SET(current_arg_name ${arg})
  238. SET(current_arg_list)
  239. ELSE (is_arg_name GREATER -1)
  240. SET(loption_names ${option_names})
  241. LIST(FIND loption_names "${arg}" is_option)
  242. IF (is_option GREATER -1)
  243. SET(${prefix}_${arg} TRUE)
  244. ELSE (is_option GREATER -1)
  245. SET(current_arg_list ${current_arg_list} ${arg})
  246. ENDIF (is_option GREATER -1)
  247. ENDIF (is_arg_name GREATER -1)
  248. ENDFOREACH(arg)
  249. SET(${prefix}_${current_arg_name} ${current_arg_list})
  250. ENDMACRO(PARSE_ARGUMENTS)
  251. # This macro allows for disabling a directory based on the value of a variable passed to the macro.
  252. #
  253. # ex. HPCC_ADD_SUBDIRECORY(roxie ${CLIENTTOOLS_ONLY})
  254. #
  255. # This call will disable the roxie dir if -DCLIENTTOOLS_ONLY=ON is set at config time.
  256. #
  257. macro(HPCC_ADD_SUBDIRECTORY)
  258. set(adddir OFF)
  259. PARSE_ARGUMENTS(_HPCC_SUB "" "" ${ARGN})
  260. LIST(GET _HPCC_SUB_DEFAULT_ARGS 0 subdir)
  261. set(flags ${_HPCC_SUB_DEFAULT_ARGS})
  262. LIST(REMOVE_AT flags 0)
  263. LIST(LENGTH flags length)
  264. if(NOT length)
  265. set(adddir ON)
  266. else()
  267. foreach(f ${flags})
  268. if(${f})
  269. set(adddir ON)
  270. endif()
  271. endforeach()
  272. endif()
  273. if ( adddir )
  274. add_subdirectory(${subdir})
  275. endif()
  276. endmacro(HPCC_ADD_SUBDIRECTORY)
  277. set ( SCM_GENERATED_DIR ${CMAKE_BINARY_DIR}/generated )
  278. include_directories (${SCM_GENERATED_DIR})
  279. ###############################################################
  280. # Macro for Logging Plugin build in CMake
  281. macro(LOG_PLUGIN)
  282. PARSE_ARGUMENTS(pLOG
  283. "OPTION;MDEPS"
  284. ""
  285. ${ARGN}
  286. )
  287. LIST(GET pLOG_DEFAULT_ARGS 0 PLUGIN_NAME)
  288. if ( ${pLOG_OPTION} )
  289. message(STATUS "Building Plugin: ${PLUGIN_NAME}" )
  290. else()
  291. message("---- WARNING -- Not Building Plugin: ${PLUGIN_NAME}")
  292. foreach (dep ${pLOG_MDEPS})
  293. MESSAGE("---- WARNING -- Missing dependency: ${dep}")
  294. endforeach()
  295. if (NOT USE_OPTIONAL)
  296. message(FATAL_ERROR "Optional dependencies missing and USE_OPTIONAL not set")
  297. endif()
  298. endif()
  299. endmacro()
  300. ###############################################################
  301. # Macro for adding an optional plugin to the CMake build.
  302. macro(ADD_PLUGIN)
  303. PARSE_ARGUMENTS(PLUGIN
  304. "PACKAGES;OPTION;MINVERSION;MAXVERSION"
  305. ""
  306. ${ARGN}
  307. )
  308. LIST(GET PLUGIN_DEFAULT_ARGS 0 PLUGIN_NAME)
  309. string(TOUPPER ${PLUGIN_NAME} name)
  310. set(PLUGIN_FOUND 0)
  311. set(PLUGIN_MDEPS ${PLUGIN_NAME}_mdeps)
  312. set(${PLUGIN_MDEPS} "")
  313. FOREACH(package ${PLUGIN_PACKAGES})
  314. set(findvar ${package}_FOUND)
  315. string(TOUPPER ${findvar} PACKAGE_FOUND)
  316. if ("${PLUGIN_MINVERSION}" STREQUAL "")
  317. find_package(${package})
  318. else()
  319. set(findvar ${package}_VERSION_STRING)
  320. string(TOUPPER ${findvar} PACKAGE_VERSION_STRING)
  321. find_package(${package} ${PLUGIN_MINVERSION} )
  322. if ("${${PACKAGE_VERSION_STRING}}" VERSION_GREATER "${PLUGIN_MAXVERSION}")
  323. set(${PLUGIN_FOUND} 0)
  324. endif()
  325. endif()
  326. if (${PACKAGE_FOUND})
  327. set(PLUGIN_FOUND 1)
  328. else()
  329. set(PLUGIN_FOUND 0)
  330. set(${PLUGIN_MDEPS} ${${PLUGIN_MDEPS}} ${package})
  331. endif()
  332. ENDFOREACH()
  333. option(${PLUGIN_OPTION} "Turn on optional plugin based on availability of dependencies" ${PLUGIN_FOUND})
  334. LOG_PLUGIN(${PLUGIN_NAME} OPTION ${PLUGIN_OPTION} MDEPS ${${PLUGIN_MDEPS}})
  335. if(${PLUGIN_FOUND})
  336. set(bPLUGINS ${bPLUGINS} ${PLUGIN_NAME})
  337. else()
  338. set(nbPLUGINS ${nbPLUGINS} ${PLUGIN_NAME})
  339. endif()
  340. endmacro()
  341. ##################################################################
  342. # Build tag generation
  343. set(projname ${HPCC_PROJECT})
  344. set(majorver ${HPCC_MAJOR})
  345. set(minorver ${HPCC_MINOR})
  346. set(point ${HPCC_POINT})
  347. if ( "${HPCC_MATURITY}" STREQUAL "release" )
  348. set(stagever "${HPCC_SEQUENCE}")
  349. else()
  350. set(stagever "${HPCC_MATURITY}${HPCC_SEQUENCE}")
  351. endif()
  352. set(version ${majorver}.${minorver}.${point})
  353. IF ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  354. set( stagever "${stagever}Debug" )
  355. ENDIF ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  356. ###########################################################################
  357. if (USE_OPTIONAL)
  358. message ("-- USE_OPTIONAL set - missing dependencies for optional features will automatically disable them")
  359. endif()
  360. if (NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
  361. message ("-- Using externals directory at ${EXTERNALS_DIRECTORY}")
  362. endif()
  363. IF ( NOT MAKE_DOCS_ONLY )
  364. IF ("${EXTERNALS_DIRECTORY}" STREQUAL "")
  365. SET(bisoncmd "bison")
  366. SET(flexcmd "flex")
  367. ELSE()
  368. IF (WIN32)
  369. SET(bisoncmdprefix "call")
  370. SET(flexcmdprefix "call")
  371. SET(bisoncmd "${EXTERNALS_DIRECTORY}\\bison\\bison.bat")
  372. SET(flexcmd "${EXTERNALS_DIRECTORY}\\bison\\flex.bat")
  373. ELSE ()
  374. SET(bisoncmd "${EXTERNALS_DIRECTORY}/bison/bison")
  375. SET(flexcmd "${EXTERNALS_DIRECTORY}/bison/flex")
  376. ENDIF()
  377. ENDIF()
  378. IF ("${BISON_VERSION}" STREQUAL "")
  379. IF (WIN32)
  380. # cmake bug workaround - it converts path separators fine in add_custom_command but not here
  381. STRING(REPLACE "/" "\\" BISON_exename "${bisoncmd}")
  382. ELSE()
  383. SET(BISON_exename "${bisoncmd}")
  384. ENDIF()
  385. EXECUTE_PROCESS(COMMAND ${BISON_exename} --version
  386. OUTPUT_VARIABLE BISON_version_output
  387. ERROR_VARIABLE BISON_version_error
  388. RESULT_VARIABLE BISON_version_result
  389. OUTPUT_STRIP_TRAILING_WHITESPACE)
  390. STRING(REGEX REPLACE "^[^0-9]*([0-9.]+).*" "\\1" BISON_VERSION "${BISON_version_output}")
  391. ENDIF()
  392. IF ("${FLEX_VERSION}" STREQUAL "")
  393. IF (WIN32)
  394. # cmake bug workaround - it converts path separators fine in add_custom_command but not here
  395. STRING(REPLACE "/" "\\" FLEX_exename "${flexcmd}")
  396. ELSE()
  397. SET(FLEX_exename "${flexcmd}")
  398. ENDIF()
  399. EXECUTE_PROCESS(COMMAND ${FLEX_exename} --version
  400. OUTPUT_VARIABLE FLEX_version_output
  401. ERROR_VARIABLE FLEX_version_error
  402. RESULT_VARIABLE FLEX_version_result
  403. OUTPUT_STRIP_TRAILING_WHITESPACE)
  404. STRING(REGEX REPLACE "^[^0-9]*([0-9.]+).*" "\\1" FLEX_VERSION "${FLEX_version_output}")
  405. ENDIF()
  406. IF ("${BISON_VERSION}" VERSION_LESS "2.4.1")
  407. MESSAGE(FATAL_ERROR "You need bison version 2.4.1 or later to build this project (version ${BISON_VERSION} detected)")
  408. ENDIF()
  409. IF ("${FLEX_VERSION}" VERSION_LESS "2.5.35")
  410. MESSAGE(FATAL_ERROR "You need flex version 2.5.35 or later to build this project (version ${FLEX_VERSION} detected)")
  411. ENDIF()
  412. IF (CMAKE_COMPILER_IS_GNUCXX)
  413. IF ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.1.1")
  414. MESSAGE(FATAL_ERROR "You need Gnu c++ version 4.1.1 or later to build this project (version ${CMAKE_CXX_COMPILER_VERSION} detected)")
  415. ENDIF()
  416. ENDIF()
  417. ENDIF()
  418. ###########################################################################
  419. # External library setup - some can be optionally selected based on USE_xxx flags, some are required
  420. IF (MAKE_DOCS)
  421. find_package(XSLTPROC)
  422. IF (XSLTPROC_FOUND)
  423. add_definitions (-D_USE_XSLTPROC)
  424. ELSE()
  425. message(FATAL_ERROR "XSLTPROC requested but package not found")
  426. ENDIF()
  427. find_package(FOP)
  428. IF (FOP_FOUND)
  429. add_definitions (-D_USE_FOP)
  430. ELSE()
  431. message(FATAL_ERROR "FOP requested but package not found")
  432. ENDIF()
  433. ENDIF(MAKE_DOCS)
  434. IF ( NOT MAKE_DOCS_ONLY )
  435. IF (USE_BINUTILS AND NOT WIN32)
  436. find_package(BINUTILS)
  437. IF (BINUTILS_FOUND)
  438. add_definitions (-D_USE_BINUTILS)
  439. ELSE()
  440. message(FATAL_ERROR "BINUTILS requested but package not found")
  441. ENDIF()
  442. ENDIF()
  443. IF (USE_OPENLDAP)
  444. find_package(OPENLDAP)
  445. IF (OPENLDAP_FOUND)
  446. add_definitions (-D_USE_OPENLDAP)
  447. ELSE()
  448. message(FATAL_ERROR "OPENLDAP requested but package not found")
  449. ENDIF()
  450. ELSE()
  451. add_definitions (-D_NO_LDAP)
  452. ENDIF(USE_OPENLDAP)
  453. IF (USE_CPPUNIT)
  454. find_package(CPPUNIT)
  455. IF (CPPUNIT_FOUND)
  456. add_definitions (-D_USE_CPPUNIT)
  457. include_directories(${CPPUNIT_INCLUDE_DIR})
  458. ELSE()
  459. message(FATAL_ERROR "CPPUNIT requested but package not found")
  460. ENDIF()
  461. ENDIF(USE_CPPUNIT)
  462. IF (USE_ICU)
  463. find_package(ICU)
  464. IF (ICU_FOUND)
  465. add_definitions (-D_USE_ICU)
  466. include_directories(${ICU_INCLUDE_DIR})
  467. ELSE()
  468. message(FATAL_ERROR "ICU requested but package not found")
  469. ENDIF()
  470. ENDIF(USE_ICU)
  471. if(USE_XALAN)
  472. find_package(XALAN)
  473. if (XALAN_FOUND)
  474. add_definitions (-D_USE_XALAN)
  475. else()
  476. message(FATAL_ERROR "XALAN requested but package not found")
  477. endif()
  478. endif(USE_XALAN)
  479. if(USE_LIBXSLT)
  480. find_package(LIBXSLT)
  481. if (LIBXSLT_FOUND)
  482. add_definitions (-D_USE_LIBSLT)
  483. else()
  484. message(FATAL_ERROR "LIBXSLT requested but package not found")
  485. endif()
  486. endif(USE_LIBXSLT)
  487. if(USE_XERCES)
  488. find_package(XERCES)
  489. if (XERCES_FOUND)
  490. add_definitions (-D_USE_XERCES)
  491. else()
  492. message(FATAL_ERROR "XERCES requested but package not found")
  493. endif()
  494. endif(USE_XERCES)
  495. if(USE_LIBXML2)
  496. find_package(LIBXML2)
  497. if (LIBXML2_FOUND)
  498. add_definitions (-D_USE_LIBXML2)
  499. else()
  500. message(FATAL_ERROR "LIBXML2 requested but package not found")
  501. endif()
  502. endif(USE_LIBXML2)
  503. if(USE_ZLIB)
  504. find_package(ZLIB)
  505. if (ZLIB_FOUND)
  506. add_definitions (-D_USE_ZLIB)
  507. else()
  508. message(FATAL_ERROR "ZLIB requested but package not found")
  509. endif()
  510. endif(USE_ZLIB)
  511. if(USE_LIBARCHIVE)
  512. if (WIN32)
  513. if(NOT USE_ZLIB)
  514. message(FATAL ERROR "LIBARCHIVE requires ZLIB")
  515. endif(NOT USE_ZLIB)
  516. find_package(BZip2)
  517. if (BZIP2_FOUND)
  518. add_definitions (-D_USE_BZIP2)
  519. else()
  520. message(FATAL_ERROR "LIBARCHIVE requires BZIP2 but package not found")
  521. endif()
  522. endif (WIN32)
  523. find_package(LIBARCHIVE)
  524. if (LIBARCHIVE_FOUND)
  525. add_definitions (-D_USE_LIBARCHIVE)
  526. else()
  527. message(FATAL_ERROR "LIBARCHIVE requested but package not found")
  528. endif()
  529. endif(USE_LIBARCHIVE)
  530. if(USE_URIPARSER)
  531. find_package(Uriparser)
  532. if (URIPARSER_FOUND)
  533. add_definitions (-D_USE_URIPARSER)
  534. else()
  535. message(FATAL_ERROR "URIPARSER requested but package not found")
  536. endif()
  537. endif(USE_URIPARSER)
  538. if(USE_BOOST_REGEX)
  539. find_package(BOOST_REGEX)
  540. if (BOOST_REGEX_FOUND)
  541. add_definitions (-D_USE_BOOST_REGEX)
  542. else()
  543. message(FATAL_ERROR "BOOST_REGEX requested but package not found")
  544. endif()
  545. endif(USE_BOOST_REGEX)
  546. if(USE_OPENSSL)
  547. find_package(OPENSSL)
  548. if (OPENSSL_FOUND)
  549. add_definitions (-D_USE_OPENSSL)
  550. include_directories(${OPENSSL_INCLUDE_DIR})
  551. link_directories(${OPENSSL_LIBRARY_DIR})
  552. else()
  553. message(FATAL_ERROR "OPENSSL requested but package not found")
  554. endif()
  555. endif(USE_OPENSSL)
  556. if(USE_MYSQL_REPOSITORY)
  557. find_package(MYSQL)
  558. if (MYSQL_FOUND)
  559. add_definitions (-D_USE_MYSQL_REPOSITORY)
  560. else()
  561. message(FATAL_ERROR "MYSQL requested but package not found")
  562. endif()
  563. else()
  564. add_definitions (-D_NO_MYSQL_REPOSITORY)
  565. endif(USE_MYSQL_REPOSITORY)
  566. if(USE_APR)
  567. find_package(APR)
  568. if (APR_FOUND)
  569. add_definitions (-D_USE_APR)
  570. include_directories(${APR_INCLUDE_DIR})
  571. link_directories(${APR_LIBRARIES})
  572. else()
  573. message(FATAL_ERROR "APR requested but package not found")
  574. endif()
  575. if (APRUTIL_FOUND)
  576. include_directories(${APRUTIL_INCLUDE_DIR})
  577. link_directories(${APRUTIL_LIBRARIES})
  578. else()
  579. message(FATAL_ERROR "APRUTIL requested but package not found")
  580. endif()
  581. else()
  582. add_definitions (-D_NO_APR)
  583. endif(USE_APR)
  584. ENDIF()
  585. ###########################################################################
  586. ###
  587. ## The following sets the install directories and names.
  588. ###
  589. if ( PLATFORM )
  590. set ( CMAKE_INSTALL_PREFIX "${PREFIX}/${DIR_NAME}" )
  591. else ( PLATFORM )
  592. set ( CMAKE_INSTALL_PREFIX "${PREFIX}/${DIR_NAME}/${version}/clienttools" )
  593. endif ( PLATFORM )
  594. set (CMAKE_SKIP_BUILD_RPATH FALSE)
  595. set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  596. set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
  597. set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  598. if (APPLE)
  599. set(CMAKE_INSTALL_RPATH "@loader_path/../${LIB_DIR}")
  600. set(CMAKE_INSTALL_NAME_DIR "@loader_path/../${LIB_DIR}")
  601. endif()
  602. MACRO (FETCH_GIT_TAG workdir edition result)
  603. execute_process(COMMAND "${GIT_COMMAND}" describe --tags --dirty --abbrev=6 --match ${edition}*
  604. WORKING_DIRECTORY "${workdir}"
  605. OUTPUT_VARIABLE ${result}
  606. ERROR_QUIET
  607. OUTPUT_STRIP_TRAILING_WHITESPACE)
  608. if ("${${result}}" STREQUAL "")
  609. execute_process(COMMAND "${GIT_COMMAND}" describe --always --tags --all --abbrev=6 --dirty --long
  610. WORKING_DIRECTORY "${workdir}"
  611. OUTPUT_VARIABLE ${result}
  612. ERROR_QUIET
  613. OUTPUT_STRIP_TRAILING_WHITESPACE)
  614. endif()
  615. ENDMACRO()
  616. endif ("${COMMONSETUP_DONE}" STREQUAL "")