Changed: Form element styling
[ryzomcore.git] / code / CMakeLists.txt
blob681f7a95997e0f8ace6bdbc6582c896fe26bd482
1 #-----------------------------------------------------------------------------
3 # Ryzom Core
4 #  Authors: Nevrax and the Ryzom Core Community
5 #  Version: 0.12.0
7 # Notes:
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 #-----------------------------------------------------------------------------
22 # Load some macros.
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
32   IF(POLICY CMP0020)
33     CMAKE_POLICY(SET CMP0020 NEW)
34   ENDIF()
35 ENDIF()
37 INCLUDE(nel)
38 INCLUDE(ConfigureChecks)
39 INCLUDE(CheckDepends)
40 INCLUDE(${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL)
42 # Force out of source builds.
43 CHECK_OUT_OF_SOURCE()
45 # To be able to specify a different deployment target on Mac OS X :
46 # export MACOSX_DEPLOYMENT_TARGET=10.6
48 IF(CMAKE_VERSION VERSION_GREATER "2.8.10")
49   STRING(TIMESTAMP CURRENT_YEAR "%Y")
50 ELSE()
51   SET(CURRENT_YEAR "2016")
52 ENDIF()
54 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
55 PROJECT(RyzomCore CXX C)
56 SET(NL_VERSION_MAJOR 1)
57 SET(NL_VERSION_MINOR 0)
58 SET(NL_VERSION_PATCH 0)
59 SET(YEAR "2004-${CURRENT_YEAR}")
60 SET(AUTHOR "Winch Gate and The Ryzom Core Community")
62 #-----------------------------------------------------------------------------
63 # Redirect output files
64 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
65 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
67 # DLL should be in the same directory as EXE under Windows
68 IF(WIN32)
69   SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
70 ELSE()
71   SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
72 ENDIF()
74 IF(WIN32)
75   IF(WITH_MFC)
76     FIND_PACKAGE(MFC QUIET)
77   ENDIF()
78 ENDIF()
80 #-----------------------------------------------------------------------------
81 # Set default config options
83 NL_SETUP_DEFAULT_OPTIONS()
84 NL_SETUP_NEL_DEFAULT_OPTIONS()
85 NL_SETUP_NELNS_DEFAULT_OPTIONS()
86 NL_SETUP_RYZOM_DEFAULT_OPTIONS()
87 NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS()
89 NL_SETUP_BUILD()
90 NL_SETUP_BUILD_FLAGS()
92 NL_SETUP_PREFIX_PATHS()
93 RYZOM_SETUP_PREFIX_PATHS()
95 #-----------------------------------------------------------------------------
96 #Platform specifics
98 SETUP_EXTERNAL()
100 IF(WIN32)
101   SET(WINSOCK2_LIB ws2_32.lib)
103   IF(WITH_MFC)
104     FIND_PACKAGE(CustomMFC REQUIRED)
105   ENDIF()
106 ENDIF()
108 FIND_PACKAGE(ZLIB REQUIRED)
109 FIND_PACKAGE(LibXml2 REQUIRED)
110 FIND_PACKAGE(PNG REQUIRED)
111 FIND_PACKAGE(OpenSSL REQUIRED)
112 FIND_PACKAGE(GIF)
113 FIND_PACKAGE(Jpeg)
115 IF(WIN32)
116   SET(OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} Crypt32.lib)
117 ENDIF()
119 IF(WITH_LIBOVR)
120   FIND_PACKAGE(LibOVR)
121 ENDIF()
123 IF(WITH_LIBVR)
124   FIND_PACKAGE(LibVR)
125 ENDIF()
127 NL_CONFIGURE_CHECKS()
129 IF(WITH_STATIC_LIBXML2)
130   SET(LIBXML2_DEFINITIONS ${LIBXML2_DEFINITIONS} -DLIBXML_STATIC)
131 ENDIF()
133 IF(WITH_LIBXML2_ICONV)
134   FIND_PACKAGE(Iconv REQUIRED)
135   INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
136   SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${ICONV_LIBRARIES})
137 ENDIF()
139 IF(WITH_STATIC)
140   # libxml2 could need winsock2 library
141   IF(WINSOCK2_LIB)
142     SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${WINSOCK2_LIB})
143   ENDIF()
145   IF(UNIX)
146     # under Linux and OS X, recent libxml2 versions are linked against liblzma
147     FIND_PACKAGE(LibLZMA)
148     IF(LIBLZMA_LIBRARIES)
149       SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${LIBLZMA_LIBRARIES})
150     ENDIF()
151   ENDIF()
152 ENDIF()
154 INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/PCHSupport.cmake)
156 IF(FINAL_VERSION)
157   ADD_DEFINITIONS(-DFINAL_VERSION=1)
158 ENDIF()
160 IF(WITH_SSE2)
161   ADD_DEFINITIONS(-DNL_HAS_SSE2)
162   IF(WITH_SSE3)
163     ADD_DEFINITIONS(-DNL_HAS_SSE3)
164   ENDIF()
165 ENDIF()
167 IF(APPLE)
168   FIND_LIBRARY(CARBON_FRAMEWORK Carbon)
169   FIND_LIBRARY(FOUNDATION_FRAMEWORK Foundation)
170   FIND_LIBRARY(SECURITY_FRAMEWORK Security)
172   IF(APPLE_CERTIFICATE)
173     # Find codesign_allocate
175     # Xcode 7.0 and later versions
176     SET(CODESIGN_ALLOCATE ${OSX_DEVELOPER_ROOT}/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate)
178     IF(NOT EXISTS "${CODESIGN_ALLOCATE}")
179       # Xcode 6.4 and previous versions
180       SET(CODESIGN_ALLOCATE ${CMAKE_OSX_SYSROOT}/usr/bin/codesign_allocate)
181     ENDIF()
183     IF(NOT EXISTS "${CODESIGN_ALLOCATE}")
184       # System path
185       SET(CODESIGN_ALLOCATE /usr/bin/codesign_allocate)
186     ENDIF()
188     IF(NOT EXISTS "${CODESIGN_ALLOCATE}")
189       MESSAGE(WARNING "Unable to find codesign_allocate in standard directories")
190       SET(CODESIGN_ALLOCATE)
191     ENDIF()
192   ENDIF()
193 ENDIF()
195 INCLUDE(FindHelpers)
197 IF(WITH_QT5)
198   FIND_QT5()
199 ENDIF()
201 IF(WITH_QT)
202   SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QTDIR} $ENV{QTDIR})
204   # Use Qt 4
205   FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtXml QtOpenGL REQUIRED)
206 ENDIF()
208 IF(WITH_ASSIMP)
209   FIND_PACKAGE(assimp REQUIRED)
210 ENDIF()
212 IF(WITH_NEL)
213   IF(WITH_NEL_TESTS)
214     FIND_PACKAGE(CppTest)
215   ENDIF()
217   IF(WITH_GUI)
218     FIND_PACKAGE(Luabind REQUIRED)
219     FIND_PACKAGE(CURL REQUIRED)
221     IF((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL)
222       SET(CURL_STATIC ON)
223     ELSE()
224       SET(CURL_STATIC OFF)
225     ENDIF()
227     IF(CURL_STATIC)
228       SET(CURL_DEFINITIONS -DCURL_STATICLIB)
230       LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
231       LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES})
233       IF(WIN32)
234         LIST(APPEND CURL_LIBRARIES Crypt32 Cryptui)
235       ELSE()
236         # CURL depends on libidn
237         FIND_LIBRARY(IDN_LIBRARY idn)
238         IF(IDN_LIBRARY)
239           LIST(APPEND CURL_LIBRARIES ${IDN_LIBRARY})
240         ENDIF()
242         # CURL Macports version can depend on libidn, libidn2, libintl, libpsl and libiconv too
243         IF(APPLE)
244           FIND_LIBRARY(INTL_LIBRARY intl)
245           IF(INTL_LIBRARY)
246             LIST(APPEND CURL_LIBRARIES ${INTL_LIBRARY})
247           ENDIF()
249           FIND_LIBRARY(IDN2_LIBRARY idn2)
250           IF(IDN2_LIBRARY)
251             LIST(APPEND CURL_LIBRARIES ${IDN2_LIBRARY})
252           ENDIF()
254           FIND_LIBRARY(PSL_LIBRARY psl)
255           IF(PSL_LIBRARY)
256             LIST(APPEND CURL_LIBRARIES ${PSL_LIBRARY})
257           ENDIF()
259           FIND_LIBRARY(UNISTRING_LIBRARY unistring)
260           IF(UNISTRING_LIBRARY)
261             LIST(APPEND CURL_LIBRARIES ${UNISTRING_LIBRARY})
262           ENDIF()
264           LIST(APPEND CURL_LIBRARIES ${SECURITY_FRAMEWORK})
265         ENDIF()
266       ENDIF()
267     ENDIF()
268   ENDIF()
270   INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/nel/include)
271   ADD_SUBDIRECTORY(nel)
273   # Aliases for targets
274   SET(NELMISC_LIBRARIES nelmisc)
275   SET(NELNET_LIBRARIES nelnet)
276   SET(NELLIGO_LIBRARIES nelligo)
277   SET(NELGEORGES_LIBRARIES nelgeorges)
278   SET(NEL3D_LIBRARIES nel3d)
279   SET(NELGUI_LIBRARIES nelgui)
280   SET(NELSOUND_LIBRARIES nelsound)
281 ELSE()
282 #  FIND_PACKAGE(NeL COMPONENTS 3d misc pacs sound nimp REQUIRED)
283   FIND_PACKAGE(NeL REQUIRED)
284   INCLUDE_DIRECTORIES(${NEL_INCLUDE_DIRS})
285 ENDIF()
287 IF(WITH_RYZOM)
288   ADD_SUBDIRECTORY(ryzom)
289 ENDIF()
291 IF(WITH_NELNS)
292   ADD_SUBDIRECTORY(nelns)
293 ENDIF()
295 IF(WITH_SNOWBALLS)
296   ADD_SUBDIRECTORY(snowballs2)
297 ENDIF()
299 IF(WITH_TOOLS)
300   ADD_SUBDIRECTORY(tool)
301 ENDIF()
303 IF(WITH_STUDIO)
304   ADD_SUBDIRECTORY(studio)
305 ENDIF()
307 IF(WITH_PERSONAL)
308   ADD_SUBDIRECTORY(personal)
309 ENDIF()
311 # To build the documention, you will have to enable it
312 # and then do the equivalent of "make DoxygenDoc".
313 IF(BUILD_DOCUMENTATION)
314     IF(DOT)
315         SET(HAVE_DOT YES)
316     ELSE()
317         SET(HAVE_DOT NO)
318     ENDIF()
319     # This processes our Doxyfile.in and substitutes paths to generate
320     # a final Doxyfile
321     CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/doc/Doxyfile.cmake.in ${CMAKE_BINARY_DIR}/doc/Doxyfile)
323     ADD_CUSTOM_TARGET(DoxygenDoc ${DOXYGEN} ${CMAKE_BINARY_DIR}/doc/Doxyfile)
324 ENDIF()
326 IF(WITH_NEL_TESTS)
327   ENABLE_TESTING()
328   ADD_TEST(nel_unit_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/nel_unit_test --html)
329   IF(BUILD_DASHBOARD)
330     INCLUDE(Dart)
331     SET(SVNCOMMAND svn)
332     SET(SVNSOURCEDIR http://dev.ryzom.com/svn/trunk/nel)
333     SET(GENERATELOGS svn2cl)
334   ENDIF()
335 ENDIF()
337 # packaging information
338 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Ryzom Core MMORPG Framework")
339 SET(CPACK_PACKAGE_VENDOR "Ryzom Core")
340 SET(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/README)
341 SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/COPYING)
342 SET(CPACK_PACKAGE_VERSION_MAJOR "${NL_VERSION_MAJOR}")
343 SET(CPACK_PACKAGE_VERSION_MINOR "${NL_VERSION_MINOR}")
344 SET(CPACK_PACKAGE_VERSION_PATCH "${NL_VERSION_PATCH}")
345 SET(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_BINARY_DIR};NeL;ALL;/")
346 SET(CPACK_PACKAGE_EXECUTABLES "ryzomcore${NL_VERSION}" "ryzomcore")
347 SET(CPACK_SET_DESTDIR TRUE)
349 # NSIS Specific Packing Setup
350 SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "RyzomCore")
351 SET(CPACK_NSIS_MODIFY_PATH "ON")
352 SET(CPACK_NSIS_MUI_ICON ${CMAKE_SOURCE_DIR}/resources/nevraxpill.ico)
353 SET(CPACK_NSIS_MUI_UNIICON ${CMAKE_SOURCE_DIR}/resources/nevraxpill.ico)
354 SET(CPACK_PACKAGE_ICON ${CMAKE_SOURCE_DIR}/resources\\\\nel.bmp)
355 SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} RyzomCore")
356 SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\dev.ryzom.com")
357 SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\dev.ryzom.com\\\\projects\\\\nel\\\\wiki")
358 SET(CPACK_NSIS_CONTACT "matt.raykowski@gmail.com")
360 ## Source Packages
361 SET(CPACK_PACKAGE_FILE_NAME "ryzomcore-${NL_VERSION}")
362 SET(CPACK_SOURCE_PACKAGE_FILE_NAME "ryzomcore-${NL_VERSION}")
363 IF(WIN32)
364   #SET(CPACK_GENERATOR "NSIS")
365   SET(CPACK_GENERATOR "NSIS;ZIP")
366   SET(CPACK_SOURCE_GENERATOR "ZIP")
367 ELSE()
368   SET(CPACK_GENERATOR "TGZ")
369   SET(CPACK_SOURCE_GENERATOR "TGZ")
370 ENDIF()
371 set(CPACK_SOURCE_IGNORE_FILES
372         "~$"
373         "\\\\.cvsignore$"
374         "^${CMAKE_SOURCE_DIR}.*/CVS/"
375         "^${CMAKE_SOURCE_DIR}.*/\\\\.svn/"
376         "^${CMAKE_SOURCE_DIR}/debian/"
377         "^${CMAKE_SOURCE_DIR}/old/")
378 IF(WIN32)
379   IF(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
380     SET(CMAKE_INSTALL_DEBUG_LIBRARIES TRUE)
381     IF(WITH_QT)
382       INCLUDE(${QT_USE_FILE})
383       INSTALL(FILES
384         "${QT_LIBRARY_DIR}/../bin/QtGuid4.dll"
385         "${QT_LIBRARY_DIR}/../bin/QtXmld4.dll"
386         "${QT_LIBRARY_DIR}/../bin/QtCored4.dll"
387         DESTINATION ${NL_BIN_PREFIX})
388     ENDIF()
389   ELSE()
390     IF(WITH_QT)
391       INCLUDE(${QT_USE_FILE})
392       INSTALL(FILES
393         "${QT_LIBRARY_DIR}/../bin/QtGui4.dll"
394         "${QT_LIBRARY_DIR}/../bin/QtXml4.dll"
395         "${QT_LIBRARY_DIR}/../bin/QtCore4.dll"
396         DESTINATION ${NL_BIN_PREFIX})
397     ENDIF()
398   ENDIF()
400   # Install CEGUI and its dependencies.
401   IF(WITH_NEL_CEGUI)
402     INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIBase.dll" DESTINATION ${NL_BIN_PREFIX})
403     INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIDevilImageCodec.dll" DESTINATION ${NL_BIN_PREFIX})
404     INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIExpatParser.dll" DESTINATION ${NL_BIN_PREFIX})
405     INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIFalagardWRBase.dll" DESTINATION ${NL_BIN_PREFIX})
406     INSTALL(FILES "${CEGUI_LIB_DIR}/Devil.dll" DESTINATION ${NL_BIN_PREFIX})
407     INSTALL(FILES "${CEGUI_LIB_DIR}/ILU.dll" DESTINATION ${NL_BIN_PREFIX})
408   ENDIF()
410   # Only the tools require MFC.
411   IF(WITH_TOOLS)
412     SET(CMAKE_INSTALL_MFC_LIBRARIES TRUE)
413   ENDIF()
414   #INCLUDE(InstallRequiredSystemLibraries)
415 ENDIF()
417 INCLUDE(CPack)
419 INCLUDE(CMakePackaging.txt)
421 ## Debian Packages
422 #INCLUDE(UseDebian)
423 #IF(DEBIAN_FOUND)
424 #  ADD_DEBIAN_TARGETS(nel)
425 #ENDIF()