commonSetup.cmake 23 KB

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