commonSetup.cmake 20 KB

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