1 # Force Release configuration for compiler checks
\r
2 SET(CMAKE_TRY_COMPILE_CONFIGURATION "Release")
\r
4 # Force Release configuration by default
\r
5 IF(NOT CMAKE_BUILD_TYPE)
\r
6 SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
\r
9 # Declare CMAKE_CONFIGURATION_TYPES before PROJECT
\r
10 SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
\r
13 # Helper macro that generates .pc and installs it.
\r
14 # Argument: name - the name of the .pc package, e.g. "nel-pacs.pc"
\r
16 MACRO(NL_GEN_PC name)
\r
17 IF(NOT WIN32 AND WITH_INSTALL_LIBRARIES)
\r
18 CONFIGURE_FILE(${name}.in "${CMAKE_CURRENT_BINARY_DIR}/${name}")
\r
19 INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${name}" DESTINATION ${NL_LIB_PREFIX}/pkgconfig)
\r
26 MACRO(NL_TARGET_LIB name)
\r
28 ADD_LIBRARY(${name} STATIC ${ARGN})
\r
30 ADD_LIBRARY(${name} SHARED ${ARGN})
\r
32 ENDMACRO(NL_TARGET_LIB)
\r
37 MACRO(NL_TARGET_DRIVER name)
\r
38 IF(WITH_STATIC_DRIVERS)
\r
39 ADD_LIBRARY(${name} STATIC ${ARGN})
\r
41 ADD_LIBRARY(${name} MODULE ${ARGN})
\r
43 ENDMACRO(NL_TARGET_DRIVER)
\r
46 # Helper macro that sets the default library properties.
\r
47 # Argument: name - the target name whose properties are being set
\r
50 MACRO(NL_DEFAULT_PROPS name label)
\r
52 # explicitly say that the target depends on revision.h
\r
53 ADD_DEPENDENCIES(${name} revision)
\r
56 # Note: This is just a workaround for a CMake bug generating VS10 files with a colon in the project name.
\r
57 # CMake Bug ID: http://www.cmake.org/Bug/view.php?id=11819
\r
58 STRING(REGEX REPLACE "\\:" " -" proj_label ${label})
\r
59 SET_TARGET_PROPERTIES(${name} PROPERTIES PROJECT_LABEL ${proj_label})
\r
60 GET_TARGET_PROPERTY(type ${name} TYPE)
\r
61 IF(${type} STREQUAL SHARED_LIBRARY)
\r
62 # Set versions only if target is a shared library
\r
63 SET_TARGET_PROPERTIES(${name} PROPERTIES
\r
64 VERSION ${NL_VERSION} SOVERSION ${NL_VERSION_MAJOR})
\r
66 SET_TARGET_PROPERTIES(${name} PROPERTIES INSTALL_NAME_DIR ${NL_LIB_PREFIX})
\r
70 IF(${type} STREQUAL EXECUTABLE AND WIN32 AND NOT MINGW)
\r
71 # check if using a GUI
\r
72 GET_TARGET_PROPERTY(_VALUE ${name} WIN32_EXECUTABLE)
\r
75 # Target Windows XP 64 bits
\r
76 SET(_SUBSYSTEM_VERSION "5.02")
\r
79 SET(_SUBSYSTEM_VERSION "5.01")
\r
84 SET(_SUBSYSTEM "WINDOWS")
\r
87 SET(_SUBSYSTEM "CONSOLE")
\r
90 SET_TARGET_PROPERTIES(${name} PROPERTIES
\r
91 VERSION ${NL_VERSION}
\r
92 SOVERSION ${NL_VERSION_MAJOR}
\r
94 LINK_FLAGS "/VERSION:${NL_VERSION_MAJOR}.${NL_VERSION_MINOR} /SUBSYSTEM:${_SUBSYSTEM},${_SUBSYSTEM_VERSION}")
\r
96 ENDMACRO(NL_DEFAULT_PROPS)
\r
99 # Adds the target suffix on Windows.
\r
100 # Argument: name - the library's target name.
\r
102 MACRO(NL_ADD_LIB_SUFFIX name)
\r
104 SET_TARGET_PROPERTIES(${name} PROPERTIES DEBUG_POSTFIX "_d" RELEASE_POSTFIX "_r")
\r
106 ENDMACRO(NL_ADD_LIB_SUFFIX)
\r
109 # Adds the runtime link flags for Win32 binaries and links STLport.
\r
110 # Argument: name - the target to add the link flags to.
\r
112 MACRO(NL_ADD_RUNTIME_FLAGS name)
\r
114 # SET_TARGET_PROPERTIES(${name} PROPERTIES
\r
115 # LINK_FLAGS_DEBUG "${CMAKE_LINK_FLAGS_DEBUG}"
\r
116 # LINK_FLAGS_RELEASE "${CMAKE_LINK_FLAGS_RELEASE}")
\r
119 TARGET_LINK_LIBRARIES(${name} ${STLPORT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
\r
121 ENDMACRO(NL_ADD_RUNTIME_FLAGS)
\r
123 MACRO(NL_ADD_STATIC_VID_DRIVERS name)
\r
126 SET(drv_suffix "_win")
\r
130 IF(WIN32 AND WITH_DRIVER_DIRECT3D)
\r
131 TARGET_LINK_LIBRARIES(${name} nel_drv_direct3d${drv_suffix})
\r
133 IF(WITH_DRIVER_OPENGL)
\r
134 TARGET_LINK_LIBRARIES(${name} nel_drv_opengl${drv_suffix})
\r
136 IF(WITH_DRIVER_OPENGLES)
\r
137 TARGET_LINK_LIBRARIES(${name} nel_drv_opengles${drv_suffix})
\r
140 IF(WITH_STATIC_DRIVERS)
\r
142 IF(WITH_DRIVER_DIRECT3D)
\r
143 TARGET_LINK_LIBRARIES(${name} nel_drv_direct3d_win)
\r
147 IF(WITH_DRIVER_OPENGL)
\r
149 TARGET_LINK_LIBRARIES(${name} nel_drv_opengl_win)
\r
151 TARGET_LINK_LIBRARIES(${name} nel_drv_opengl)
\r
155 IF(WITH_DRIVER_OPENGLES)
\r
157 TARGET_LINK_LIBRARIES(${name} nel_drv_opengles_win)
\r
159 TARGET_LINK_LIBRARIES(${name} nel_drv_opengles)
\r
164 ENDMACRO(NL_ADD_STATIC_VID_DRIVERS)
\r
166 MACRO(NL_ADD_STATIC_SND_DRIVERS name)
\r
169 SET(drv_suffix "_win")
\r
173 IF(WIN32 AND WITH_DRIVER_DSOUND)
\r
174 TARGET_LINK_LIBRARIES(${name} nel_drv_dsound${drv_suffix})
\r
176 IF(WIN32 AND WITH_DRIVER_XAUDIO2)
\r
177 TARGET_LINK_LIBRARIES(${name} nel_drv_xaudio2${drv_suffix})
\r
179 IF(WITH_DRIVER_FMOD)
\r
180 TARGET_LINK_LIBRARIES(${name} nel_drv_fmod${drv_suffix})
\r
182 IF(WITH_DRIVER_OPENAL)
\r
183 TARGET_LINK_LIBRARIES(${name} nel_drv_openal${drv_suffix})
\r
186 IF(WITH_STATIC_DRIVERS)
\r
188 IF(WITH_DRIVER_DSOUND)
\r
189 TARGET_LINK_LIBRARIES(${name} nel_drv_dsound_win)
\r
192 IF(WITH_DRIVER_XAUDIO2)
\r
193 TARGET_LINK_LIBRARIES(${name} nel_drv_xaudio2_win)
\r
196 IF(WITH_DRIVER_OPENAL)
\r
197 TARGET_LINK_LIBRARIES(${name} nel_drv_openal_win)
\r
200 IF(WITH_DRIVER_FMOD)
\r
201 TARGET_LINK_LIBRARIES(${name} nel_drv_fmod_win)
\r
204 IF(WITH_DRIVER_OPENAL)
\r
205 TARGET_LINK_LIBRARIES(${name} nel_drv_openal)
\r
208 IF(WITH_DRIVER_FMOD)
\r
209 TARGET_LINK_LIBRARIES(${name} nel_drv_fmod)
\r
215 ENDMACRO(NL_ADD_STATIC_SND_DRIVERS)
\r
218 # Checks build vs. source location. Prevents In-Source builds.
\r
220 MACRO(CHECK_OUT_OF_SOURCE)
\r
221 IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
\r
222 MESSAGE(FATAL_ERROR "
\r
224 CMake generation for this project is not allowed within the source directory!
\r
225 Remove the CMakeCache.txt file and try again from another folder, e.g.:
\r
234 ENDMACRO(CHECK_OUT_OF_SOURCE)
\r
236 MACRO(NL_SETUP_DEFAULT_OPTIONS)
\r
238 OPTION(WITH_STUDIO "Build Core Studio" OFF )
\r
244 OPTION(WITH_LOGGING "With Logging" ON )
\r
245 OPTION(WITH_COVERAGE "With Code Coverage Support" OFF)
\r
246 OPTION(WITH_PCH "With Precompiled Headers" ON )
\r
247 OPTION(WITH_LOW_MEMORY "With low memory (use the least of RAM)" OFF)
\r
248 OPTION(FINAL_VERSION "Build in Final Version mode" ON )
\r
250 # Default to static building on Windows.
\r
252 OPTION(WITH_STATIC "With static libraries." ON )
\r
254 OPTION(WITH_STATIC "With static libraries." OFF)
\r
257 OPTION(WITH_STATIC_LIBXML2 "With static libxml2" ON )
\r
259 OPTION(WITH_STATIC_LIBXML2 "With static libxml2" OFF)
\r
262 OPTION(WITH_STATIC_CURL "With static curl" ON )
\r
264 OPTION(WITH_STATIC_CURL "With static curl" OFF)
\r
267 OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" ON )
\r
269 OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" OFF)
\r
271 OPTION(WITH_STATIC_DRIVERS "With static drivers." OFF)
\r
273 OPTION(WITH_EXTERNAL "With provided external." ON )
\r
275 OPTION(WITH_EXTERNAL "With provided external." OFF)
\r
277 OPTION(WITH_STATIC_EXTERNAL "With static external libraries" OFF)
\r
278 OPTION(WITH_STATIC_RUNTIMES "Use only static C++ runtimes" OFF)
\r
279 IF(UNIX AND NOT APPLE)
\r
280 OPTION(WITH_UNIX_STRUCTURE "Use UNIX structure (bin, include, lib)" ON )
\r
282 OPTION(WITH_UNIX_STRUCTURE "Use UNIX structure (bin, include, lib)" OFF)
\r
284 OPTION(WITH_INSTALL_LIBRARIES "Install development files." ON )
\r
286 OPTION(WITH_ASSIMP "Use assimp exporter" OFF)
\r
287 OPTION(WITH_LIBGSF "Use libgsf for max file library" OFF)
\r
289 OPTION(WITH_FFMPEG "Use ffmpeg for audio decoder" OFF)
\r
294 OPTION(WITH_GTK "With GTK Support" OFF)
\r
295 OPTION(WITH_QT "With Qt 4 Support" OFF)
\r
296 OPTION(WITH_QT5 "With Qt 5 Support" OFF)
\r
298 IF(WIN32 AND MFC_FOUND)
\r
299 OPTION(WITH_MFC "With MFC Support" ON )
\r
301 OPTION(WITH_MFC "With MFC Support" OFF)
\r
307 OPTION(WITH_SYMBOLS "Keep debug symbols in binaries" OFF)
\r
309 # only enable STLport for VC++ 2010 and less
\r
310 IF(WIN32 AND MSVC_VERSION LESS 1600)
\r
311 OPTION(WITH_STLPORT "With STLport support." ON )
\r
313 OPTION(WITH_STLPORT "With STLport support." OFF)
\r
316 OPTION(BUILD_DASHBOARD "Build to the CDash dashboard" OFF)
\r
318 OPTION(WITH_NEL "Build NeL (nearly always required)." ON )
\r
319 OPTION(WITH_NELNS "Build NeL Network Services." OFF)
\r
320 OPTION(WITH_RYZOM "Build Ryzom Core." ON )
\r
321 OPTION(WITH_RYZOM_GAMESHARE "Build Ryzom GameShare library." ON )
\r
322 OPTION(WITH_SNOWBALLS "Build Snowballs." OFF)
\r
323 OPTION(WITH_TOOLS "Build Tools" OFF)
\r
325 OPTION(WITH_RYZOM_LIVE "Use ryzom.com urls" ON)
\r
327 OPTION(WITH_MONGODB "Compile server with MongoDB support" ON)
\r
328 OPTION(WITH_PATCHMAN_SERVICE "Compile Ryzom server patchman service" OFF)
\r
329 ENDMACRO(NL_SETUP_DEFAULT_OPTIONS)
\r
331 MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)
\r
335 OPTION(WITH_NET "Build NLNET" ON )
\r
336 OPTION(WITH_3D "Build NL3D" ON )
\r
337 OPTION(WITH_WEB "Build WEB" ON )
\r
338 OPTION(WITH_GUI "Build GUI" ON )
\r
339 OPTION(WITH_PACS "Build NLPACS" ON )
\r
340 OPTION(WITH_GEORGES "Build NLGEORGES" ON )
\r
341 OPTION(WITH_LIGO "Build NLLIGO" ON )
\r
342 OPTION(WITH_LOGIC "Build NLLOGIC" ON )
\r
343 OPTION(WITH_SOUND "Build NLSOUND" ON )
\r
348 OPTION(WITH_DRIVER_OPENGL "Build OpenGL Driver (3D)" ON )
\r
349 OPTION(WITH_DRIVER_OPENGLES "Build OpenGL ES Driver (3D)" OFF)
\r
350 OPTION(WITH_DRIVER_DIRECT3D "Build Direct3D Driver (3D)" OFF)
\r
351 OPTION(WITH_DRIVER_OPENAL "Build OpenAL Driver (Sound)" ON )
\r
352 OPTION(WITH_DRIVER_FMOD "Build FMOD Driver (Sound)" OFF)
\r
353 OPTION(WITH_DRIVER_DSOUND "Build DirectSound Driver (Sound)" OFF)
\r
354 OPTION(WITH_DRIVER_XAUDIO2 "Build XAudio2 Driver (Sound)" OFF)
\r
359 OPTION(WITH_NEL_CEGUI "Build CEGUI Renderer" OFF)
\r
360 OPTION(WITH_NEL_TOOLS "Build NeL Tools" ON )
\r
361 OPTION(WITH_NEL_MAXPLUGIN "Build NeL 3dsMax Plugin" OFF)
\r
362 OPTION(WITH_NEL_SAMPLES "Build NeL Samples" ON )
\r
363 OPTION(WITH_NEL_TESTS "Build NeL Unit Tests" ON )
\r
365 OPTION(WITH_LIBOVR "With LibOVR support" OFF)
\r
366 OPTION(WITH_LIBVR "With LibVR support" OFF)
\r
367 OPTION(WITH_PERFHUD "With NVIDIA PerfHUD support" OFF)
\r
369 OPTION(WITH_SSE2 "With SSE2" ON )
\r
370 OPTION(WITH_SSE3 "With SSE3" ON )
\r
372 OPTION(WITH_XRANDR "With XRandR extension" ON )
\r
375 OPTION(WITH_GCC_FPMATH_BOTH "With GCC -mfpmath=both" OFF)
\r
377 ENDMACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)
\r
379 MACRO(NL_SETUP_NELNS_DEFAULT_OPTIONS)
\r
383 OPTION(WITH_NELNS_SERVER "Build NeLNS Services" ON )
\r
384 OPTION(WITH_NELNS_LOGIN_SYSTEM "Build NeLNS Login System Tools" ON )
\r
385 ENDMACRO(NL_SETUP_NELNS_DEFAULT_OPTIONS)
\r
387 MACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS)
\r
391 OPTION(WITH_RYZOM_CLIENT "Build Ryzom Core Client" ON )
\r
392 OPTION(WITH_RYZOM_TOOLS "Build Ryzom Core Tools" ON )
\r
393 OPTION(WITH_RYZOM_SERVER "Build Ryzom Core Services" ON )
\r
394 OPTION(WITH_RYZOM_INSTALLER "Build Ryzom Installer" OFF)
\r
399 OPTION(WITH_LUA51 "Build Ryzom Core using Lua 5.1" ON )
\r
400 OPTION(WITH_LUA52 "Build Ryzom Core using Lua 5.2" OFF)
\r
401 OPTION(WITH_LUA53 "Build Ryzom Core using Lua 5.3" OFF)
\r
402 OPTION(WITH_RYZOM_CLIENT_UAC "Ask to run as Administrator" OFF)
\r
403 OPTION(WITH_RYZOM_PATCH "Enable Ryzom in-game patch support" OFF)
\r
404 OPTION(WITH_RYZOM_CUSTOM_PATCH_SERVER "Only use patch server from CFG file" OFF)
\r
405 OPTION(WITH_RYZOM_STEAM "Enable Steam features" OFF)
\r
406 OPTION(WITH_RYZOM_SANDBOX "Enable Sandbox under OS X" OFF)
\r
407 ENDMACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS)
\r
409 MACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS)
\r
413 OPTION(WITH_SNOWBALLS_CLIENT "Build Snowballs Client" ON )
\r
414 OPTION(WITH_SNOWBALLS_SERVER "Build Snowballs Services" ON )
\r
415 ENDMACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS)
\r
417 MACRO(ADD_PLATFORM_FLAGS _FLAGS)
\r
418 SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} ${_FLAGS}")
\r
419 SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} ${_FLAGS}")
\r
422 MACRO(ADD_PLATFORM_LINKFLAGS _FLAGS)
\r
423 SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${_FLAGS}")
\r
426 MACRO(CONVERT_VERSION_NUMBER _VERSION_NUMBER _BASE)
\r
427 SET(${_VERSION_NUMBER} 0)
\r
428 FOREACH(_ARG ${ARGN})
\r
429 MATH(EXPR ${_VERSION_NUMBER} "${${_VERSION_NUMBER}} * ${_BASE} + ${_ARG}")
\r
433 MACRO(NL_SETUP_BUILD)
\r
434 #-----------------------------------------------------------------------------
\r
435 # Setup the buildmode variables.
\r
437 # None = NL_RELEASE
\r
439 # Release = NL_RELEASE
\r
441 IF(CMAKE_BUILD_TYPE MATCHES "Debug")
\r
442 SET(NL_BUILD_MODE "NL_DEBUG")
\r
444 IF(CMAKE_BUILD_TYPE MATCHES "Release")
\r
445 SET(NL_BUILD_MODE "NL_RELEASE")
\r
447 SET(NL_BUILD_MODE "NL_RELEASE")
\r
448 # enforce release mode if it's neither Debug nor Release
\r
449 SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
\r
453 IF(CMAKE_CXX_LIBRARY_ARCHITECTURE)
\r
454 SET(HOST_CPU ${CMAKE_CXX_LIBRARY_ARCHITECTURE})
\r
456 SET(HOST_CPU ${CMAKE_HOST_SYSTEM_PROCESSOR})
\r
459 IF(HOST_CPU MATCHES "(amd|AMD|x86_)64")
\r
460 SET(HOST_CPU "x86_64")
\r
461 ELSEIF(HOST_CPU MATCHES "i.86")
\r
462 SET(HOST_CPU "x86")
\r
465 # Determine target CPU
\r
467 # If not specified, use the same CPU as host
\r
469 SET(TARGET_CPU ${HOST_CPU})
\r
472 IF(TARGET_CPU MATCHES "(amd|AMD|x86_)64")
\r
473 SET(TARGET_CPU "x86_64")
\r
474 ELSEIF(TARGET_CPU MATCHES "i.86")
\r
475 SET(TARGET_CPU "x86")
\r
478 IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
\r
480 MESSAGE(STATUS "Using Clang ${CMAKE_CXX_COMPILER_VERSION} compiler")
\r
483 IF(CMAKE_GENERATOR MATCHES "Xcode")
\r
485 MESSAGE(STATUS "Generating Xcode project")
\r
488 IF(CMAKE_GENERATOR MATCHES "NMake")
\r
490 MESSAGE(STATUS "Generating NMake project")
\r
493 IF(CMAKE_GENERATOR MATCHES "Ninja")
\r
495 MESSAGE(STATUS "Generating Ninja project")
\r
498 # If target and host CPU are the same
\r
499 IF("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING)
\r
500 # x86-compatible CPU
\r
501 IF(HOST_CPU MATCHES "x86")
\r
502 IF(NOT CMAKE_SIZEOF_VOID_P)
\r
503 INCLUDE (CheckTypeSize)
\r
504 CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P)
\r
507 # Using 32 or 64 bits libraries
\r
508 IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
\r
509 SET(TARGET_CPU "x86_64")
\r
511 SET(TARGET_CPU "x86")
\r
513 ELSEIF(HOST_CPU MATCHES "arm")
\r
514 SET(TARGET_CPU "arm")
\r
516 SET(TARGET_CPU "unknown")
\r
517 MESSAGE(STATUS "Unknown architecture: ${HOST_CPU}")
\r
519 # TODO: add checks for PPC
\r
521 MESSAGE(STATUS "Compiling on ${HOST_CPU} for ${TARGET_CPU}")
\r
524 # Use values from environment variables
\r
525 SET(PLATFORM_CFLAGS "$ENV{CFLAGS} $ENV{CPPFLAGS} ${PLATFORM_CFLAGS}")
\r
526 SET(PLATFORM_CXXFLAGS "$ENV{CXXFLAGS} $ENV{CPPFLAGS} ${PLATFORM_CXXFLAGS}")
\r
527 SET(PLATFORM_LINKFLAGS "$ENV{LDFLAGS} ${PLATFORM_LINKFLAGS}")
\r
529 # Remove -g and -O flag because we are managing them ourself
\r
530 STRING(REPLACE "-g" "" PLATFORM_CFLAGS ${PLATFORM_CFLAGS})
\r
531 STRING(REPLACE "-g" "" PLATFORM_CXXFLAGS ${PLATFORM_CXXFLAGS})
\r
532 STRING(REGEX REPLACE "-O[0-9s]" "" PLATFORM_CFLAGS ${PLATFORM_CFLAGS})
\r
533 STRING(REGEX REPLACE "-O[0-9s]" "" PLATFORM_CXXFLAGS ${PLATFORM_CXXFLAGS})
\r
536 STRING(STRIP ${PLATFORM_CFLAGS} PLATFORM_CFLAGS)
\r
537 STRING(STRIP ${PLATFORM_CXXFLAGS} PLATFORM_CXXFLAGS)
\r
538 STRING(STRIP ${PLATFORM_LINKFLAGS} PLATFORM_LINKFLAGS)
\r
540 IF(NOT CMAKE_OSX_ARCHITECTURES)
\r
541 IF(TARGET_CPU STREQUAL "x86_64")
\r
544 ELSEIF(TARGET_CPU STREQUAL "x86")
\r
546 ELSEIF(TARGET_CPU STREQUAL "arm64")
\r
548 SET(TARGET_ARM64 1)
\r
549 ELSEIF(TARGET_CPU STREQUAL "armv7s")
\r
551 SET(TARGET_ARMV7S 1)
\r
552 ELSEIF(TARGET_CPU STREQUAL "armv7")
\r
554 SET(TARGET_ARMV7 1)
\r
555 ELSEIF(TARGET_CPU STREQUAL "armv6")
\r
557 SET(TARGET_ARMV6 1)
\r
558 ELSEIF(TARGET_CPU STREQUAL "armv5")
\r
560 SET(TARGET_ARMV5 1)
\r
561 ELSEIF(TARGET_CPU STREQUAL "arm")
\r
563 ELSEIF(TARGET_CPU STREQUAL "mips")
\r
569 ADD_PLATFORM_FLAGS("-DHAVE_ARM64")
\r
573 ADD_PLATFORM_FLAGS("-DHAVE_ARMV7S")
\r
577 ADD_PLATFORM_FLAGS("-DHAVE_ARMV7")
\r
581 ADD_PLATFORM_FLAGS("-HAVE_ARMV6")
\r
584 ADD_PLATFORM_FLAGS("-DHAVE_ARM")
\r
588 ADD_PLATFORM_FLAGS("-DHAVE_X86")
\r
592 ADD_PLATFORM_FLAGS("-DHAVE_X64 -DHAVE_X86_64")
\r
596 ADD_PLATFORM_FLAGS("-DHAVE_MIPS")
\r
600 # Fix library paths suffixes for Debian MultiArch
\r
601 IF(LIBRARY_ARCHITECTURE)
\r
602 SET(CMAKE_LIBRARY_PATH /lib/${LIBRARY_ARCHITECTURE} /usr/lib/${LIBRARY_ARCHITECTURE} ${CMAKE_LIBRARY_PATH})
\r
604 SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib64 /usr/lib64)
\r
606 SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib32 /usr/lib32)
\r
610 IF(APPLE AND NOT IOS)
\r
611 SET(CMAKE_INCLUDE_PATH /opt/local/include ${CMAKE_INCLUDE_PATH})
\r
612 SET(CMAKE_LIBRARY_PATH /opt/local/lib ${CMAKE_LIBRARY_PATH})
\r
616 ADD_PLATFORM_FLAGS("-DENABLE_LOGS")
\r
619 SET(CUSTOM_FLAGS "" CACHE STRING "Custom compile flags (useful for /MPn)")
\r
620 IF(NOT ${CUSTOM_FLAGS} STREQUAL "")
\r
621 ADD_PLATFORM_FLAGS(${CUSTOM_FLAGS})
\r
625 # Ignore default include paths
\r
626 ADD_PLATFORM_FLAGS("/X")
\r
629 ADD_PLATFORM_FLAGS("/Gy-")
\r
630 # /Ox is working with VC++ 2015 and 2017, but custom optimizations don't exist
\r
631 SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
\r
632 # without inlining it's unusable, use custom optimizations again
\r
633 SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
\r
635 # Special cases for VC++ 2017
\r
636 IF(MSVC_VERSION EQUAL "1911")
\r
638 ELSEIF(MSVC_VERSION EQUAL "1910")
\r
642 ADD_PLATFORM_FLAGS("/Gy-")
\r
643 # /Ox is working with VC++ 2013, but custom optimizations don't exist
\r
644 SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
\r
645 # without inlining it's unusable, use custom optimizations again
\r
646 SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
\r
648 ADD_PLATFORM_FLAGS("/Gy-")
\r
649 # /Ox is working with VC++ 2012, but custom optimizations don't exist
\r
650 SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
\r
651 # without inlining it's unusable, use custom optimizations again
\r
652 SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
\r
654 ADD_PLATFORM_FLAGS("/Gy-")
\r
655 # /Ox is working with VC++ 2010, but custom optimizations don't exist
\r
656 SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
\r
657 # without inlining it's unusable, use custom optimizations again
\r
658 SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
\r
660 ADD_PLATFORM_FLAGS("/Gy-")
\r
661 # don't use a /O[012x] flag if you want custom optimizations
\r
662 SET(RELEASE_CFLAGS "/Ob2 /Oi /Ot /Oy /GT /GF /GS- ${RELEASE_CFLAGS}")
\r
663 # without inlining it's unusable, use custom optimizations again
\r
664 SET(DEBUG_CFLAGS "/Ob1 /GF- ${DEBUG_CFLAGS}")
\r
666 ADD_PLATFORM_FLAGS("/Gy- /Wp64")
\r
667 # don't use a /O[012x] flag if you want custom optimizations
\r
668 SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
\r
669 # without inlining it's unusable, use custom optimizations again
\r
670 SET(DEBUG_CFLAGS "/Od /Ob1 ${DEBUG_CFLAGS}")
\r
672 MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}")
\r
675 ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /D_WIN32 /DWIN32 /D_WINDOWS /wd4250")
\r
678 ADD_PLATFORM_FLAGS("/Zm1000")
\r
681 # Fix a bug with Intellisense
\r
682 ADD_PLATFORM_FLAGS("/D_WIN64")
\r
683 # Fix a compilation error for some big C++ files
\r
684 ADD_PLATFORM_FLAGS("/bigobj")
\r
686 # Allows 32 bits applications to use 3 GB of RAM
\r
687 ADD_PLATFORM_LINKFLAGS("/LARGEADDRESSAWARE")
\r
690 # Exceptions are only set for C++
\r
691 SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} /EHa")
\r
694 SET(NL_RELEASE_CFLAGS "/Zi ${NL_RELEASE_CFLAGS}")
\r
695 SET(NL_RELEASE_LINKFLAGS "/DEBUG ${NL_RELEASE_LINKFLAGS}")
\r
697 SET(NL_RELEASE_LINKFLAGS "/RELEASE ${NL_RELEASE_LINKFLAGS}")
\r
700 IF(WITH_STATIC_RUNTIMES)
\r
701 SET(RUNTIME_FLAG "/MT")
\r
703 SET(RUNTIME_FLAG "/MD")
\r
706 SET(NL_DEBUG_CFLAGS "/Zi ${RUNTIME_FLAG}d /RTC1 /D_DEBUG ${DEBUG_CFLAGS} ${NL_DEBUG_CFLAGS}")
\r
707 SET(NL_RELEASE_CFLAGS "${RUNTIME_FLAG} /DNDEBUG ${RELEASE_CFLAGS} ${NL_RELEASE_CFLAGS}")
\r
708 SET(NL_DEBUG_LINKFLAGS "/DEBUG /OPT:NOREF /OPT:NOICF /NODEFAULTLIB:msvcrt ${MSVC_INCREMENTAL_YES_FLAG} ${NL_DEBUG_LINKFLAGS}")
\r
709 SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO ${NL_RELEASE_LINKFLAGS}")
\r
712 SET(DEBUG_CFLAGS "/W4 ${DEBUG_CFLAGS}")
\r
714 SET(DEBUG_CFLAGS "/W3 ${DEBUG_CFLAGS}")
\r
718 ADD_PLATFORM_FLAGS("-DWIN32 -D_WIN32")
\r
721 ADD_PLATFORM_FLAGS("-nobuiltininc")
\r
726 ADD_PLATFORM_FLAGS("-msse3")
\r
729 IF(WITH_GCC_FPMATH_BOTH)
\r
730 ADD_PLATFORM_FLAGS("-mfpmath=both")
\r
734 SET(OBJC_FLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch -fobjc-weak)
\r
737 IF(CMAKE_OSX_ARCHITECTURES)
\r
738 SET(TARGETS_COUNT 0)
\r
740 FOREACH(_ARCH ${CMAKE_OSX_ARCHITECTURES})
\r
741 IF(_ARCH STREQUAL "i386")
\r
742 SET(_ARCHS "${_ARCHS} i386")
\r
744 MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
\r
745 ELSEIF(_ARCH STREQUAL "x86_64")
\r
746 SET(_ARCHS "${_ARCHS} x86_64")
\r
748 MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
\r
749 ELSEIF(_ARCH STREQUAL "armv7s")
\r
750 SET(_ARCHS "${_ARCHS} armv7s")
\r
751 SET(TARGET_ARMV7S 1)
\r
753 MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
\r
754 ELSEIF(_ARCH STREQUAL "armv7")
\r
755 SET(_ARCHS "${_ARCHS} armv7")
\r
756 SET(TARGET_ARMV7 1)
\r
758 MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
\r
759 ELSEIF(_ARCH STREQUAL "armv6")
\r
760 SET(_ARCHS "${_ARCHS} armv6")
\r
761 SET(TARGET_ARMV6 1)
\r
763 MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
\r
764 ELSEIF(_ARCH STREQUAL "mips")
\r
765 SET(_ARCHS "${_ARCHS} mips")
\r
767 MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
\r
769 SET(_ARCHS "${_ARCHS} unknwon(${_ARCH})")
\r
772 MESSAGE(STATUS "Compiling under Mac OS X for ${TARGETS_COUNT} architectures: ${_ARCHS}")
\r
774 SET(TARGETS_COUNT 0)
\r
777 IF(TARGETS_COUNT EQUAL 1)
\r
780 ADD_PLATFORM_FLAGS("-arch armv7s -DHAVE_ARMV7S")
\r
784 ADD_PLATFORM_FLAGS("-arch armv7 -DHAVE_ARMV7")
\r
788 ADD_PLATFORM_FLAGS("-arch armv6 -DHAVE_ARMV6")
\r
792 ADD_PLATFORM_FLAGS("-arch armv5 -DHAVE_ARMV5")
\r
795 ADD_PLATFORM_FLAGS("-mthumb -DHAVE_ARM")
\r
799 ADD_PLATFORM_FLAGS("-arch x86_64 -DHAVE_X64 -DHAVE_X86_64 -DHAVE_X86")
\r
801 ADD_PLATFORM_FLAGS("-arch i386 -DHAVE_X86")
\r
805 ADD_PLATFORM_FLAGS("-arch mips -DHAVE_MIPS")
\r
807 ELSEIF(TARGETS_COUNT EQUAL 0)
\r
808 # Not using CMAKE_OSX_ARCHITECTURES, HAVE_XXX already defined before
\r
811 ADD_PLATFORM_FLAGS("-arch armv7s")
\r
815 ADD_PLATFORM_FLAGS("-arch armv7")
\r
819 ADD_PLATFORM_FLAGS("-arch armv6")
\r
823 ADD_PLATFORM_FLAGS("-arch armv5")
\r
826 ADD_PLATFORM_FLAGS("-mthumb")
\r
830 ADD_PLATFORM_FLAGS("-arch x86_64")
\r
832 ADD_PLATFORM_FLAGS("-arch i386")
\r
836 ADD_PLATFORM_FLAGS("-arch mips")
\r
840 ADD_PLATFORM_FLAGS("-Xarch_armv6 -mthumb -Xarch_armv6 -DHAVE_ARM -Xarch_armv6 -DHAVE_ARMV6")
\r
844 ADD_PLATFORM_FLAGS("-Xarch_armv7 -mthumb -Xarch_armv7 -DHAVE_ARM -Xarch_armv7 -DHAVE_ARMV7")
\r
848 ADD_PLATFORM_FLAGS("-Xarch_i386 -DHAVE_X86")
\r
852 ADD_PLATFORM_FLAGS("-Xarch_x86_64 -DHAVE_X64 -Xarch_x86_64 -DHAVE_X86_64")
\r
856 ADD_PLATFORM_FLAGS("-Xarch_mips -DHAVE_MIPS")
\r
861 SET(CMAKE_OSX_SYSROOT "" CACHE PATH "" FORCE)
\r
864 PARSE_VERSION_STRING(${IOS_VERSION} IOS_VERSION_MAJOR IOS_VERSION_MINOR IOS_VERSION_PATCH)
\r
865 CONVERT_VERSION_NUMBER(${IOS_VERSION_MAJOR} ${IOS_VERSION_MINOR} ${IOS_VERSION_PATCH} IOS_VERSION_NUMBER)
\r
867 ADD_PLATFORM_FLAGS("-D__IPHONE_OS_VERSION_MIN_REQUIRED=${IOS_VERSION_NUMBER}")
\r
870 IF(CMAKE_IOS_SYSROOT)
\r
872 IF(TARGETS_COUNT GREATER 1)
\r
873 SET(XARCH "-Xarch_armv7s ")
\r
876 ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}")
\r
877 ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}")
\r
878 ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}")
\r
882 IF(TARGETS_COUNT GREATER 1)
\r
883 SET(XARCH "-Xarch_armv7 ")
\r
886 ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}")
\r
887 ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}")
\r
888 ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}")
\r
892 IF(TARGETS_COUNT GREATER 1)
\r
893 SET(XARCH "-Xarch_armv6 ")
\r
896 ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}")
\r
897 ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}")
\r
898 ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}")
\r
902 IF(CMAKE_IOS_SIMULATOR_SYSROOT AND TARGET_X86)
\r
903 IF(TARGETS_COUNT GREATER 1)
\r
904 SET(XARCH "-Xarch_i386 ")
\r
907 ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SIMULATOR_SYSROOT}")
\r
908 ADD_PLATFORM_FLAGS("${XARCH}-mios-simulator-version-min=${IOS_VERSION}")
\r
909 IF(CMAKE_OSX_DEPLOYMENT_TARGET)
\r
910 ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}")
\r
914 # Always force -mmacosx-version-min to override environement variable
\r
915 IF(CMAKE_OSX_DEPLOYMENT_TARGET)
\r
916 IF(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "10.7")
\r
917 MESSAGE(FATAL_ERROR "Minimum target for OS X is 10.7 but you're using ${CMAKE_OSX_DEPLOYMENT_TARGET}")
\r
919 ADD_PLATFORM_LINKFLAGS("-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}")
\r
923 # use libc++ under OX X to be able to use new C++ features (and else it'll use GCC 4.2.1 STL)
\r
924 # minimum target is now OS X 10.7
\r
925 SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -stdlib=libc++")
\r
927 ADD_PLATFORM_LINKFLAGS("-Wl,-headerpad_max_install_names")
\r
929 IF(HAVE_FLAG_SEARCH_PATHS_FIRST)
\r
930 ADD_PLATFORM_LINKFLAGS("-Wl,-search_paths_first")
\r
934 IF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86")
\r
935 ADD_PLATFORM_FLAGS("-m32 -march=i686")
\r
938 IF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64")
\r
939 ADD_PLATFORM_FLAGS("-m64")
\r
943 # use c++0x standard to use std::unique_ptr and std::shared_ptr
\r
944 IF(CMAKE_CXX11_EXTENSION_COMPILE_OPTION)
\r
945 SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} ${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}")
\r
948 ADD_PLATFORM_FLAGS("-D_REENTRANT")
\r
951 ADD_PLATFORM_FLAGS("-D_FORTIFY_SOURCE=2")
\r
953 IF(NOT WITH_LOW_MEMORY)
\r
954 ADD_PLATFORM_FLAGS("-pipe")
\r
958 ADD_PLATFORM_FLAGS("-fprofile-arcs -ftest-coverage")
\r
962 ADD_PLATFORM_FLAGS("-Wall")
\r
964 # Check wrong formats in printf-like functions
\r
965 ADD_PLATFORM_FLAGS("-Wformat -Werror=format-security")
\r
968 # never display these warnings because they are minor
\r
969 ADD_PLATFORM_FLAGS("-Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-value")
\r
971 IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "6.0.0")
\r
972 ADD_PLATFORM_FLAGS("-Wno-unused-local-typedefs")
\r
974 ADD_PLATFORM_FLAGS("-Wno-unused-private-field -Wno-unused-local-typedef")
\r
978 ADD_PLATFORM_FLAGS("--sysroot=${PLATFORM_ROOT}")
\r
979 ADD_PLATFORM_FLAGS("-ffunction-sections -funwind-tables")
\r
980 ADD_PLATFORM_FLAGS("-DANDROID")
\r
981 ADD_PLATFORM_FLAGS("-Wa,--noexecstack")
\r
984 ADD_PLATFORM_FLAGS("-fpic")
\r
985 ADD_PLATFORM_FLAGS("-D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__")
\r
988 ADD_PLATFORM_FLAGS("-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16")
\r
989 ADD_PLATFORM_LINKFLAGS("-march=armv7-a -Wl,--fix-cortex-a8")
\r
990 ELSEIF(TARGET_ARMV5)
\r
991 ADD_PLATFORM_FLAGS("-march=armv5te -mtune=xscale -msoft-float")
\r
994 SET(TARGET_THUMB ON)
\r
996 ADD_PLATFORM_FLAGS("-mthumb -finline-limit=64")
\r
997 SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -marm")
\r
999 ADD_PLATFORM_FLAGS("-funswitch-loops -finline-limit=300")
\r
1001 ELSEIF(TARGET_X86)
\r
1002 # Optimizations for Intel Atom
\r
1003 ADD_PLATFORM_FLAGS("-march=i686 -mtune=atom -mstackrealign -msse3 -mfpmath=sse -m32 -flto -ffast-math -funroll-loops")
\r
1004 ADD_PLATFORM_FLAGS("-funswitch-loops -finline-limit=300")
\r
1005 ELSEIF(TARGET_MIPS)
\r
1006 ADD_PLATFORM_FLAGS("-fpic -finline-functions -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers")
\r
1007 SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -funswitch-loops -finline-limit=300")
\r
1009 ADD_PLATFORM_LINKFLAGS("-Wl,-z,noexecstack")
\r
1010 ADD_PLATFORM_LINKFLAGS("-L${PLATFORM_ROOT}/usr/lib")
\r
1014 ADD_PLATFORM_FLAGS("-gdwarf-2 -D_DARWIN_UNLIMITED_STREAMS")
\r
1017 # Fix "relocation R_X86_64_32 against.." error on x64 platforms
\r
1019 ADD_PLATFORM_FLAGS("-fPIC")
\r
1023 ADD_PLATFORM_FLAGS("-fstack-protector --param=ssp-buffer-size=4")
\r
1025 # If -fstack-protector or -fstack-protector-all enabled, enable too new warnings and fix possible link problems
\r
1027 ADD_PLATFORM_FLAGS("-Wstack-protector")
\r
1030 # Fix undefined reference to `__stack_chk_fail' error
\r
1031 ADD_PLATFORM_LINKFLAGS("-lc")
\r
1034 ADD_PLATFORM_LINKFLAGS("-Wl,--no-undefined -Wl,--as-needed")
\r
1036 IF(WITH_STATIC_RUNTIMES)
\r
1037 ADD_PLATFORM_LINKFLAGS("-static-libstdc++")
\r
1043 ADD_PLATFORM_LINKFLAGS("-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now")
\r
1047 SET(NL_RELEASE_CFLAGS "${NL_RELEASE_CFLAGS} -g")
\r
1050 SET(NL_RELEASE_LINKFLAGS "-Wl,-dead_strip ${NL_RELEASE_LINKFLAGS}")
\r
1052 SET(NL_RELEASE_LINKFLAGS "-Wl,-s ${NL_RELEASE_LINKFLAGS}")
\r
1056 SET(NL_DEBUG_CFLAGS "-g -DNL_DEBUG -D_DEBUG ${NL_DEBUG_CFLAGS}")
\r
1057 SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -DNDEBUG -O3 ${NL_RELEASE_CFLAGS}")
\r
1061 MACRO(NL_SETUP_BUILD_FLAGS)
\r
1062 SET(CMAKE_C_FLAGS ${PLATFORM_CFLAGS} CACHE STRING "" FORCE)
\r
1063 SET(CMAKE_CXX_FLAGS ${PLATFORM_CXXFLAGS} CACHE STRING "" FORCE)
\r
1064 SET(CMAKE_EXE_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE)
\r
1065 SET(CMAKE_MODULE_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE)
\r
1066 SET(CMAKE_SHARED_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE)
\r
1069 SET(CMAKE_C_FLAGS_DEBUG ${NL_DEBUG_CFLAGS} CACHE STRING "" FORCE)
\r
1070 SET(CMAKE_CXX_FLAGS_DEBUG ${NL_DEBUG_CFLAGS} CACHE STRING "" FORCE)
\r
1071 SET(CMAKE_EXE_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE)
\r
1072 SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE)
\r
1073 SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE)
\r
1076 SET(CMAKE_C_FLAGS_RELEASE ${NL_RELEASE_CFLAGS} CACHE STRING "" FORCE)
\r
1077 SET(CMAKE_CXX_FLAGS_RELEASE ${NL_RELEASE_CFLAGS} CACHE STRING "" FORCE)
\r
1078 SET(CMAKE_EXE_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE)
\r
1079 SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE)
\r
1080 SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE)
\r
1081 ENDMACRO(NL_SETUP_BUILD_FLAGS)
\r
1083 # Macro to create x_ABSOLUTE_PREFIX from x_PREFIX
\r
1084 MACRO(NL_MAKE_ABSOLUTE_PREFIX NAME_RELATIVE NAME_ABSOLUTE)
\r
1085 IF(IS_ABSOLUTE "${${NAME_RELATIVE}}")
\r
1086 SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}})
\r
1088 IF(WITH_UNIX_STRUCTURE)
\r
1089 SET(${NAME_ABSOLUTE} ${CMAKE_INSTALL_PREFIX}/${${NAME_RELATIVE}})
\r
1091 SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}})
\r
1094 ENDMACRO(NL_MAKE_ABSOLUTE_PREFIX)
\r
1096 MACRO(NL_SETUP_PREFIX_PATHS)
\r
1097 IF(TARGET_X64 AND WIN32)
\r
1098 SET(LIB_SUFFIX "64")
\r
1100 SET(LIB_SUFFIX "")
\r
1103 ## Allow override of install_prefix/etc path.
\r
1104 IF(NOT NL_ETC_PREFIX)
\r
1105 IF(WITH_UNIX_STRUCTURE)
\r
1106 SET(NL_ETC_PREFIX "etc/nel" CACHE PATH "Installation path for configurations")
\r
1108 SET(NL_ETC_PREFIX "." CACHE PATH "Installation path for configurations")
\r
1111 NL_MAKE_ABSOLUTE_PREFIX(NL_ETC_PREFIX NL_ETC_ABSOLUTE_PREFIX)
\r
1113 ## Allow override of install_prefix/share path.
\r
1114 IF(NOT NL_SHARE_PREFIX)
\r
1115 IF(WITH_UNIX_STRUCTURE)
\r
1116 SET(NL_SHARE_PREFIX "share/nel" CACHE PATH "Installation path for data.")
\r
1118 SET(NL_SHARE_PREFIX "." CACHE PATH "Installation path for data.")
\r
1121 NL_MAKE_ABSOLUTE_PREFIX(NL_SHARE_PREFIX NL_SHARE_ABSOLUTE_PREFIX)
\r
1123 ## Allow override of install_prefix/sbin path.
\r
1124 IF(NOT NL_SBIN_PREFIX)
\r
1125 IF(WITH_UNIX_STRUCTURE)
\r
1126 SET(NL_SBIN_PREFIX "sbin${LIB_SUFFIX}" CACHE PATH "Installation path for admin tools and services.")
\r
1128 SET(NL_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.")
\r
1131 NL_MAKE_ABSOLUTE_PREFIX(NL_SBIN_PREFIX NL_SBIN_ABSOLUTE_PREFIX)
\r
1133 ## Allow override of install_prefix/bin path.
\r
1134 IF(NOT NL_BIN_PREFIX)
\r
1135 IF(WITH_UNIX_STRUCTURE)
\r
1136 SET(NL_BIN_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for tools and applications.")
\r
1138 SET(NL_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.")
\r
1141 NL_MAKE_ABSOLUTE_PREFIX(NL_BIN_PREFIX NL_BIN_ABSOLUTE_PREFIX)
\r
1143 ## Allow override of install_prefix/lib path.
\r
1144 IF(NOT NL_LIB_PREFIX)
\r
1145 IF(LIBRARY_ARCHITECTURE)
\r
1146 SET(NL_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.")
\r
1148 SET(NL_LIB_PREFIX "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries.")
\r
1151 NL_MAKE_ABSOLUTE_PREFIX(NL_LIB_PREFIX NL_LIB_ABSOLUTE_PREFIX)
\r
1153 ## Allow override of install_prefix/lib path.
\r
1154 IF(NOT NL_DRIVER_PREFIX)
\r
1155 IF(WITH_UNIX_STRUCTURE)
\r
1156 IF(LIBRARY_ARCHITECTURE)
\r
1157 SET(NL_DRIVER_PREFIX "lib/${LIBRARY_ARCHITECTURE}/nel" CACHE PATH "Installation path for drivers.")
\r
1160 SET(NL_DRIVER_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for drivers.")
\r
1162 SET(NL_DRIVER_PREFIX "lib${LIB_SUFFIX}/nel" CACHE PATH "Installation path for drivers.")
\r
1166 SET(NL_DRIVER_PREFIX "." CACHE PATH "Installation path for drivers.")
\r
1169 NL_MAKE_ABSOLUTE_PREFIX(NL_DRIVER_PREFIX NL_DRIVER_ABSOLUTE_PREFIX)
\r
1170 ENDMACRO(NL_SETUP_PREFIX_PATHS)
\r
1172 MACRO(RYZOM_SETUP_PREFIX_PATHS)
\r
1173 ## Allow override of install_prefix/etc path.
\r
1174 IF(NOT RYZOM_ETC_PREFIX)
\r
1175 IF(WITH_UNIX_STRUCTURE)
\r
1176 SET(RYZOM_ETC_PREFIX "etc/ryzom" CACHE PATH "Installation path for configurations")
\r
1178 SET(RYZOM_ETC_PREFIX "." CACHE PATH "Installation path for configurations")
\r
1181 NL_MAKE_ABSOLUTE_PREFIX(RYZOM_ETC_PREFIX RYZOM_ETC_ABSOLUTE_PREFIX)
\r
1183 ## Allow override of install_prefix/share path.
\r
1184 IF(NOT RYZOM_SHARE_PREFIX)
\r
1185 IF(WITH_UNIX_STRUCTURE)
\r
1186 SET(RYZOM_SHARE_PREFIX "share/ryzom" CACHE PATH "Installation path for data.")
\r
1188 SET(RYZOM_SHARE_PREFIX "." CACHE PATH "Installation path for data.")
\r
1191 NL_MAKE_ABSOLUTE_PREFIX(RYZOM_SHARE_PREFIX RYZOM_SHARE_ABSOLUTE_PREFIX)
\r
1193 ## Allow override of install_prefix/sbin path.
\r
1194 IF(NOT RYZOM_SBIN_PREFIX)
\r
1195 IF(WITH_UNIX_STRUCTURE)
\r
1196 SET(RYZOM_SBIN_PREFIX "sbin${LIB_SUFFIX}" CACHE PATH "Installation path for admin tools and services.")
\r
1198 SET(RYZOM_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.")
\r
1201 NL_MAKE_ABSOLUTE_PREFIX(RYZOM_SBIN_PREFIX RYZOM_SBIN_ABSOLUTE_PREFIX)
\r
1203 ## Allow override of install_prefix/bin path.
\r
1204 IF(NOT RYZOM_BIN_PREFIX)
\r
1205 IF(WITH_UNIX_STRUCTURE)
\r
1206 SET(RYZOM_BIN_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for tools.")
\r
1208 SET(RYZOM_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.")
\r
1211 NL_MAKE_ABSOLUTE_PREFIX(RYZOM_BIN_PREFIX RYZOM_BIN_ABSOLUTE_PREFIX)
\r
1213 ## Allow override of install_prefix/lib path.
\r
1214 IF(NOT RYZOM_LIB_PREFIX)
\r
1215 IF(LIBRARY_ARCHITECTURE)
\r
1216 SET(RYZOM_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.")
\r
1218 SET(RYZOM_LIB_PREFIX "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries.")
\r
1221 NL_MAKE_ABSOLUTE_PREFIX(RYZOM_LIB_PREFIX RYZOM_LIB_ABSOLUTE_PREFIX)
\r
1223 ## Allow override of install_prefix/games path.
\r
1224 IF(NOT RYZOM_GAMES_PREFIX)
\r
1225 IF(WITH_UNIX_STRUCTURE)
\r
1226 SET(RYZOM_GAMES_PREFIX "games" CACHE PATH "Installation path for client.")
\r
1228 SET(RYZOM_GAMES_PREFIX "." CACHE PATH "Installation path for tools and applications.")
\r
1231 NL_MAKE_ABSOLUTE_PREFIX(RYZOM_GAMES_PREFIX RYZOM_GAMES_ABSOLUTE_PREFIX)
\r
1233 ENDMACRO(RYZOM_SETUP_PREFIX_PATHS)
\r
1235 MACRO(SETUP_EXTERNAL)
\r
1237 FIND_PACKAGE(External REQUIRED)
\r
1241 IF (HUNTER_ENABLED)
\r
1242 FIND_PACKAGE(External QUIET)
\r
1244 FIND_PACKAGE(External REQUIRED)
\r
1247 # If using custom boost, we need to define the right variables used by official boost CMake module
\r
1248 IF(DEFINED BOOST_DIR)
\r
1249 SET(BOOST_INCLUDEDIR ${BOOST_DIR}/include)
\r
1250 SET(BOOST_LIBRARYDIR ${BOOST_DIR}/lib)
\r
1253 FIND_PACKAGE(External QUIET)
\r
1256 IF(WITH_STATIC_EXTERNAL)
\r
1257 # Look only for static libraries because systems libraries are using Frameworks
\r
1258 SET(CMAKE_FIND_LIBRARY_SUFFIXES .a)
\r
1260 SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib .so .a)
\r
1263 IF(WITH_STATIC_EXTERNAL)
\r
1264 SET(CMAKE_FIND_LIBRARY_SUFFIXES .a .so)
\r
1266 SET(CMAKE_FIND_LIBRARY_SUFFIXES .so .a)
\r
1271 # Android, iOS and Mac OS X have pthread, but no need to link to libpthread
\r
1272 IF(ANDROID OR APPLE)
\r
1273 SET(CMAKE_USE_PTHREADS_INIT 1)
\r
1274 SET(Threads_FOUND TRUE)
\r
1276 SET(THREADS_HAVE_PTHREAD_ARG ON)
\r
1277 FIND_PACKAGE(Threads)
\r
1278 # TODO: replace all -l<lib> by absolute path to <lib> in CMAKE_THREAD_LIBS_INIT
\r
1282 FIND_PACKAGE(STLport REQUIRED)
\r
1283 INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR})
\r
1287 # Must include DXSDK before WINSDK
\r
1288 FIND_PACKAGE(DirectXSDK)
\r
1289 # IF(DXSDK_INCLUDE_DIR)
\r
1290 # INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR})
\r
1295 FIND_PACKAGE(MSVC REQUIRED)
\r
1296 FIND_PACKAGE(WindowsSDK REQUIRED)
\r
1298 MESSAGE(FATAL_ERROR "DirectX SDK or DirectX files from Windows SDK not found.")
\r