Guest User

Untitled

a guest
Feb 7th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.35 KB | None | 0 0
  1. #
  2. # This file is part of the CMaNGOS Project. See AUTHORS file for Copyright information
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (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 General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17.  
  18. project(CMaNGOS)
  19.  
  20. cmake_minimum_required(VERSION 2.8.12)
  21.  
  22. include(cmake/common.cmake)
  23.  
  24. # Set RPATH-handing (CMake parameters)
  25. set(CMAKE_SKIP_BUILD_RPATH FALSE)
  26. set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  27. set(CMAKE_INSTALL_RPATH ${LIBS_DIR})
  28. set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  29.  
  30. # set default buildoptions and print them
  31. include(cmake/options.cmake)
  32.  
  33. # Force out-of-source build
  34. if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
  35. message(FATAL_ERROR
  36. "This project requires an out of source build. Remove the file 'CMakeCache.txt' found in this directory before continuing, create a separate build directory and run 'cmake [options] <srcs>' from there."
  37. )
  38. endif()
  39.  
  40. # TODO: allow other compilers under windows in the future
  41. if(WIN32 AND NOT MSVC)
  42. message(FATAL_ERROR
  43. "Under Windows other compiler than Microsoft Visual Studio are not supported."
  44. )
  45. endif()
  46.  
  47. # TODO: remove this in the future! it has only been added to make the switch easier for end users
  48. if(PREFIX)
  49. message(FATAL_ERROR "The parameter PREFIX has been removed. Please re-run CMake and use CMAKE_INSTALL_PREFIX instead to define your installation location!")
  50. endif()
  51.  
  52. include(CheckPlatform)
  53.  
  54. # TODO: use MSVC_CXX_ARCHITECTURE_ID instead to identify platform on windows (not required on other systems)
  55. # find platform: required to build 3rd party libraries w/o CMake files
  56. # Find out what system we use to include the needed libs
  57. if(WIN32)
  58. if(PLATFORM MATCHES X86) # 32-bit
  59. set(DEP_ARCH win32)
  60. else() # 64-bit
  61. set(DEP_ARCH x64)
  62. endif()
  63. endif()
  64.  
  65. # find Git: used to get the revision number
  66. find_package(Git)
  67.  
  68. # check if the platform supports precomiled headers
  69. #find_package(PCHSupport)
  70. include(cotire)
  71.  
  72. # Override configuration-types - we don't use anything else than debug and release
  73. if(CMAKE_CONFIGURATION_TYPES)
  74. set(CMAKE_CONFIGURATION_TYPES Release Debug)
  75. set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
  76. "Reset the configurations to what we need"
  77. FORCE)
  78. endif()
  79.  
  80. set(BIN_FOLDER_NAME bin)
  81. set(CONF_FOLDER_NAME etc)
  82. set(LIBS_FOLDER_NAME lib)
  83.  
  84. set(BIN_DIR ${CMAKE_INSTALL_PREFIX}/${BIN_FOLDER_NAME})
  85. set(CONF_DIR ${CMAKE_INSTALL_PREFIX}/${CONF_FOLDER_NAME})
  86. # If win32 put it in the bin dir not lib
  87. if(WIN32)
  88. set(LIBS_DIR ${CMAKE_INSTALL_PREFIX}/${BIN_FOLDER_NAME})
  89. else()
  90. set(LIBS_DIR ${CMAKE_INSTALL_PREFIX}/${LIBS_FOLDER_NAME})
  91. endif()
  92.  
  93. # For Unix systems set the rpath so that libraries are found
  94. set(CMAKE_INSTALL_RPATH ../${LIBS_FOLDER_NAME})
  95. set(CMAKE_INSTALL_NAME_DIR ${LIBS_DIR})
  96.  
  97. # Find needed packages and if necessery abort if something important is missing
  98. find_package(Boost REQUIRED COMPONENTS system program_options thread)
  99.  
  100. if(Boost_FOUND)
  101. include_directories(${Boost_INCLUDE_DIRS})
  102. else()
  103. message(FATAL_ERROR "This project requires boost. Please install from http://www.boost.org")
  104. endif()
  105.  
  106. # Win32 delivered packages
  107. if(WIN32)
  108. set(MYSQL_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/dep/include/mysql)
  109. set(MYSQL_LIBRARY ${CMAKE_SOURCE_DIR}/dep/lib/${DEP_ARCH}_release/libmySQL.lib)
  110. set(MYSQL_DEBUG_LIBRARY ${CMAKE_SOURCE_DIR}/dep/lib/${DEP_ARCH}_debug/libmySQL.lib)
  111. set(OPENSSL_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/dep/include/openssl)
  112. set(OPENSSL_LIBRARIES ${CMAKE_SOURCE_DIR}/dep/lib/${DEP_ARCH}_release/libeay32.lib)
  113. set(OPENSSL_DEBUG_LIBRARIES ${CMAKE_SOURCE_DIR}/dep/lib/${DEP_ARCH}_debug/libeay32.lib)
  114. # zlib is build
  115. endif()
  116.  
  117. # *nix-specific packages
  118. if(UNIX)
  119. if(POSTGRESQL)
  120. find_package(PostgreSQL REQUIRED)
  121.  
  122. if(POSTGRESQL_FOUND)
  123. include_directories(${POSTGRESQL_INCLUDE_DIRS})
  124. endif(POSTGRESQL_FOUND)
  125.  
  126. else()
  127. find_package(MySQL REQUIRED)
  128. endif()
  129.  
  130. find_package(OpenSSL REQUIRED)
  131. find_package(ZLIB REQUIRED)
  132. endif()
  133.  
  134. # Find core revision
  135. if(GIT_EXECUTABLE)
  136. execute_process(
  137. COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
  138. WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
  139. OUTPUT_VARIABLE GIT_REVISION
  140. RESULT_VARIABLE GIT_RESULT
  141. ERROR_QUIET
  142. OUTPUT_STRIP_TRAILING_WHITESPACE
  143. )
  144. if(GIT_RESULT)
  145. set(GIT_REVISION "Git repository not found")
  146. endif()
  147. else()
  148. set(GIT_REVISION "Git not found")
  149. endif()
  150.  
  151. if(DEFINED INCLUDE_BINDINGS_DIR AND INCLUDE_BINDINGS_DIR)
  152. # check if the directory exists
  153. if(NOT IS_DIRECTORY ${CMAKE_SOURCE_DIR}/src/bindings/${INCLUDE_BINDINGS_DIR})
  154. message(FATAL_ERROR "Could not find the script library which was supposed to be: " ${CMAKE_SOURCE_DIR}/src/bindings/${INCLUDE_BINDINGS_DIR})
  155. endif()
  156. # check if it really contains a CMakeLists.txt
  157. if(NOT EXISTS ${CMAKE_SOURCE_DIR}/src/bindings/${INCLUDE_BINDINGS_DIR}/CMakeLists.txt)
  158. message(FATAL_ERROR "The script library does not contain a CMakeLists.txt!")
  159. endif()
  160. else()
  161. endif()
  162.  
  163. #if(PCH AND NOT PCHSupport_FOUND)
  164. # set(PCH 0 CACHE BOOL
  165. # "Use precompiled headers"
  166. # FORCE)
  167. # message(WARNING "No PCH for your system possible but PCH was set to 1. Resetting it."
  168. # )
  169. #endif()
  170.  
  171. set(DEFINITIONS_RELEASE NDEBUG)
  172. set(DEFINITIONS_DEBUG _DEBUG MANGOS_DEBUG)
  173.  
  174. if(DEBUG)
  175. set(CMAKE_BUILD_TYPE Debug)
  176. else()
  177. set(CMAKE_BUILD_TYPE Release)
  178. endif()
  179.  
  180. # print out the results before continuing
  181. include(cmake/showoptions.cmake)
  182.  
  183. if(NOT BUILD_CORE AND NOT BUILD_EXTRACTOR AND NOT BUILD_VMAP_EXTRACTOR AND NOT BUILD_MMAP_EXTRACTOR)
  184. message(FATAL_ERROR "You must select something to build!")
  185. endif()
  186.  
  187. # Generate revision-extractor
  188. set(GENREV_SRC
  189. src/tools/genrevision/genrevision.cpp
  190. )
  191.  
  192. add_executable(genrev
  193. ${GENREV_SRC}
  194. )
  195.  
  196. add_custom_target("revision.h" ALL
  197. COMMAND genrev ${CMAKE_SOURCE_DIR}
  198. WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
  199. DEPENDS genrev
  200. )
  201.  
  202. if(WIN32)
  203. install(
  204. FILES
  205. ${CMAKE_SOURCE_DIR}/dep/lib/${DEP_ARCH}_release/libeay32.dll
  206. ${CMAKE_SOURCE_DIR}/dep/lib/${DEP_ARCH}_release/libmySQL.dll
  207. DESTINATION ${LIBS_DIR}
  208. CONFIGURATIONS Release
  209. )
  210. install(
  211. FILES
  212. ${CMAKE_SOURCE_DIR}/dep/lib/${DEP_ARCH}_debug/libeay32.dll
  213. ${CMAKE_SOURCE_DIR}/dep/lib/${DEP_ARCH}_debug/libmySQL.dll
  214. DESTINATION ${LIBS_DIR}
  215. CONFIGURATIONS Debug
  216. )
  217. if(PLATFORM MATCHES X86)
  218. # Copy dll's Windows needs
  219. install(
  220. FILES
  221. ${CMAKE_SOURCE_DIR}/dep/lib/win32_release/dbghelp.dll
  222. DESTINATION ${LIBS_DIR}
  223. CONFIGURATIONS Release
  224. )
  225. install(
  226. FILES
  227. ${CMAKE_SOURCE_DIR}/dep/lib/win32_debug/dbghelp.dll
  228. DESTINATION ${LIBS_DIR}
  229. CONFIGURATIONS Debug
  230. )
  231. endif()
  232. endif()
  233.  
  234. if(XCODE)
  235. if(PLATFORM MATCHES X86)
  236. set(CMAKE_OSX_ARCHITECTURES i386)
  237. else()
  238. set(CMAKE_OSX_ARCHITECTURES x86_64)
  239. endif()
  240. endif()
  241.  
  242. add_subdirectory(dep)
  243.  
  244. # Add definitions for all build types
  245. # Don't place this above 'dep' subdirectory! Because of defines build will crash.
  246. set(DEFINITIONS
  247. SYSCONFDIR="../${CONF_FOLDER_NAME}/"
  248. )
  249.  
  250. if(POSTGRESQL)
  251. set(DEFINITIONS ${DEFINITIONS} DO_POSTGRESQL)
  252. else()
  253. set(DEFINITIONS ${DEFINITIONS} DO_MYSQL)
  254. endif()
  255.  
  256. if(WIN32)
  257. set(DEFINITIONS ${DEFINITIONS} WIN32 _WIN32)
  258. endif()
  259.  
  260. if(DEBUG)
  261. set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS};${DEFINITIONS_DEBUG}")
  262. else()
  263. set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS};${DEFINITIONS_RELEASE}")
  264. endif()
  265.  
  266. if(BUILD_CORE)
  267. add_subdirectory(src)
  268. endif()
  269.  
  270. if(BUILD_EXTRACTOR)
  271. add_subdirectory(contrib/extractor)
  272. endif()
  273.  
  274. if(BUILD_VMAP_EXTRACTOR)
  275. add_subdirectory(contrib/vmap_extractor)
  276. add_subdirectory(contrib/vmap_assembler)
  277. endif()
  278.  
  279. if(BUILD_MMAP_EXTRACTOR)
  280. add_subdirectory(contrib/mmap)
  281. endif()
  282. # if(SQL)
  283. # add_subdirectory(sql)
  284. # endif()
Advertisement
Add Comment
Please, Sign In to add comment