commonSetup.cmake 19 KB

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