commonSetup.cmake 19 KB

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