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
124 IF(WITH_STATIC_DRIVERS)
\r
126 IF(WITH_DRIVER_DIRECT3D)
\r
127 TARGET_LINK_LIBRARIES(${name} nel_drv_direct3d_win)
\r
131 IF(WITH_DRIVER_OPENGL)
\r
133 TARGET_LINK_LIBRARIES(${name} nel_drv_opengl_win)
\r
135 TARGET_LINK_LIBRARIES(${name} nel_drv_opengl)
\r
139 IF(WITH_DRIVER_OPENGLES)
\r
141 TARGET_LINK_LIBRARIES(${name} nel_drv_opengles_win)
\r
143 TARGET_LINK_LIBRARIES(${name} nel_drv_opengles)
\r
147 ENDMACRO(NL_ADD_STATIC_VID_DRIVERS)
\r
149 MACRO(NL_ADD_STATIC_SND_DRIVERS name)
\r
150 IF(WITH_STATIC_DRIVERS)
\r
152 IF(WITH_DRIVER_DSOUND)
\r
153 TARGET_LINK_LIBRARIES(${name} nel_drv_dsound_win)
\r
156 IF(WITH_DRIVER_XAUDIO2)
\r
157 TARGET_LINK_LIBRARIES(${name} nel_drv_xaudio2_win)
\r
160 IF(WITH_DRIVER_OPENAL)
\r
161 TARGET_LINK_LIBRARIES(${name} nel_drv_openal_win)
\r
164 IF(WITH_DRIVER_FMOD)
\r
165 TARGET_LINK_LIBRARIES(${name} nel_drv_fmod_win)
\r
168 IF(WITH_DRIVER_OPENAL)
\r
169 TARGET_LINK_LIBRARIES(${name} nel_drv_openal)
\r
172 IF(WITH_DRIVER_FMOD)
\r
173 TARGET_LINK_LIBRARIES(${name} nel_drv_fmod)
\r
178 ENDMACRO(NL_ADD_STATIC_SND_DRIVERS)
\r
181 # Checks build vs. source location. Prevents In-Source builds.
\r
183 MACRO(CHECK_OUT_OF_SOURCE)
\r
184 IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
\r
185 MESSAGE(FATAL_ERROR "
\r
187 CMake generation for this project is not allowed within the source directory!
\r
188 Remove the CMakeCache.txt file and try again from another folder, e.g.:
\r
197 ENDMACRO(CHECK_OUT_OF_SOURCE)
\r
199 MACRO(NL_SETUP_DEFAULT_OPTIONS)
\r
201 OPTION(WITH_STUDIO "Build Core Studio" OFF )
\r
207 OPTION(WITH_LOGGING "With Logging" ON )
\r
208 OPTION(WITH_COVERAGE "With Code Coverage Support" OFF)
\r
209 OPTION(WITH_PCH "With Precompiled Headers" ON )
\r
210 OPTION(WITH_LOW_MEMORY "With low memory (use the least of RAM)" OFF)
\r
211 OPTION(FINAL_VERSION "Build in Final Version mode" ON )
\r
213 # Default to static building on Windows.
\r
215 OPTION(WITH_STATIC "With static libraries." ON )
\r
217 OPTION(WITH_STATIC "With static libraries." OFF)
\r
220 OPTION(WITH_STATIC_LIBXML2 "With static libxml2" ON )
\r
222 OPTION(WITH_STATIC_LIBXML2 "With static libxml2" OFF)
\r
225 OPTION(WITH_STATIC_CURL "With static curl" ON )
\r
227 OPTION(WITH_STATIC_CURL "With static curl" OFF)
\r
230 OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" ON )
\r
232 OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" OFF)
\r
234 OPTION(WITH_STATIC_DRIVERS "With static drivers." OFF)
\r
236 OPTION(WITH_EXTERNAL "With provided external." ON )
\r
238 OPTION(WITH_EXTERNAL "With provided external." OFF)
\r
240 OPTION(WITH_STATIC_EXTERNAL "With static external libraries" OFF)
\r
241 OPTION(WITH_STATIC_RUNTIMES "Use only static C++ runtimes" OFF)
\r
242 IF(UNIX AND NOT APPLE)
\r
243 OPTION(WITH_UNIX_STRUCTURE "Use UNIX structure (bin, include, lib)" ON )
\r
245 OPTION(WITH_UNIX_STRUCTURE "Use UNIX structure (bin, include, lib)" OFF)
\r
247 OPTION(WITH_INSTALL_LIBRARIES "Install development files." ON )
\r
249 OPTION(WITH_ASSIMP "Use assimp exporter" OFF)
\r
250 OPTION(WITH_LIBGSF "Use libgsf for max file library" OFF)
\r
252 OPTION(WITH_FFMPEG "Use ffmpeg for audio decoder" OFF)
\r
257 OPTION(WITH_GTK "With GTK Support" OFF)
\r
258 OPTION(WITH_QT "With Qt 4 Support" OFF)
\r
259 OPTION(WITH_QT5 "With Qt 5 Support" OFF)
\r
261 IF(WIN32 AND MFC_FOUND)
\r
262 OPTION(WITH_MFC "With MFC Support" ON )
\r
264 OPTION(WITH_MFC "With MFC Support" OFF)
\r
270 OPTION(WITH_SYMBOLS "Keep debug symbols in binaries" OFF)
\r
272 # only enable STLport for VC++ 2010 and less
\r
273 IF(WIN32 AND MSVC_VERSION LESS 1600)
\r
274 OPTION(WITH_STLPORT "With STLport support." ON )
\r
276 OPTION(WITH_STLPORT "With STLport support." OFF)
\r
279 OPTION(BUILD_DASHBOARD "Build to the CDash dashboard" OFF)
\r
281 OPTION(WITH_NEL "Build NeL (nearly always required)." ON )
\r
282 OPTION(WITH_NELNS "Build NeL Network Services." OFF)
\r
283 OPTION(WITH_RYZOM "Build Ryzom Core." ON )
\r
284 OPTION(WITH_SNOWBALLS "Build Snowballs." OFF)
\r
285 OPTION(WITH_TOOLS "Build Tools" OFF)
\r
287 OPTION(WITH_RYZOM_LIVE "Use ryzom.com urls" OFF)
\r
288 ENDMACRO(NL_SETUP_DEFAULT_OPTIONS)
\r
290 MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)
\r
294 OPTION(WITH_NET "Build NLNET" ON )
\r
295 OPTION(WITH_3D "Build NL3D" ON )
\r
296 OPTION(WITH_WEB "Build WEB" ON )
\r
297 OPTION(WITH_GUI "Build GUI" ON )
\r
298 OPTION(WITH_PACS "Build NLPACS" ON )
\r
299 OPTION(WITH_GEORGES "Build NLGEORGES" ON )
\r
300 OPTION(WITH_LIGO "Build NLLIGO" ON )
\r
301 OPTION(WITH_LOGIC "Build NLLOGIC" ON )
\r
302 OPTION(WITH_SOUND "Build NLSOUND" ON )
\r
307 OPTION(WITH_DRIVER_OPENGL "Build OpenGL Driver (3D)" ON )
\r
308 OPTION(WITH_DRIVER_OPENGLES "Build OpenGL ES Driver (3D)" OFF)
\r
309 OPTION(WITH_DRIVER_DIRECT3D "Build Direct3D Driver (3D)" OFF)
\r
310 OPTION(WITH_DRIVER_OPENAL "Build OpenAL Driver (Sound)" ON )
\r
311 OPTION(WITH_DRIVER_FMOD "Build FMOD Driver (Sound)" OFF)
\r
312 OPTION(WITH_DRIVER_DSOUND "Build DirectSound Driver (Sound)" OFF)
\r
313 OPTION(WITH_DRIVER_XAUDIO2 "Build XAudio2 Driver (Sound)" OFF)
\r
318 OPTION(WITH_NEL_CEGUI "Build CEGUI Renderer" OFF)
\r
319 OPTION(WITH_NEL_TOOLS "Build NeL Tools" ON )
\r
320 OPTION(WITH_NEL_MAXPLUGIN "Build NeL 3dsMax Plugin" OFF)
\r
321 OPTION(WITH_NEL_SAMPLES "Build NeL Samples" ON )
\r
322 OPTION(WITH_NEL_TESTS "Build NeL Unit Tests" ON )
\r
324 OPTION(WITH_LIBOVR "With LibOVR support" OFF)
\r
325 OPTION(WITH_LIBVR "With LibVR support" OFF)
\r
326 OPTION(WITH_PERFHUD "With NVIDIA PerfHUD support" OFF)
\r
328 OPTION(WITH_SSE2 "With SSE2" ON )
\r
329 OPTION(WITH_SSE3 "With SSE3" ON )
\r
332 OPTION(WITH_GCC_FPMATH_BOTH "With GCC -mfpmath=both" OFF)
\r
334 ENDMACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)
\r
336 MACRO(NL_SETUP_NELNS_DEFAULT_OPTIONS)
\r
340 OPTION(WITH_NELNS_SERVER "Build NeLNS Services" ON )
\r
341 OPTION(WITH_NELNS_LOGIN_SYSTEM "Build NeLNS Login System Tools" ON )
\r
342 ENDMACRO(NL_SETUP_NELNS_DEFAULT_OPTIONS)
\r
344 MACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS)
\r
348 OPTION(WITH_RYZOM_CLIENT "Build Ryzom Core Client" ON )
\r
349 OPTION(WITH_RYZOM_TOOLS "Build Ryzom Core Tools" ON )
\r
350 OPTION(WITH_RYZOM_SERVER "Build Ryzom Core Services" ON )
\r
351 OPTION(WITH_RYZOM_INSTALLER "Build Ryzom Installer" OFF)
\r
356 OPTION(WITH_LUA51 "Build Ryzom Core using Lua 5.1" ON )
\r
357 OPTION(WITH_LUA52 "Build Ryzom Core using Lua 5.2" OFF)
\r
358 OPTION(WITH_LUA53 "Build Ryzom Core using Lua 5.3" OFF)
\r
359 OPTION(WITH_RYZOM_CLIENT_UAC "Ask to run as Administrator" OFF)
\r
360 OPTION(WITH_RYZOM_PATCH "Enable Ryzom in-game patch support" OFF)
\r
361 OPTION(WITH_RYZOM_CUSTOM_PATCH_SERVER "Only use patch server from CFG file" OFF)
\r
362 OPTION(WITH_RYZOM_STEAM "Enable Steam features" OFF)
\r
363 OPTION(WITH_RYZOM_SANDBOX "Enable Sandbox under OS X" OFF)
\r
364 ENDMACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS)
\r
366 MACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS)
\r
370 OPTION(WITH_SNOWBALLS_CLIENT "Build Snowballs Client" ON )
\r
371 OPTION(WITH_SNOWBALLS_SERVER "Build Snowballs Services" ON )
\r
372 ENDMACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS)
\r
374 MACRO(ADD_PLATFORM_FLAGS _FLAGS)
\r
375 SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} ${_FLAGS}")
\r
376 SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} ${_FLAGS}")
\r
379 MACRO(ADD_PLATFORM_LINKFLAGS _FLAGS)
\r
380 SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${_FLAGS}")
\r
383 MACRO(CONVERT_VERSION_NUMBER _VERSION_NUMBER _BASE)
\r
384 SET(${_VERSION_NUMBER} 0)
\r
385 FOREACH(_ARG ${ARGN})
\r
386 MATH(EXPR ${_VERSION_NUMBER} "${${_VERSION_NUMBER}} * ${_BASE} + ${_ARG}")
\r
390 MACRO(NL_SETUP_BUILD)
\r
391 #-----------------------------------------------------------------------------
\r
392 # Setup the buildmode variables.
\r
394 # None = NL_RELEASE
\r
396 # Release = NL_RELEASE
\r
398 IF(CMAKE_BUILD_TYPE MATCHES "Debug")
\r
399 SET(NL_BUILD_MODE "NL_DEBUG")
\r
401 IF(CMAKE_BUILD_TYPE MATCHES "Release")
\r
402 SET(NL_BUILD_MODE "NL_RELEASE")
\r
404 SET(NL_BUILD_MODE "NL_RELEASE")
\r
405 # enforce release mode if it's neither Debug nor Release
\r
406 SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
\r
410 IF(CMAKE_CXX_LIBRARY_ARCHITECTURE)
\r
411 SET(HOST_CPU ${CMAKE_CXX_LIBRARY_ARCHITECTURE})
\r
413 SET(HOST_CPU ${CMAKE_HOST_SYSTEM_PROCESSOR})
\r
416 IF(HOST_CPU MATCHES "(amd|AMD|x86_)64")
\r
417 SET(HOST_CPU "x86_64")
\r
418 ELSEIF(HOST_CPU MATCHES "i.86")
\r
419 SET(HOST_CPU "x86")
\r
422 # Determine target CPU
\r
424 # If not specified, use the same CPU as host
\r
426 SET(TARGET_CPU ${HOST_CPU})
\r
429 IF(TARGET_CPU MATCHES "(amd|AMD|x86_)64")
\r
430 SET(TARGET_CPU "x86_64")
\r
431 ELSEIF(TARGET_CPU MATCHES "i.86")
\r
432 SET(TARGET_CPU "x86")
\r
435 IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
\r
437 MESSAGE(STATUS "Using Clang ${CMAKE_CXX_COMPILER_VERSION} compiler")
\r
440 IF(CMAKE_GENERATOR MATCHES "Xcode")
\r
442 MESSAGE(STATUS "Generating Xcode project")
\r
445 IF(CMAKE_GENERATOR MATCHES "NMake")
\r
447 MESSAGE(STATUS "Generating NMake project")
\r
450 IF(CMAKE_GENERATOR MATCHES "Ninja")
\r
452 MESSAGE(STATUS "Generating Ninja project")
\r
455 # If target and host CPU are the same
\r
456 IF("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING)
\r
457 # x86-compatible CPU
\r
458 IF(HOST_CPU MATCHES "x86")
\r
459 IF(NOT CMAKE_SIZEOF_VOID_P)
\r
460 INCLUDE (CheckTypeSize)
\r
461 CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P)
\r
464 # Using 32 or 64 bits libraries
\r
465 IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
\r
466 SET(TARGET_CPU "x86_64")
\r
468 SET(TARGET_CPU "x86")
\r
470 ELSEIF(HOST_CPU MATCHES "arm")
\r
471 SET(TARGET_CPU "arm")
\r
473 SET(TARGET_CPU "unknown")
\r
474 MESSAGE(STATUS "Unknown architecture: ${HOST_CPU}")
\r
476 # TODO: add checks for PPC
\r
478 MESSAGE(STATUS "Compiling on ${HOST_CPU} for ${TARGET_CPU}")
\r
481 # Use values from environment variables
\r
482 SET(PLATFORM_CFLAGS "$ENV{CFLAGS} $ENV{CPPFLAGS} ${PLATFORM_CFLAGS}")
\r
483 SET(PLATFORM_CXXFLAGS "$ENV{CXXFLAGS} $ENV{CPPFLAGS} ${PLATFORM_CXXFLAGS}")
\r
484 SET(PLATFORM_LINKFLAGS "$ENV{LDFLAGS} ${PLATFORM_LINKFLAGS}")
\r
486 # Remove -g and -O flag because we are managing them ourself
\r
487 STRING(REPLACE "-g" "" PLATFORM_CFLAGS ${PLATFORM_CFLAGS})
\r
488 STRING(REPLACE "-g" "" PLATFORM_CXXFLAGS ${PLATFORM_CXXFLAGS})
\r
489 STRING(REGEX REPLACE "-O[0-9s]" "" PLATFORM_CFLAGS ${PLATFORM_CFLAGS})
\r
490 STRING(REGEX REPLACE "-O[0-9s]" "" PLATFORM_CXXFLAGS ${PLATFORM_CXXFLAGS})
\r
493 STRING(STRIP ${PLATFORM_CFLAGS} PLATFORM_CFLAGS)
\r
494 STRING(STRIP ${PLATFORM_CXXFLAGS} PLATFORM_CXXFLAGS)
\r
495 STRING(STRIP ${PLATFORM_LINKFLAGS} PLATFORM_LINKFLAGS)
\r
497 IF(NOT CMAKE_OSX_ARCHITECTURES)
\r
498 IF(TARGET_CPU STREQUAL "x86_64")
\r
501 ELSEIF(TARGET_CPU STREQUAL "x86")
\r
503 ELSEIF(TARGET_CPU STREQUAL "arm64")
\r
505 SET(TARGET_ARM64 1)
\r
506 ELSEIF(TARGET_CPU STREQUAL "armv7s")
\r
508 SET(TARGET_ARMV7S 1)
\r
509 ELSEIF(TARGET_CPU STREQUAL "armv7")
\r
511 SET(TARGET_ARMV7 1)
\r
512 ELSEIF(TARGET_CPU STREQUAL "armv6")
\r
514 SET(TARGET_ARMV6 1)
\r
515 ELSEIF(TARGET_CPU STREQUAL "armv5")
\r
517 SET(TARGET_ARMV5 1)
\r
518 ELSEIF(TARGET_CPU STREQUAL "arm")
\r
520 ELSEIF(TARGET_CPU STREQUAL "mips")
\r
526 ADD_PLATFORM_FLAGS("-DHAVE_ARM64")
\r
530 ADD_PLATFORM_FLAGS("-DHAVE_ARMV7S")
\r
534 ADD_PLATFORM_FLAGS("-DHAVE_ARMV7")
\r
538 ADD_PLATFORM_FLAGS("-HAVE_ARMV6")
\r
541 ADD_PLATFORM_FLAGS("-DHAVE_ARM")
\r
545 ADD_PLATFORM_FLAGS("-DHAVE_X86")
\r
549 ADD_PLATFORM_FLAGS("-DHAVE_X64 -DHAVE_X86_64")
\r
553 ADD_PLATFORM_FLAGS("-DHAVE_MIPS")
\r
557 # Fix library paths suffixes for Debian MultiArch
\r
558 IF(LIBRARY_ARCHITECTURE)
\r
559 SET(CMAKE_LIBRARY_PATH /lib/${LIBRARY_ARCHITECTURE} /usr/lib/${LIBRARY_ARCHITECTURE} ${CMAKE_LIBRARY_PATH})
\r
561 SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib64 /usr/lib64)
\r
563 SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib32 /usr/lib32)
\r
567 IF(APPLE AND NOT IOS)
\r
568 SET(CMAKE_INCLUDE_PATH /opt/local/include ${CMAKE_INCLUDE_PATH})
\r
569 SET(CMAKE_LIBRARY_PATH /opt/local/lib ${CMAKE_LIBRARY_PATH})
\r
573 ADD_PLATFORM_FLAGS("-DENABLE_LOGS")
\r
576 SET(CUSTOM_FLAGS "" CACHE STRING "Custom compile flags (useful for /MPn)")
\r
577 IF(NOT ${CUSTOM_FLAGS} STREQUAL "")
\r
578 ADD_PLATFORM_FLAGS(${CUSTOM_FLAGS})
\r
582 # Ignore default include paths
\r
583 ADD_PLATFORM_FLAGS("/X")
\r
586 ADD_PLATFORM_FLAGS("/Gy-")
\r
587 # /Ox is working with VC++ 2015 and 2017, but custom optimizations don't exist
\r
588 SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
\r
589 # without inlining it's unusable, use custom optimizations again
\r
590 SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
\r
592 # Special cases for VC++ 2017
\r
593 IF(MSVC_VERSION EQUAL "1911")
\r
595 ELSEIF(MSVC_VERSION EQUAL "1910")
\r
599 ADD_PLATFORM_FLAGS("/Gy-")
\r
600 # /Ox is working with VC++ 2013, but custom optimizations don't exist
\r
601 SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
\r
602 # without inlining it's unusable, use custom optimizations again
\r
603 SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
\r
605 ADD_PLATFORM_FLAGS("/Gy-")
\r
606 # /Ox is working with VC++ 2012, but custom optimizations don't exist
\r
607 SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
\r
608 # without inlining it's unusable, use custom optimizations again
\r
609 SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
\r
611 ADD_PLATFORM_FLAGS("/Gy-")
\r
612 # /Ox is working with VC++ 2010, but custom optimizations don't exist
\r
613 SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
\r
614 # without inlining it's unusable, use custom optimizations again
\r
615 SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
\r
617 ADD_PLATFORM_FLAGS("/Gy-")
\r
618 # don't use a /O[012x] flag if you want custom optimizations
\r
619 SET(RELEASE_CFLAGS "/Ob2 /Oi /Ot /Oy /GT /GF /GS- ${RELEASE_CFLAGS}")
\r
620 # without inlining it's unusable, use custom optimizations again
\r
621 SET(DEBUG_CFLAGS "/Ob1 /GF- ${DEBUG_CFLAGS}")
\r
623 ADD_PLATFORM_FLAGS("/Gy- /Wp64")
\r
624 # don't use a /O[012x] flag if you want custom optimizations
\r
625 SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
\r
626 # without inlining it's unusable, use custom optimizations again
\r
627 SET(DEBUG_CFLAGS "/Od /Ob1 ${DEBUG_CFLAGS}")
\r
629 MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}")
\r
632 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
635 ADD_PLATFORM_FLAGS("/Zm1000")
\r
638 # Fix a bug with Intellisense
\r
639 ADD_PLATFORM_FLAGS("/D_WIN64")
\r
640 # Fix a compilation error for some big C++ files
\r
641 ADD_PLATFORM_FLAGS("/bigobj")
\r
643 # Allows 32 bits applications to use 3 GB of RAM
\r
644 ADD_PLATFORM_LINKFLAGS("/LARGEADDRESSAWARE")
\r
647 # Exceptions are only set for C++
\r
648 SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} /EHa")
\r
651 SET(NL_RELEASE_CFLAGS "/Zi ${NL_RELEASE_CFLAGS}")
\r
652 SET(NL_RELEASE_LINKFLAGS "/DEBUG ${NL_RELEASE_LINKFLAGS}")
\r
654 SET(NL_RELEASE_LINKFLAGS "/RELEASE ${NL_RELEASE_LINKFLAGS}")
\r
657 IF(WITH_STATIC_RUNTIMES)
\r
658 SET(RUNTIME_FLAG "/MT")
\r
660 SET(RUNTIME_FLAG "/MD")
\r
663 SET(NL_DEBUG_CFLAGS "/Zi ${RUNTIME_FLAG}d /RTC1 /D_DEBUG ${DEBUG_CFLAGS} ${NL_DEBUG_CFLAGS}")
\r
664 SET(NL_RELEASE_CFLAGS "${RUNTIME_FLAG} /DNDEBUG ${RELEASE_CFLAGS} ${NL_RELEASE_CFLAGS}")
\r
665 SET(NL_DEBUG_LINKFLAGS "/DEBUG /OPT:NOREF /OPT:NOICF /NODEFAULTLIB:msvcrt ${MSVC_INCREMENTAL_YES_FLAG} ${NL_DEBUG_LINKFLAGS}")
\r
666 SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO ${NL_RELEASE_LINKFLAGS}")
\r
669 SET(DEBUG_CFLAGS "/W4 ${DEBUG_CFLAGS}")
\r
671 SET(DEBUG_CFLAGS "/W3 ${DEBUG_CFLAGS}")
\r
675 ADD_PLATFORM_FLAGS("-DWIN32 -D_WIN32")
\r
678 ADD_PLATFORM_FLAGS("-nobuiltininc")
\r
683 ADD_PLATFORM_FLAGS("-msse3")
\r
686 IF(WITH_GCC_FPMATH_BOTH)
\r
687 ADD_PLATFORM_FLAGS("-mfpmath=both")
\r
691 SET(OBJC_FLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch -fobjc-weak)
\r
694 IF(CMAKE_OSX_ARCHITECTURES)
\r
695 SET(TARGETS_COUNT 0)
\r
697 FOREACH(_ARCH ${CMAKE_OSX_ARCHITECTURES})
\r
698 IF(_ARCH STREQUAL "i386")
\r
699 SET(_ARCHS "${_ARCHS} i386")
\r
701 MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
\r
702 ELSEIF(_ARCH STREQUAL "x86_64")
\r
703 SET(_ARCHS "${_ARCHS} x86_64")
\r
705 MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
\r
706 ELSEIF(_ARCH STREQUAL "armv7s")
\r
707 SET(_ARCHS "${_ARCHS} armv7s")
\r
708 SET(TARGET_ARMV7S 1)
\r
710 MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
\r
711 ELSEIF(_ARCH STREQUAL "armv7")
\r
712 SET(_ARCHS "${_ARCHS} armv7")
\r
713 SET(TARGET_ARMV7 1)
\r
715 MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
\r
716 ELSEIF(_ARCH STREQUAL "armv6")
\r
717 SET(_ARCHS "${_ARCHS} armv6")
\r
718 SET(TARGET_ARMV6 1)
\r
720 MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
\r
721 ELSEIF(_ARCH STREQUAL "mips")
\r
722 SET(_ARCHS "${_ARCHS} mips")
\r
724 MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
\r
726 SET(_ARCHS "${_ARCHS} unknwon(${_ARCH})")
\r
729 MESSAGE(STATUS "Compiling under Mac OS X for ${TARGETS_COUNT} architectures: ${_ARCHS}")
\r
731 SET(TARGETS_COUNT 0)
\r
734 IF(TARGETS_COUNT EQUAL 1)
\r
737 ADD_PLATFORM_FLAGS("-arch armv7s -DHAVE_ARMV7S")
\r
741 ADD_PLATFORM_FLAGS("-arch armv7 -DHAVE_ARMV7")
\r
745 ADD_PLATFORM_FLAGS("-arch armv6 -DHAVE_ARMV6")
\r
749 ADD_PLATFORM_FLAGS("-arch armv5 -DHAVE_ARMV5")
\r
752 ADD_PLATFORM_FLAGS("-mthumb -DHAVE_ARM")
\r
756 ADD_PLATFORM_FLAGS("-arch x86_64 -DHAVE_X64 -DHAVE_X86_64 -DHAVE_X86")
\r
758 ADD_PLATFORM_FLAGS("-arch i386 -DHAVE_X86")
\r
762 ADD_PLATFORM_FLAGS("-arch mips -DHAVE_MIPS")
\r
764 ELSEIF(TARGETS_COUNT EQUAL 0)
\r
765 # Not using CMAKE_OSX_ARCHITECTURES, HAVE_XXX already defined before
\r
768 ADD_PLATFORM_FLAGS("-arch armv7s")
\r
772 ADD_PLATFORM_FLAGS("-arch armv7")
\r
776 ADD_PLATFORM_FLAGS("-arch armv6")
\r
780 ADD_PLATFORM_FLAGS("-arch armv5")
\r
783 ADD_PLATFORM_FLAGS("-mthumb")
\r
787 ADD_PLATFORM_FLAGS("-arch x86_64")
\r
789 ADD_PLATFORM_FLAGS("-arch i386")
\r
793 ADD_PLATFORM_FLAGS("-arch mips")
\r
797 ADD_PLATFORM_FLAGS("-Xarch_armv6 -mthumb -Xarch_armv6 -DHAVE_ARM -Xarch_armv6 -DHAVE_ARMV6")
\r
801 ADD_PLATFORM_FLAGS("-Xarch_armv7 -mthumb -Xarch_armv7 -DHAVE_ARM -Xarch_armv7 -DHAVE_ARMV7")
\r
805 ADD_PLATFORM_FLAGS("-Xarch_i386 -DHAVE_X86")
\r
809 ADD_PLATFORM_FLAGS("-Xarch_x86_64 -DHAVE_X64 -Xarch_x86_64 -DHAVE_X86_64")
\r
813 ADD_PLATFORM_FLAGS("-Xarch_mips -DHAVE_MIPS")
\r
818 SET(CMAKE_OSX_SYSROOT "" CACHE PATH "" FORCE)
\r
821 PARSE_VERSION_STRING(${IOS_VERSION} IOS_VERSION_MAJOR IOS_VERSION_MINOR IOS_VERSION_PATCH)
\r
822 CONVERT_VERSION_NUMBER(${IOS_VERSION_MAJOR} ${IOS_VERSION_MINOR} ${IOS_VERSION_PATCH} IOS_VERSION_NUMBER)
\r
824 ADD_PLATFORM_FLAGS("-D__IPHONE_OS_VERSION_MIN_REQUIRED=${IOS_VERSION_NUMBER}")
\r
827 IF(CMAKE_IOS_SYSROOT)
\r
829 IF(TARGETS_COUNT GREATER 1)
\r
830 SET(XARCH "-Xarch_armv7s ")
\r
833 ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}")
\r
834 ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}")
\r
835 ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}")
\r
839 IF(TARGETS_COUNT GREATER 1)
\r
840 SET(XARCH "-Xarch_armv7 ")
\r
843 ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}")
\r
844 ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}")
\r
845 ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}")
\r
849 IF(TARGETS_COUNT GREATER 1)
\r
850 SET(XARCH "-Xarch_armv6 ")
\r
853 ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}")
\r
854 ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}")
\r
855 ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}")
\r
859 IF(CMAKE_IOS_SIMULATOR_SYSROOT AND TARGET_X86)
\r
860 IF(TARGETS_COUNT GREATER 1)
\r
861 SET(XARCH "-Xarch_i386 ")
\r
864 ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SIMULATOR_SYSROOT}")
\r
865 ADD_PLATFORM_FLAGS("${XARCH}-mios-simulator-version-min=${IOS_VERSION}")
\r
866 IF(CMAKE_OSX_DEPLOYMENT_TARGET)
\r
867 ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}")
\r
871 # Always force -mmacosx-version-min to override environement variable
\r
872 IF(CMAKE_OSX_DEPLOYMENT_TARGET)
\r
873 IF(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "10.7")
\r
874 MESSAGE(FATAL_ERROR "Minimum target for OS X is 10.7 but you're using ${CMAKE_OSX_DEPLOYMENT_TARGET}")
\r
876 ADD_PLATFORM_LINKFLAGS("-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}")
\r
880 # use libc++ under OX X to be able to use new C++ features (and else it'll use GCC 4.2.1 STL)
\r
881 # minimum target is now OS X 10.7
\r
882 SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -stdlib=libc++")
\r
884 ADD_PLATFORM_LINKFLAGS("-Wl,-headerpad_max_install_names")
\r
886 IF(HAVE_FLAG_SEARCH_PATHS_FIRST)
\r
887 ADD_PLATFORM_LINKFLAGS("-Wl,-search_paths_first")
\r
891 IF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86")
\r
892 ADD_PLATFORM_FLAGS("-m32 -march=i686")
\r
895 IF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64")
\r
896 ADD_PLATFORM_FLAGS("-m64")
\r
900 # use c++0x standard to use std::unique_ptr and std::shared_ptr
\r
901 IF(CMAKE_CXX11_EXTENSION_COMPILE_OPTION)
\r
902 SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} ${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}")
\r
905 ADD_PLATFORM_FLAGS("-D_REENTRANT")
\r
908 ADD_PLATFORM_FLAGS("-D_FORTIFY_SOURCE=2")
\r
910 IF(NOT WITH_LOW_MEMORY)
\r
911 ADD_PLATFORM_FLAGS("-pipe")
\r
915 ADD_PLATFORM_FLAGS("-fprofile-arcs -ftest-coverage")
\r
919 ADD_PLATFORM_FLAGS("-Wall")
\r
921 # Check wrong formats in printf-like functions
\r
922 ADD_PLATFORM_FLAGS("-Wformat -Werror=format-security")
\r
925 # never display these warnings because they are minor
\r
926 ADD_PLATFORM_FLAGS("-Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-value")
\r
928 IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "6.0.0")
\r
929 ADD_PLATFORM_FLAGS("-Wno-unused-local-typedefs")
\r
931 ADD_PLATFORM_FLAGS("-Wno-unused-private-field -Wno-unused-local-typedef")
\r
935 ADD_PLATFORM_FLAGS("--sysroot=${PLATFORM_ROOT}")
\r
936 ADD_PLATFORM_FLAGS("-ffunction-sections -funwind-tables")
\r
937 ADD_PLATFORM_FLAGS("-DANDROID")
\r
938 ADD_PLATFORM_FLAGS("-Wa,--noexecstack")
\r
941 ADD_PLATFORM_FLAGS("-fpic")
\r
942 ADD_PLATFORM_FLAGS("-D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__")
\r
945 ADD_PLATFORM_FLAGS("-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16")
\r
946 ADD_PLATFORM_LINKFLAGS("-march=armv7-a -Wl,--fix-cortex-a8")
\r
947 ELSEIF(TARGET_ARMV5)
\r
948 ADD_PLATFORM_FLAGS("-march=armv5te -mtune=xscale -msoft-float")
\r
951 SET(TARGET_THUMB ON)
\r
953 ADD_PLATFORM_FLAGS("-mthumb -finline-limit=64")
\r
954 SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -marm")
\r
956 ADD_PLATFORM_FLAGS("-funswitch-loops -finline-limit=300")
\r
959 # Optimizations for Intel Atom
\r
960 ADD_PLATFORM_FLAGS("-march=i686 -mtune=atom -mstackrealign -msse3 -mfpmath=sse -m32 -flto -ffast-math -funroll-loops")
\r
961 ADD_PLATFORM_FLAGS("-funswitch-loops -finline-limit=300")
\r
962 ELSEIF(TARGET_MIPS)
\r
963 ADD_PLATFORM_FLAGS("-fpic -finline-functions -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers")
\r
964 SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -funswitch-loops -finline-limit=300")
\r
966 ADD_PLATFORM_LINKFLAGS("-Wl,-z,noexecstack")
\r
967 ADD_PLATFORM_LINKFLAGS("-L${PLATFORM_ROOT}/usr/lib")
\r
971 ADD_PLATFORM_FLAGS("-gdwarf-2 -D_DARWIN_UNLIMITED_STREAMS")
\r
974 # Fix "relocation R_X86_64_32 against.." error on x64 platforms
\r
976 ADD_PLATFORM_FLAGS("-fPIC")
\r
980 ADD_PLATFORM_FLAGS("-fstack-protector --param=ssp-buffer-size=4")
\r
982 # If -fstack-protector or -fstack-protector-all enabled, enable too new warnings and fix possible link problems
\r
984 ADD_PLATFORM_FLAGS("-Wstack-protector")
\r
987 # Fix undefined reference to `__stack_chk_fail' error
\r
988 ADD_PLATFORM_LINKFLAGS("-lc")
\r
991 ADD_PLATFORM_LINKFLAGS("-Wl,--no-undefined -Wl,--as-needed")
\r
993 IF(WITH_STATIC_RUNTIMES)
\r
994 ADD_PLATFORM_LINKFLAGS("-static-libstdc++")
\r
1000 ADD_PLATFORM_LINKFLAGS("-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now")
\r
1004 SET(NL_RELEASE_CFLAGS "${NL_RELEASE_CFLAGS} -g")
\r
1007 SET(NL_RELEASE_LINKFLAGS "-Wl,-dead_strip ${NL_RELEASE_LINKFLAGS}")
\r
1009 SET(NL_RELEASE_LINKFLAGS "-Wl,-s ${NL_RELEASE_LINKFLAGS}")
\r
1013 SET(NL_DEBUG_CFLAGS "-g -DNL_DEBUG -D_DEBUG ${NL_DEBUG_CFLAGS}")
\r
1014 SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -DNDEBUG -O3 ${NL_RELEASE_CFLAGS}")
\r
1018 MACRO(NL_SETUP_BUILD_FLAGS)
\r
1019 SET(CMAKE_C_FLAGS ${PLATFORM_CFLAGS} CACHE STRING "" FORCE)
\r
1020 SET(CMAKE_CXX_FLAGS ${PLATFORM_CXXFLAGS} CACHE STRING "" FORCE)
\r
1021 SET(CMAKE_EXE_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE)
\r
1022 SET(CMAKE_MODULE_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE)
\r
1023 SET(CMAKE_SHARED_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE)
\r
1026 SET(CMAKE_C_FLAGS_DEBUG ${NL_DEBUG_CFLAGS} CACHE STRING "" FORCE)
\r
1027 SET(CMAKE_CXX_FLAGS_DEBUG ${NL_DEBUG_CFLAGS} CACHE STRING "" FORCE)
\r
1028 SET(CMAKE_EXE_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE)
\r
1029 SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE)
\r
1030 SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE)
\r
1033 SET(CMAKE_C_FLAGS_RELEASE ${NL_RELEASE_CFLAGS} CACHE STRING "" FORCE)
\r
1034 SET(CMAKE_CXX_FLAGS_RELEASE ${NL_RELEASE_CFLAGS} CACHE STRING "" FORCE)
\r
1035 SET(CMAKE_EXE_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE)
\r
1036 SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE)
\r
1037 SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE)
\r
1038 ENDMACRO(NL_SETUP_BUILD_FLAGS)
\r
1040 # Macro to create x_ABSOLUTE_PREFIX from x_PREFIX
\r
1041 MACRO(NL_MAKE_ABSOLUTE_PREFIX NAME_RELATIVE NAME_ABSOLUTE)
\r
1042 IF(IS_ABSOLUTE "${${NAME_RELATIVE}}")
\r
1043 SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}})
\r
1045 IF(WITH_UNIX_STRUCTURE)
\r
1046 SET(${NAME_ABSOLUTE} ${CMAKE_INSTALL_PREFIX}/${${NAME_RELATIVE}})
\r
1048 SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}})
\r
1051 ENDMACRO(NL_MAKE_ABSOLUTE_PREFIX)
\r
1053 MACRO(NL_SETUP_PREFIX_PATHS)
\r
1054 IF(TARGET_X64 AND WIN32)
\r
1055 SET(LIB_SUFFIX "64")
\r
1057 SET(LIB_SUFFIX "")
\r
1060 ## Allow override of install_prefix/etc path.
\r
1061 IF(NOT NL_ETC_PREFIX)
\r
1062 IF(WITH_UNIX_STRUCTURE)
\r
1063 SET(NL_ETC_PREFIX "etc/nel" CACHE PATH "Installation path for configurations")
\r
1065 SET(NL_ETC_PREFIX "." CACHE PATH "Installation path for configurations")
\r
1068 NL_MAKE_ABSOLUTE_PREFIX(NL_ETC_PREFIX NL_ETC_ABSOLUTE_PREFIX)
\r
1070 ## Allow override of install_prefix/share path.
\r
1071 IF(NOT NL_SHARE_PREFIX)
\r
1072 IF(WITH_UNIX_STRUCTURE)
\r
1073 SET(NL_SHARE_PREFIX "share/nel" CACHE PATH "Installation path for data.")
\r
1075 SET(NL_SHARE_PREFIX "." CACHE PATH "Installation path for data.")
\r
1078 NL_MAKE_ABSOLUTE_PREFIX(NL_SHARE_PREFIX NL_SHARE_ABSOLUTE_PREFIX)
\r
1080 ## Allow override of install_prefix/sbin path.
\r
1081 IF(NOT NL_SBIN_PREFIX)
\r
1082 IF(WITH_UNIX_STRUCTURE)
\r
1083 SET(NL_SBIN_PREFIX "sbin${LIB_SUFFIX}" CACHE PATH "Installation path for admin tools and services.")
\r
1085 SET(NL_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.")
\r
1088 NL_MAKE_ABSOLUTE_PREFIX(NL_SBIN_PREFIX NL_SBIN_ABSOLUTE_PREFIX)
\r
1090 ## Allow override of install_prefix/bin path.
\r
1091 IF(NOT NL_BIN_PREFIX)
\r
1092 IF(WITH_UNIX_STRUCTURE)
\r
1093 SET(NL_BIN_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for tools and applications.")
\r
1095 SET(NL_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.")
\r
1098 NL_MAKE_ABSOLUTE_PREFIX(NL_BIN_PREFIX NL_BIN_ABSOLUTE_PREFIX)
\r
1100 ## Allow override of install_prefix/lib path.
\r
1101 IF(NOT NL_LIB_PREFIX)
\r
1102 IF(LIBRARY_ARCHITECTURE)
\r
1103 SET(NL_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.")
\r
1105 SET(NL_LIB_PREFIX "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries.")
\r
1108 NL_MAKE_ABSOLUTE_PREFIX(NL_LIB_PREFIX NL_LIB_ABSOLUTE_PREFIX)
\r
1110 ## Allow override of install_prefix/lib path.
\r
1111 IF(NOT NL_DRIVER_PREFIX)
\r
1112 IF(WITH_UNIX_STRUCTURE)
\r
1113 IF(LIBRARY_ARCHITECTURE)
\r
1114 SET(NL_DRIVER_PREFIX "lib/${LIBRARY_ARCHITECTURE}/nel" CACHE PATH "Installation path for drivers.")
\r
1117 SET(NL_DRIVER_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for drivers.")
\r
1119 SET(NL_DRIVER_PREFIX "lib${LIB_SUFFIX}/nel" CACHE PATH "Installation path for drivers.")
\r
1123 SET(NL_DRIVER_PREFIX "." CACHE PATH "Installation path for drivers.")
\r
1126 NL_MAKE_ABSOLUTE_PREFIX(NL_DRIVER_PREFIX NL_DRIVER_ABSOLUTE_PREFIX)
\r
1127 ENDMACRO(NL_SETUP_PREFIX_PATHS)
\r
1129 MACRO(RYZOM_SETUP_PREFIX_PATHS)
\r
1130 ## Allow override of install_prefix/etc path.
\r
1131 IF(NOT RYZOM_ETC_PREFIX)
\r
1132 IF(WITH_UNIX_STRUCTURE)
\r
1133 SET(RYZOM_ETC_PREFIX "etc/ryzom" CACHE PATH "Installation path for configurations")
\r
1135 SET(RYZOM_ETC_PREFIX "." CACHE PATH "Installation path for configurations")
\r
1138 NL_MAKE_ABSOLUTE_PREFIX(RYZOM_ETC_PREFIX RYZOM_ETC_ABSOLUTE_PREFIX)
\r
1140 ## Allow override of install_prefix/share path.
\r
1141 IF(NOT RYZOM_SHARE_PREFIX)
\r
1142 IF(WITH_UNIX_STRUCTURE)
\r
1143 SET(RYZOM_SHARE_PREFIX "share/ryzom" CACHE PATH "Installation path for data.")
\r
1145 SET(RYZOM_SHARE_PREFIX "." CACHE PATH "Installation path for data.")
\r
1148 NL_MAKE_ABSOLUTE_PREFIX(RYZOM_SHARE_PREFIX RYZOM_SHARE_ABSOLUTE_PREFIX)
\r
1150 ## Allow override of install_prefix/sbin path.
\r
1151 IF(NOT RYZOM_SBIN_PREFIX)
\r
1152 IF(WITH_UNIX_STRUCTURE)
\r
1153 SET(RYZOM_SBIN_PREFIX "sbin${LIB_SUFFIX}" CACHE PATH "Installation path for admin tools and services.")
\r
1155 SET(RYZOM_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.")
\r
1158 NL_MAKE_ABSOLUTE_PREFIX(RYZOM_SBIN_PREFIX RYZOM_SBIN_ABSOLUTE_PREFIX)
\r
1160 ## Allow override of install_prefix/bin path.
\r
1161 IF(NOT RYZOM_BIN_PREFIX)
\r
1162 IF(WITH_UNIX_STRUCTURE)
\r
1163 SET(RYZOM_BIN_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for tools.")
\r
1165 SET(RYZOM_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.")
\r
1168 NL_MAKE_ABSOLUTE_PREFIX(RYZOM_BIN_PREFIX RYZOM_BIN_ABSOLUTE_PREFIX)
\r
1170 ## Allow override of install_prefix/lib path.
\r
1171 IF(NOT RYZOM_LIB_PREFIX)
\r
1172 IF(LIBRARY_ARCHITECTURE)
\r
1173 SET(RYZOM_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.")
\r
1175 SET(RYZOM_LIB_PREFIX "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries.")
\r
1178 NL_MAKE_ABSOLUTE_PREFIX(RYZOM_LIB_PREFIX RYZOM_LIB_ABSOLUTE_PREFIX)
\r
1180 ## Allow override of install_prefix/games path.
\r
1181 IF(NOT RYZOM_GAMES_PREFIX)
\r
1182 IF(WITH_UNIX_STRUCTURE)
\r
1183 SET(RYZOM_GAMES_PREFIX "games" CACHE PATH "Installation path for client.")
\r
1185 SET(RYZOM_GAMES_PREFIX "." CACHE PATH "Installation path for tools and applications.")
\r
1188 NL_MAKE_ABSOLUTE_PREFIX(RYZOM_GAMES_PREFIX RYZOM_GAMES_ABSOLUTE_PREFIX)
\r
1190 ENDMACRO(RYZOM_SETUP_PREFIX_PATHS)
\r
1192 MACRO(SETUP_EXTERNAL)
\r
1194 FIND_PACKAGE(External REQUIRED)
\r
1198 FIND_PACKAGE(External REQUIRED)
\r
1200 # If using custom boost, we need to define the right variables used by official boost CMake module
\r
1201 IF(DEFINED BOOST_DIR)
\r
1202 SET(BOOST_INCLUDEDIR ${BOOST_DIR}/include)
\r
1203 SET(BOOST_LIBRARYDIR ${BOOST_DIR}/lib)
\r
1206 FIND_PACKAGE(External QUIET)
\r
1209 IF(WITH_STATIC_EXTERNAL)
\r
1210 # Look only for static libraries because systems libraries are using Frameworks
\r
1211 SET(CMAKE_FIND_LIBRARY_SUFFIXES .a)
\r
1213 SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib .so .a)
\r
1216 IF(WITH_STATIC_EXTERNAL)
\r
1217 SET(CMAKE_FIND_LIBRARY_SUFFIXES .a .so)
\r
1219 SET(CMAKE_FIND_LIBRARY_SUFFIXES .so .a)
\r
1224 # Android, iOS and Mac OS X have pthread, but no need to link to libpthread
\r
1225 IF(ANDROID OR APPLE)
\r
1226 SET(CMAKE_USE_PTHREADS_INIT 1)
\r
1227 SET(Threads_FOUND TRUE)
\r
1229 SET(THREADS_HAVE_PTHREAD_ARG ON)
\r
1230 FIND_PACKAGE(Threads)
\r
1231 # TODO: replace all -l<lib> by absolute path to <lib> in CMAKE_THREAD_LIBS_INIT
\r
1235 FIND_PACKAGE(STLport REQUIRED)
\r
1236 INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR})
\r
1240 # Must include DXSDK before WINSDK
\r
1241 FIND_PACKAGE(DirectXSDK REQUIRED)
\r
1242 # IF(DXSDK_INCLUDE_DIR)
\r
1243 # INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR})
\r
1248 FIND_PACKAGE(MSVC REQUIRED)
\r
1249 FIND_PACKAGE(WindowsSDK REQUIRED)
\r