commonSetup.cmake 23 KB

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