commonSetup.cmake 19 KB

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