1 #-----------------------------------------------------------------------------
4 # Authors: Nevrax and the Ryzom Core Community
8 # * Changing install location: add -DCMAKE_INSTALL_PREFIX:PATH=/my/new/path
9 # * Changing specific install location variables:
10 # * NL_ETC_PREFIX (default: $CMAKE_INSTALL_PREFIX/etc)
11 # * NL_SHARE_PREFIX (default: $CMAKE_INSTALL_PREFIX/share)
12 # * NL_BIN_PREFIX (default: $CMAKE_INSTALL_PREFIX/bin)
13 # * NL_SBIN_PREFIX (default: $CMAKE_INSTALL_PREFIX/sbin)
14 # * NL_LIB_PREFIX (default: $CMAKE_INSTALL_PREFIX/lib)
15 # * NL_DRIVER_PREFIX (default: $CMAKE_INSTALL_PREFIX/lib (windows) or $CMAKE_INSTALL_PREFIX/lib/nel)
16 # * Enable building of documentation: add -DBUILD_DOCUMENTATION:BOOL=ON - new make target: DoxygenDoc
17 # * Updating version: update header (above) but also update NL_VERSION below.
18 # * To build binary archive, use the 'package' target.
19 # To build source archive, use the 'package_source' target.
21 #-----------------------------------------------------------------------------
23 SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
24 #-----------------------------------------------------------------------------
25 # Set CMake 2.6 Policies.
26 IF(COMMAND cmake_policy)
27 # Works around warnings libraries linked against that don't
28 # have absolute paths (e.g. -lpthread)
29 cmake_policy(SET CMP0003 NEW)
31 # allow to link to qtmain automatically under Windows
33 CMAKE_POLICY(SET CMP0020 NEW)
38 #-----------------------------------------------------------------------------
39 # Downloads and install Hunger into HUNTER_ROOT directory.
40 OPTION(HUNTER_ENABLED "Enable Hunter package manager" OFF)
42 INCLUDE("CMakeModules/HunterGate.cmake")
44 URL "https://github.com/cpp-pm/hunter/archive/v0.23.321.tar.gz"
45 SHA1 "5e53cbb0429037ea8e2592bfd92704b8ff3ab492"
46 FILEPATH "${CMAKE_CURRENT_LIST_DIR}/CMakeModules/HunterConfig.cmake"
49 # default options for hunterized build
50 SET(WITH_STATIC ON CACHE BOOL "static" FORCE)
51 SET(WITH_STATIC_DRIVERS ON CACHE BOOL "static drivers" FORCE)
52 SET(WITH_STATIC_CURL ON CACHE BOOL "static curl" FORCE)
53 SET(WITH_STATIC_LIBXML2 ON CACHE BOOL "static libxml2" FORCE)
54 SET(WITH_STATIC_EXTERNAL ON CACHE BOOL "static external" FORCE)
55 SET(WITH_EXTERNAL OFF CACHE BOOL "external libs" FORCE)
57 # Workaround for PCH compilation issue, from curl intsizeof depencency
58 ADD_DEFINITIONS(-D__STDC_LIMIT_MACROS)
62 #-----------------------------------------------------------------------------
65 INCLUDE(ConfigureChecks)
67 INCLUDE(${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL)
69 # Force out of source builds.
72 # To be able to specify a different deployment target on Mac OS X :
73 # export MACOSX_DEPLOYMENT_TARGET=10.6
75 IF(CMAKE_VERSION VERSION_GREATER "2.8.10")
76 STRING(TIMESTAMP CURRENT_YEAR "%Y")
78 SET(CURRENT_YEAR "2019")
81 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
82 PROJECT(RyzomCore CXX C)
83 SET(NL_VERSION_MAJOR 4)
84 SET(NL_VERSION_MINOR 0)
85 SET(NL_VERSION_PATCH 0 CACHE STRING "Patch version")
86 SET(NL_VERSION_BUILD 0 CACHE STRING "Build number")
87 SET(YEAR "2001-${CURRENT_YEAR}")
88 SET(AUTHOR "Winch Gate and The Ryzom Core Community")
90 #-----------------------------------------------------------------------------
91 # Redirect output files
92 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
93 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
95 # DLL should be in the same directory as EXE under Windows
97 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
99 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
104 FIND_PACKAGE(MFC QUIET)
108 #-----------------------------------------------------------------------------
109 # Set default config options
111 NL_SETUP_DEFAULT_OPTIONS()
112 NL_SETUP_NEL_DEFAULT_OPTIONS()
113 NL_SETUP_NELNS_DEFAULT_OPTIONS()
114 NL_SETUP_RYZOM_DEFAULT_OPTIONS()
115 NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS()
118 NL_SETUP_BUILD_FLAGS()
120 NL_SETUP_PREFIX_PATHS()
121 RYZOM_SETUP_PREFIX_PATHS()
123 #-----------------------------------------------------------------------------
124 # Default values for URL's
125 SET(RYZOM_CLIENT_CREATE_ACCOUNT_URL "https://core.ryzom.dev/ams/" CACHE STRING "Ryzom Client Create Account URL")
126 SET(RYZOM_CLIENT_EDIT_ACCOUNT_URL "https://core.ryzom.dev/ams/" CACHE STRING "Ryzom Client Edit Account URL")
127 SET(RYZOM_CLIENT_FORGET_PASSWORD_URL "https://core.ryzom.dev/ams/" CACHE STRING "Ryzom Client Forget Password URL")
128 SET(RYZOM_CLIENT_PATCH_URL "https://cdn.ryzom.dev/core4/patch/" CACHE STRING "Ryzom Client Patch URL")
129 SET(RYZOM_CLIENT_APP_NAME "core4")
131 SET(RYZOM_CLIENT_RELEASENOTES_URL "https://core4.ryzom.dev/releasenotes/index.php" CACHE STRING "Ryzom Client Release Notes URL")
132 SET(RYZOM_CLIENT_RELEASENOTES_RING_URL "https://core4.ryzom.dev/releasenotes_ring/index.php" CACHE STRING "Ryzom Client Release Notes URL")
134 #-----------------------------------------------------------------------------
135 # urls when compiling ryzom live client
137 MESSAGE("Using RYZOM_LIVE urls")
138 SET(RYZOM_CLIENT_CREATE_ACCOUNT_URL "https://account.ryzom.com/signup/from_client.php")
139 SET(RYZOM_CLIENT_EDIT_ACCOUNT_URL "https://account.ryzom.com/payment_profile/index.php")
140 SET(RYZOM_CLIENT_FORGET_PASSWORD_URL "https://account.ryzom.com/payment_profile/lost_secure_password.php")
141 SET(RYZOM_CLIENT_PATCH_URL "http://dl.ryzom.com/patch_live")
142 SET(RYZOM_CLIENT_APP_NAME "ryzom_live")
144 SET(RYZOM_CLIENT_RELEASENOTES_URL "https://app.ryzom.com/releasenotes/index.php")
145 SET(RYZOM_CLIENT_RELEASENOTES_RING_URL "https://app.ryzom.com/releasenotes_ring/index.php")
148 #-----------------------------------------------------------------------------
154 SET(WINSOCK2_LIB ws2_32.lib)
157 FIND_PACKAGE(CustomMFC REQUIRED)
162 # This fix is for compiling OpenSSL in Azure Pipeline linux agent where ENV{SYSTEM} == "build"
163 IF(DEFINED ENV{SYSTEM} AND UNIX AND NOT APPLE)
164 STRING(TOUPPER "$ENV{SYSTEM}" _tmp)
165 IF (_tmp STREQUAL "BUILD")
170 ## TODO: hack for freetype hunter package
173 HUNTER_ADD_PACKAGE(ZLIB)
175 FIND_PACKAGE(ZLIB CONFIG REQUIRED)
176 SET(ZLIB_LIBRARY ZLIB::zlib)
178 HUNTER_ADD_PACKAGE(libxml2)
179 FIND_PACKAGE(libxml2 CONFIG REQUIRED)
180 SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} libxml2::libxml2)
182 HUNTER_ADD_PACKAGE(OpenSSL)
183 FIND_PACKAGE(OpenSSL REQUIRED)
184 # TODO: is OpenSSL::Crypto only needed for WIN32?
185 SET(OPENSSL_LIBRARIES OpenSSL::SSL OpenSSL::Crypto)
187 # for precompiled headers, not needed if using TARGET_PRECOMPILE_HEADERS() from cmake 3.16+
188 SET(ZLIB_INCLUDE_DIR ZLIB_ROOT/include)
189 SET(LIBXML2_INCLUDE_DIR ${LIBXML2_ROOT}/include/libxml2)
191 FIND_PACKAGE(ZLIB REQUIRED)
192 FIND_PACKAGE(LibXml2 REQUIRED)
193 FIND_PACKAGE(PNG REQUIRED)
194 FIND_PACKAGE(OpenSSL REQUIRED)
199 SET(OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} Crypt32.lib)
211 NL_CONFIGURE_CHECKS()
213 IF(WITH_STATIC_LIBXML2)
214 ADD_DEFINITIONS(-DLIBXML_STATIC)
217 FIND_PACKAGE(Iconv QUIET)
219 INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
220 SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${ICONV_LIBRARIES})
224 # libxml2 could need winsock2 library
226 SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${WINSOCK2_LIB})
229 IF(UNIX AND NOT HUNTER_ENABLED)
230 # under Linux and OS X, recent libxml2 versions are linked against liblzma
231 FIND_PACKAGE(LibLZMA)
232 IF(LIBLZMA_LIBRARIES)
233 SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${LIBLZMA_LIBRARIES})
236 # under Linux and OS X, recent libxml2 versions are linked against libicu
238 FIND_LIBRARY(ICU_LIBRARY icuuc)
240 FIND_LIBRARY(ICU_DATA_LIBRARY icudata)
242 MESSAGE(STATUS "ICU UC was found: ${ICU_LIBRARY}")
244 MESSAGE(STATUS "ICU UC was NOT found")
246 SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${ICU_DATA_LIBRARY} ${ICU_LIBRARY})
252 INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/PCHSupport.cmake)
255 ADD_DEFINITIONS(-DFINAL_VERSION=1)
259 ADD_DEFINITIONS(-DNL_HAS_SSE2)
261 ADD_DEFINITIONS(-DNL_HAS_SSE3)
266 FIND_LIBRARY(CARBON_FRAMEWORK Carbon)
267 FIND_LIBRARY(FOUNDATION_FRAMEWORK Foundation)
268 FIND_LIBRARY(SECURITY_FRAMEWORK Security)
270 IF(APPLE_CERTIFICATE)
271 # Find codesign_allocate
273 # Xcode 7.0 and later versions
274 SET(CODESIGN_ALLOCATE ${OSX_DEVELOPER_ROOT}/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate)
276 IF(NOT EXISTS "${CODESIGN_ALLOCATE}")
277 # Xcode 6.4 and previous versions
278 SET(CODESIGN_ALLOCATE ${CMAKE_OSX_SYSROOT}/usr/bin/codesign_allocate)
281 IF(NOT EXISTS "${CODESIGN_ALLOCATE}")
283 SET(CODESIGN_ALLOCATE /usr/bin/codesign_allocate)
286 IF(NOT EXISTS "${CODESIGN_ALLOCATE}")
287 MESSAGE(WARNING "Unable to find codesign_allocate in standard directories")
288 SET(CODESIGN_ALLOCATE)
295 #TODO: hunter qt package
301 SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QTDIR} $ENV{QTDIR})
304 FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtXml QtOpenGL REQUIRED)
307 #TODO: hunter assimp package
309 FIND_PACKAGE(assimp REQUIRED)
314 FIND_PACKAGE(CppTest)
319 HUNTER_ADD_PACKAGE(luabind)
320 FIND_PACKAGE(Luabind REQUIRED)
323 HUNTER_ADD_PACKAGE(CURL)
324 FIND_PACKAGE(CURL CONFIG REQUIRED)
326 SET(CURL_LIBRARIES CURL::libcurl libxml2::libxml2)
329 FIND_PACKAGE(Luabind REQUIRED)
332 FIND_PACKAGE(CURL REQUIRED)
333 # if cmake finds config-file package, ie FIND_PACKAGE(CURL CONFIG), then CURL_LIBRARIES is not defined
334 IF(TARGET CURL::libcurl)
335 SET(CURL_LIBRARIES CURL::libcurl)
338 IF((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL)
345 SET(CURL_DEFINITIONS -DCURL_STATICLIB)
347 LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
348 LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES})
351 LIST(APPEND CURL_LIBRARIES Crypt32 Cryptui)
353 # CURL depends on libidn
354 FIND_LIBRARY(IDN_LIBRARY idn)
356 LIST(APPEND CURL_LIBRARIES ${IDN_LIBRARY})
359 # CURL Macports version can depend on libidn, libidn2, libintl, libpsl and libiconv too
361 FIND_LIBRARY(INTL_LIBRARY intl)
363 LIST(APPEND CURL_LIBRARIES ${INTL_LIBRARY})
366 FIND_LIBRARY(IDN2_LIBRARY idn2)
368 LIST(APPEND CURL_LIBRARIES ${IDN2_LIBRARY})
371 FIND_LIBRARY(PSL_LIBRARY psl)
373 LIST(APPEND CURL_LIBRARIES ${PSL_LIBRARY})
376 FIND_LIBRARY(UNISTRING_LIBRARY unistring)
377 IF(UNISTRING_LIBRARY)
378 LIST(APPEND CURL_LIBRARIES ${UNISTRING_LIBRARY})
381 LIST(APPEND CURL_LIBRARIES ${SECURITY_FRAMEWORK})
387 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/nel/include)
388 ADD_SUBDIRECTORY(nel)
390 # Aliases for targets
391 SET(NELMISC_LIBRARIES nelmisc)
392 SET(NELNET_LIBRARIES nelnet)
393 SET(NELLIGO_LIBRARIES nelligo)
394 SET(NELGEORGES_LIBRARIES nelgeorges)
395 SET(NEL3D_LIBRARIES nel3d)
396 SET(NELGUI_LIBRARIES nelgui)
397 SET(NELSOUND_LIBRARIES nelsound)
399 # FIND_PACKAGE(NeL COMPONENTS 3d misc pacs sound nimp REQUIRED)
400 FIND_PACKAGE(NeL REQUIRED)
401 INCLUDE_DIRECTORIES(${NEL_INCLUDE_DIRS})
405 ADD_SUBDIRECTORY(ryzom)
409 ADD_SUBDIRECTORY(nelns)
413 ADD_SUBDIRECTORY(snowballs2)
417 ADD_SUBDIRECTORY(tool)
421 ADD_SUBDIRECTORY(studio)
425 ADD_SUBDIRECTORY(personal)
428 # To build the documention, you will have to enable it
429 # and then do the equivalent of "make DoxygenDoc".
430 IF(BUILD_DOCUMENTATION)
436 # This processes our Doxyfile.in and substitutes paths to generate
438 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/doc/Doxyfile.cmake.in ${CMAKE_BINARY_DIR}/doc/Doxyfile)
440 ADD_CUSTOM_TARGET(DoxygenDoc ${DOXYGEN} ${CMAKE_BINARY_DIR}/doc/Doxyfile)
445 ADD_TEST(nel_unit_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/nel_unit_test --html)
449 SET(SVNSOURCEDIR http://dev.ryzom.com/svn/trunk/nel)
450 SET(GENERATELOGS svn2cl)
454 # packaging information
455 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Ryzom Core MMORPG Framework")
456 SET(CPACK_PACKAGE_VENDOR "Ryzom Core")
457 SET(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/README)
458 SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/COPYING)
459 SET(CPACK_PACKAGE_VERSION_MAJOR "${NL_VERSION_MAJOR}")
460 SET(CPACK_PACKAGE_VERSION_MINOR "${NL_VERSION_MINOR}")
461 SET(CPACK_PACKAGE_VERSION_PATCH "${NL_VERSION_PATCH}")
462 SET(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_BINARY_DIR};NeL;ALL;/")
463 SET(CPACK_PACKAGE_EXECUTABLES "ryzomcore${NL_VERSION}" "ryzomcore")
464 SET(CPACK_SET_DESTDIR TRUE)
466 # NSIS Specific Packing Setup
467 SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "RyzomCore")
468 SET(CPACK_NSIS_MODIFY_PATH "ON")
469 SET(CPACK_NSIS_MUI_ICON ${CMAKE_SOURCE_DIR}/resources/nevraxpill.ico)
470 SET(CPACK_NSIS_MUI_UNIICON ${CMAKE_SOURCE_DIR}/resources/nevraxpill.ico)
471 SET(CPACK_PACKAGE_ICON ${CMAKE_SOURCE_DIR}/resources\\\\nel.bmp)
472 SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} RyzomCore")
473 SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\dev.ryzom.com")
474 SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\dev.ryzom.com\\\\projects\\\\nel\\\\wiki")
475 SET(CPACK_NSIS_CONTACT "matt.raykowski@gmail.com")
478 SET(CPACK_PACKAGE_FILE_NAME "ryzomcore-${NL_VERSION}")
479 SET(CPACK_SOURCE_PACKAGE_FILE_NAME "ryzomcore-${NL_VERSION}")
481 #SET(CPACK_GENERATOR "NSIS")
482 SET(CPACK_GENERATOR "NSIS;ZIP")
483 SET(CPACK_SOURCE_GENERATOR "ZIP")
485 SET(CPACK_GENERATOR "TGZ")
486 SET(CPACK_SOURCE_GENERATOR "TGZ")
488 set(CPACK_SOURCE_IGNORE_FILES
491 "^${CMAKE_SOURCE_DIR}.*/CVS/"
492 "^${CMAKE_SOURCE_DIR}.*/\\\\.svn/"
493 "^${CMAKE_SOURCE_DIR}/debian/"
494 "^${CMAKE_SOURCE_DIR}/old/")
496 IF(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
497 SET(CMAKE_INSTALL_DEBUG_LIBRARIES TRUE)
499 INCLUDE(${QT_USE_FILE})
501 "${QT_LIBRARY_DIR}/../bin/QtGuid4.dll"
502 "${QT_LIBRARY_DIR}/../bin/QtXmld4.dll"
503 "${QT_LIBRARY_DIR}/../bin/QtCored4.dll"
504 DESTINATION ${NL_BIN_PREFIX})
508 INCLUDE(${QT_USE_FILE})
510 "${QT_LIBRARY_DIR}/../bin/QtGui4.dll"
511 "${QT_LIBRARY_DIR}/../bin/QtXml4.dll"
512 "${QT_LIBRARY_DIR}/../bin/QtCore4.dll"
513 DESTINATION ${NL_BIN_PREFIX})
517 # Install CEGUI and its dependencies.
519 INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIBase.dll" DESTINATION ${NL_BIN_PREFIX})
520 INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIDevilImageCodec.dll" DESTINATION ${NL_BIN_PREFIX})
521 INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIExpatParser.dll" DESTINATION ${NL_BIN_PREFIX})
522 INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIFalagardWRBase.dll" DESTINATION ${NL_BIN_PREFIX})
523 INSTALL(FILES "${CEGUI_LIB_DIR}/Devil.dll" DESTINATION ${NL_BIN_PREFIX})
524 INSTALL(FILES "${CEGUI_LIB_DIR}/ILU.dll" DESTINATION ${NL_BIN_PREFIX})
527 # Only the tools require MFC.
529 SET(CMAKE_INSTALL_MFC_LIBRARIES TRUE)
531 #INCLUDE(InstallRequiredSystemLibraries)
536 INCLUDE(CMakePackaging.txt)
541 # ADD_DEBIAN_TARGETS(nel)