Fix
[ryzomcore.git] / CMakeModules / nel.cmake
blobb944516b57b0f452c46b8eacff7224a6b15adc92
1 # Force Release configuration for compiler checks\r
2 SET(CMAKE_TRY_COMPILE_CONFIGURATION "Release")\r
3 \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
7 ENDIF()\r
8 \r
9 # Declare CMAKE_CONFIGURATION_TYPES before PROJECT\r
10 SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)\r
12 ###\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
15 ###\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
20   ENDIF()\r
21 ENDMACRO(NL_GEN_PC)\r
23 ###\r
24 #\r
25 ###\r
26 MACRO(NL_TARGET_LIB name)\r
27   IF(WITH_STATIC)\r
28     ADD_LIBRARY(${name} STATIC ${ARGN})\r
29   ELSE()\r
30     ADD_LIBRARY(${name} SHARED ${ARGN})\r
31   ENDIF()\r
32 ENDMACRO(NL_TARGET_LIB)\r
34 ###\r
35 #\r
36 ###\r
37 MACRO(NL_TARGET_DRIVER name)\r
38   IF(WITH_STATIC_DRIVERS)\r
39     ADD_LIBRARY(${name} STATIC ${ARGN})\r
40   ELSE()\r
41     ADD_LIBRARY(${name} MODULE ${ARGN})\r
42   ENDIF()\r
43 ENDMACRO(NL_TARGET_DRIVER)\r
45 ###\r
46 # Helper macro that sets the default library properties.\r
47 # Argument: name - the target name whose properties are being set\r
48 # Argument:\r
49 ###\r
50 MACRO(NL_DEFAULT_PROPS name label)\r
51   IF(TARGET revision)\r
52     # explicitly say that the target depends on revision.h\r
53     ADD_DEPENDENCIES(${name} revision)\r
54   ENDIF()\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
65     IF(NL_LIB_PREFIX)\r
66       SET_TARGET_PROPERTIES(${name} PROPERTIES INSTALL_NAME_DIR ${NL_LIB_PREFIX})\r
67     ENDIF()\r
68   ENDIF()\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
74     IF(TARGET_X64)\r
75       # Target Windows XP 64 bits\r
76       SET(_SUBSYSTEM_VERSION "5.02")\r
77     ELSE()\r
78       # Target Windows XP\r
79       SET(_SUBSYSTEM_VERSION "5.01")\r
80     ENDIF()\r
82     IF(_VALUE)\r
83       # GUI\r
84       SET(_SUBSYSTEM "WINDOWS")\r
85     ELSE()\r
86       # Console\r
87       SET(_SUBSYSTEM "CONSOLE")\r
88     ENDIF()\r
90     SET_TARGET_PROPERTIES(${name} PROPERTIES\r
91       VERSION ${NL_VERSION}\r
92       SOVERSION ${NL_VERSION_MAJOR}\r
93       COMPILE_FLAGS "/GA"\r
94       LINK_FLAGS "/VERSION:${NL_VERSION_MAJOR}.${NL_VERSION_MINOR} /SUBSYSTEM:${_SUBSYSTEM},${_SUBSYSTEM_VERSION}")\r
95   ENDIF()\r
96 ENDMACRO(NL_DEFAULT_PROPS)\r
98 ###\r
99 # Adds the target suffix on Windows.\r
100 # Argument: name - the library's target name.\r
101 ###\r
102 MACRO(NL_ADD_LIB_SUFFIX name)\r
103   IF(WIN32)\r
104     SET_TARGET_PROPERTIES(${name} PROPERTIES DEBUG_POSTFIX "_d" RELEASE_POSTFIX "_r")\r
105   ENDIF()\r
106 ENDMACRO(NL_ADD_LIB_SUFFIX)\r
108 ###\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
111 ###\r
112 MACRO(NL_ADD_RUNTIME_FLAGS name)\r
113   IF(WIN32)\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
117   ENDIF()\r
118   IF(WITH_STLPORT)\r
119     TARGET_LINK_LIBRARIES(${name} ${STLPORT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})\r
120   ENDIF()\r
121 ENDMACRO(NL_ADD_RUNTIME_FLAGS)\r
123 MACRO(NL_ADD_STATIC_VID_DRIVERS name)\r
124 IF(HUNTER_ENABLED)\r
125   IF(WIN32)\r
126     SET(drv_suffix "_win")\r
127   ELSE()\r
128     SET(drv_suffix "")\r
129   ENDIF()\r
130   IF(WIN32 AND WITH_DRIVER_DIRECT3D)\r
131     TARGET_LINK_LIBRARIES(${name} nel_drv_direct3d${drv_suffix})\r
132   ENDIF()\r
133   IF(WITH_DRIVER_OPENGL)\r
134     TARGET_LINK_LIBRARIES(${name} nel_drv_opengl${drv_suffix})\r
135   ENDIF()\r
136   IF(WITH_DRIVER_OPENGLES)\r
137     TARGET_LINK_LIBRARIES(${name} nel_drv_opengles${drv_suffix})\r
138   ENDIF()\r
139 ELSE()\r
140   IF(WITH_STATIC_DRIVERS)\r
141     IF(WIN32)\r
142       IF(WITH_DRIVER_DIRECT3D)\r
143         TARGET_LINK_LIBRARIES(${name} nel_drv_direct3d_win)\r
144       ENDIF()\r
145     ENDIF()\r
147     IF(WITH_DRIVER_OPENGL)\r
148       IF(WIN32)\r
149         TARGET_LINK_LIBRARIES(${name} nel_drv_opengl_win)\r
150       ELSE()\r
151         TARGET_LINK_LIBRARIES(${name} nel_drv_opengl)\r
152       ENDIF()\r
153     ENDIF()\r
155     IF(WITH_DRIVER_OPENGLES)\r
156       IF(WIN32)\r
157         TARGET_LINK_LIBRARIES(${name} nel_drv_opengles_win)\r
158       ELSE()\r
159         TARGET_LINK_LIBRARIES(${name} nel_drv_opengles)\r
160       ENDIF()\r
161     ENDIF()\r
162   ENDIF()\r
163 ENDIF()#hunter\r
164 ENDMACRO(NL_ADD_STATIC_VID_DRIVERS)\r
166 MACRO(NL_ADD_STATIC_SND_DRIVERS name)\r
167 IF(HUNTER_ENABLED)\r
168   IF(WIN32)\r
169     SET(drv_suffix "_win")\r
170   ELSE()\r
171     SET(drv_suffix "")\r
172   ENDIF()\r
173   IF(WIN32 AND WITH_DRIVER_DSOUND)\r
174     TARGET_LINK_LIBRARIES(${name} nel_drv_dsound${drv_suffix})\r
175   ENDIF()\r
176   IF(WIN32 AND WITH_DRIVER_XAUDIO2)\r
177     TARGET_LINK_LIBRARIES(${name} nel_drv_xaudio2${drv_suffix})\r
178   ENDIF()\r
179   IF(WITH_DRIVER_FMOD)\r
180     TARGET_LINK_LIBRARIES(${name} nel_drv_fmod${drv_suffix})\r
181   ENDIF()\r
182   IF(WITH_DRIVER_OPENAL)\r
183     TARGET_LINK_LIBRARIES(${name} nel_drv_openal${drv_suffix})\r
184   ENDIF()\r
185 ELSE()\r
186   IF(WITH_STATIC_DRIVERS)\r
187     IF(WIN32)\r
188       IF(WITH_DRIVER_DSOUND)\r
189         TARGET_LINK_LIBRARIES(${name} nel_drv_dsound_win)\r
190       ENDIF()\r
192       IF(WITH_DRIVER_XAUDIO2)\r
193         TARGET_LINK_LIBRARIES(${name} nel_drv_xaudio2_win)\r
194       ENDIF()\r
196       IF(WITH_DRIVER_OPENAL)\r
197         TARGET_LINK_LIBRARIES(${name} nel_drv_openal_win)\r
198       ENDIF()\r
200       IF(WITH_DRIVER_FMOD)\r
201         TARGET_LINK_LIBRARIES(${name} nel_drv_fmod_win)\r
202       ENDIF()\r
203     ELSE()\r
204       IF(WITH_DRIVER_OPENAL)\r
205         TARGET_LINK_LIBRARIES(${name} nel_drv_openal)\r
206       ENDIF()\r
208       IF(WITH_DRIVER_FMOD)\r
209         TARGET_LINK_LIBRARIES(${name} nel_drv_fmod)\r
210       ENDIF()\r
211     ENDIF()\r
213   ENDIF()\r
214 ENDIF() #hunter\r
215 ENDMACRO(NL_ADD_STATIC_SND_DRIVERS)\r
217 ###\r
218 # Checks build vs. source location. Prevents In-Source builds.\r
219 ###\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
227    rm CMakeCache.txt\r
228    mkdir cmake\r
229    cd cmake\r
230    cmake ..\r
231     ")\r
232   ENDIF()\r
234 ENDMACRO(CHECK_OUT_OF_SOURCE)\r
236 MACRO(NL_SETUP_DEFAULT_OPTIONS)\r
237   IF(WITH_QT)\r
238     OPTION(WITH_STUDIO              "Build Core Studio"                             OFF )\r
239   ENDIF()\r
241   ###\r
242   # Features\r
243   ###\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
251   IF(WIN32)\r
252     OPTION(WITH_STATIC            "With static libraries."                        ON )\r
253   ELSE()\r
254     OPTION(WITH_STATIC            "With static libraries."                        OFF)\r
255   ENDIF()\r
256   IF (WITH_STATIC)\r
257     OPTION(WITH_STATIC_LIBXML2    "With static libxml2"                           ON )\r
258   ELSE()\r
259     OPTION(WITH_STATIC_LIBXML2    "With static libxml2"                           OFF)\r
260   ENDIF()\r
261   IF (WITH_STATIC)\r
262     OPTION(WITH_STATIC_CURL       "With static curl"                              ON )\r
263   ELSE()\r
264     OPTION(WITH_STATIC_CURL       "With static curl"                              OFF)\r
265   ENDIF()\r
266   IF(APPLE)\r
267     OPTION(WITH_LIBXML2_ICONV     "With libxml2 using iconv"                      ON )\r
268   ELSE()\r
269     OPTION(WITH_LIBXML2_ICONV     "With libxml2 using iconv"                      OFF)\r
270   ENDIF()\r
271   OPTION(WITH_STATIC_DRIVERS      "With static drivers."                          OFF)\r
272   IF(WIN32)\r
273     OPTION(WITH_EXTERNAL          "With provided external."                       ON )\r
274   ELSE()\r
275     OPTION(WITH_EXTERNAL          "With provided external."                       OFF)\r
276   ENDIF()\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
281   ELSE()\r
282     OPTION(WITH_UNIX_STRUCTURE    "Use UNIX structure (bin, include, lib)"        OFF)\r
283   ENDIF()\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
291   ###\r
292   # GUI toolkits\r
293   ###\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
300   ELSE()\r
301     OPTION(WITH_MFC               "With MFC Support"                              OFF)\r
302   ENDIF()\r
304   ###\r
305   # Optional support\r
306   ###\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
312   ELSE()\r
313     OPTION(WITH_STLPORT           "With STLport support."                         OFF)\r
314   ENDIF()\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
332   ###\r
333   # Core libraries\r
334   ###\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
345   ###\r
346   # Drivers Support\r
347   ###\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
356   ###\r
357   # Optional support\r
358   ###\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
374   IF(NOT MSVC)\r
375     OPTION(WITH_GCC_FPMATH_BOTH   "With GCC -mfpmath=both"                        OFF)\r
376   ENDIF()\r
377 ENDMACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)\r
379 MACRO(NL_SETUP_NELNS_DEFAULT_OPTIONS)\r
380   ###\r
381   # Core libraries\r
382   ###\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
388   ###\r
389   # Core libraries\r
390   ###\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
396   ###\r
397   # Optional support\r
398   ###\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
410   ###\r
411   # Core libraries\r
412   ###\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
420 ENDMACRO()\r
422 MACRO(ADD_PLATFORM_LINKFLAGS _FLAGS)\r
423   SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${_FLAGS}")\r
424 ENDMACRO()\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
430   ENDFOREACH()\r
431 ENDMACRO()\r
433 MACRO(NL_SETUP_BUILD)\r
434   #-----------------------------------------------------------------------------\r
435   # Setup the buildmode variables.\r
436   #\r
437   # None                  = NL_RELEASE\r
438   # Debug                 = NL_DEBUG\r
439   # Release               = NL_RELEASE\r
441   IF(CMAKE_BUILD_TYPE MATCHES "Debug")\r
442     SET(NL_BUILD_MODE "NL_DEBUG")\r
443   ELSE()\r
444     IF(CMAKE_BUILD_TYPE MATCHES "Release")\r
445       SET(NL_BUILD_MODE "NL_RELEASE")\r
446     ELSE()\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
450     ENDIF()\r
451   ENDIF()\r
453   IF(CMAKE_CXX_LIBRARY_ARCHITECTURE)\r
454     SET(HOST_CPU ${CMAKE_CXX_LIBRARY_ARCHITECTURE})\r
455   ELSE()\r
456     SET(HOST_CPU ${CMAKE_HOST_SYSTEM_PROCESSOR})\r
457   ENDIF()\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
463   ENDIF()\r
465   # Determine target CPU\r
467   # If not specified, use the same CPU as host\r
468   IF(NOT TARGET_CPU)\r
469     SET(TARGET_CPU ${HOST_CPU})\r
470   ENDIF()\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
476   ENDIF()\r
478   IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")\r
479     SET(CLANG ON)\r
480     MESSAGE(STATUS "Using Clang ${CMAKE_CXX_COMPILER_VERSION} compiler")\r
481   ENDIF()\r
483   IF(CMAKE_GENERATOR MATCHES "Xcode")\r
484     SET(XCODE ON)\r
485     MESSAGE(STATUS "Generating Xcode project")\r
486   ENDIF()\r
488   IF(CMAKE_GENERATOR MATCHES "NMake")\r
489     SET(NMAKE ON)\r
490     MESSAGE(STATUS "Generating NMake project")\r
491   ENDIF()\r
493   IF(CMAKE_GENERATOR MATCHES "Ninja")\r
494     SET(NINJA ON)\r
495     MESSAGE(STATUS "Generating Ninja project")\r
496   ENDIF()\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
505       ENDIF()\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
510       ELSE()\r
511         SET(TARGET_CPU "x86")\r
512       ENDIF()\r
513     ELSEIF(HOST_CPU MATCHES "arm")\r
514       SET(TARGET_CPU "arm")\r
515     ELSE()\r
516       SET(TARGET_CPU "unknown")\r
517       MESSAGE(STATUS "Unknown architecture: ${HOST_CPU}")\r
518     ENDIF()\r
519     # TODO: add checks for PPC\r
520   ELSE()\r
521     MESSAGE(STATUS "Compiling on ${HOST_CPU} for ${TARGET_CPU}")\r
522   ENDIF()\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
535   # Strip spaces\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
542       SET(TARGET_X64 1)\r
543       SET(TARGET_X86 1)\r
544     ELSEIF(TARGET_CPU STREQUAL "x86")\r
545       SET(TARGET_X86 1)\r
546     ELSEIF(TARGET_CPU STREQUAL "arm64")\r
547       SET(TARGET_ARM 1)\r
548       SET(TARGET_ARM64 1)\r
549     ELSEIF(TARGET_CPU STREQUAL "armv7s")\r
550       SET(TARGET_ARM 1)\r
551       SET(TARGET_ARMV7S 1)\r
552     ELSEIF(TARGET_CPU STREQUAL "armv7")\r
553       SET(TARGET_ARM 1)\r
554       SET(TARGET_ARMV7 1)\r
555     ELSEIF(TARGET_CPU STREQUAL "armv6")\r
556       SET(TARGET_ARM 1)\r
557       SET(TARGET_ARMV6 1)\r
558     ELSEIF(TARGET_CPU STREQUAL "armv5")\r
559       SET(TARGET_ARM 1)\r
560       SET(TARGET_ARMV5 1)\r
561     ELSEIF(TARGET_CPU STREQUAL "arm")\r
562       SET(TARGET_ARM 1)\r
563     ELSEIF(TARGET_CPU STREQUAL "mips")\r
564       SET(TARGET_MIPS 1)\r
565     ENDIF()\r
567     IF(TARGET_ARM)\r
568       IF(TARGET_ARM64)\r
569         ADD_PLATFORM_FLAGS("-DHAVE_ARM64")\r
570       ENDIF()\r
572       IF(TARGET_ARMV7S)\r
573         ADD_PLATFORM_FLAGS("-DHAVE_ARMV7S")\r
574       ENDIF()\r
576       IF(TARGET_ARMV7)\r
577         ADD_PLATFORM_FLAGS("-DHAVE_ARMV7")\r
578       ENDIF()\r
580       IF(TARGET_ARMV6)\r
581         ADD_PLATFORM_FLAGS("-HAVE_ARMV6")\r
582       ENDIF()\r
584       ADD_PLATFORM_FLAGS("-DHAVE_ARM")\r
585     ENDIF()\r
587     IF(TARGET_X86)\r
588       ADD_PLATFORM_FLAGS("-DHAVE_X86")\r
589     ENDIF()\r
591     IF(TARGET_X64)\r
592       ADD_PLATFORM_FLAGS("-DHAVE_X64 -DHAVE_X86_64")\r
593     ENDIF()\r
595     IF(TARGET_MIPS)\r
596       ADD_PLATFORM_FLAGS("-DHAVE_MIPS")\r
597     ENDIF()\r
598   ENDIF()\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
603     IF(TARGET_X64)\r
604       SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib64 /usr/lib64)\r
605     ELSEIF(TARGET_X86)\r
606       SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib32 /usr/lib32)\r
607     ENDIF()\r
608   ENDIF()\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
613   ENDIF()\r
615   IF(WITH_LOGGING)\r
616     ADD_PLATFORM_FLAGS("-DENABLE_LOGS")\r
617   ENDIF()\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
622   ENDIF()\r
624   IF(MSVC)\r
625     # Ignore default include paths\r
626     ADD_PLATFORM_FLAGS("/X")\r
628     IF(MSVC14)\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
637         SET(MSVC1411 ON)\r
638       ELSEIF(MSVC_VERSION EQUAL "1910")\r
639         SET(MSVC1410 ON)\r
640       ENDIF()\r
641     ELSEIF(MSVC12)\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
647     ELSEIF(MSVC11)\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
653     ELSEIF(MSVC10)\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
659     ELSEIF(MSVC90)\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
665     ELSEIF(MSVC80)\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
671     ELSE()\r
672       MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}")\r
673     ENDIF()\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
677     # huge PCH\r
678     ADD_PLATFORM_FLAGS("/Zm1000")\r
680     IF(TARGET_X64)\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
685     ELSE()\r
686       # Allows 32 bits applications to use 3 GB of RAM\r
687       ADD_PLATFORM_LINKFLAGS("/LARGEADDRESSAWARE")\r
688     ENDIF()\r
690     # Exceptions are only set for C++\r
691     SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} /EHa")\r
693     IF(WITH_SYMBOLS)\r
694       SET(NL_RELEASE_CFLAGS "/Zi ${NL_RELEASE_CFLAGS}")\r
695       SET(NL_RELEASE_LINKFLAGS "/DEBUG ${NL_RELEASE_LINKFLAGS}")\r
696     ELSE()\r
697       SET(NL_RELEASE_LINKFLAGS "/RELEASE ${NL_RELEASE_LINKFLAGS}")\r
698     ENDIF()\r
700     IF(WITH_STATIC_RUNTIMES)\r
701       SET(RUNTIME_FLAG "/MT")\r
702     ELSE()\r
703       SET(RUNTIME_FLAG "/MD")\r
704     ENDIF()\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
711     IF(WITH_WARNINGS)\r
712       SET(DEBUG_CFLAGS "/W4 ${DEBUG_CFLAGS}")\r
713     ELSE()\r
714       SET(DEBUG_CFLAGS "/W3 ${DEBUG_CFLAGS}")\r
715     ENDIF()\r
716   ELSE()\r
717     IF(WIN32)\r
718       ADD_PLATFORM_FLAGS("-DWIN32 -D_WIN32")\r
720       IF(CLANG)\r
721         ADD_PLATFORM_FLAGS("-nobuiltininc")\r
722       ENDIF()\r
723     ENDIF()\r
725     IF(WITH_SSE3)\r
726       ADD_PLATFORM_FLAGS("-msse3")\r
727     ENDIF()\r
729     IF(WITH_GCC_FPMATH_BOTH)\r
730       ADD_PLATFORM_FLAGS("-mfpmath=both")\r
731     ENDIF()\r
733     IF(APPLE)\r
734       SET(OBJC_FLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch -fobjc-weak)\r
736       IF(NOT XCODE)\r
737         IF(CMAKE_OSX_ARCHITECTURES)\r
738           SET(TARGETS_COUNT 0)\r
739           SET(_ARCHS)\r
740           FOREACH(_ARCH ${CMAKE_OSX_ARCHITECTURES})\r
741             IF(_ARCH STREQUAL "i386")\r
742               SET(_ARCHS "${_ARCHS} i386")\r
743               SET(TARGET_X86 1)\r
744               MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")\r
745             ELSEIF(_ARCH STREQUAL "x86_64")\r
746               SET(_ARCHS "${_ARCHS} x86_64")\r
747               SET(TARGET_X64 1)\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
752               SET(TARGET_ARM 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
757               SET(TARGET_ARM 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
762               SET(TARGET_ARM 1)\r
763               MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")\r
764             ELSEIF(_ARCH STREQUAL "mips")\r
765               SET(_ARCHS "${_ARCHS} mips")\r
766               SET(TARGET_MIPS 1)\r
767               MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")\r
768             ELSE()\r
769               SET(_ARCHS "${_ARCHS} unknwon(${_ARCH})")\r
770             ENDIF()\r
771           ENDFOREACH(_ARCH)\r
772           MESSAGE(STATUS "Compiling under Mac OS X for ${TARGETS_COUNT} architectures: ${_ARCHS}")\r
773         ELSE()\r
774           SET(TARGETS_COUNT 0)\r
775         ENDIF()\r
777         IF(TARGETS_COUNT EQUAL 1)\r
778           IF(TARGET_ARM)\r
779             IF(TARGET_ARMV7S)\r
780               ADD_PLATFORM_FLAGS("-arch armv7s -DHAVE_ARMV7S")\r
781             ENDIF()\r
783             IF(TARGET_ARMV7)\r
784               ADD_PLATFORM_FLAGS("-arch armv7 -DHAVE_ARMV7")\r
785             ENDIF()\r
787             IF(TARGET_ARMV6)\r
788               ADD_PLATFORM_FLAGS("-arch armv6 -DHAVE_ARMV6")\r
789             ENDIF()\r
791             IF(TARGET_ARMV5)\r
792               ADD_PLATFORM_FLAGS("-arch armv5 -DHAVE_ARMV5")\r
793             ENDIF()\r
795             ADD_PLATFORM_FLAGS("-mthumb -DHAVE_ARM")\r
796           ENDIF()\r
798           IF(TARGET_X64)\r
799             ADD_PLATFORM_FLAGS("-arch x86_64 -DHAVE_X64 -DHAVE_X86_64 -DHAVE_X86")\r
800           ELSEIF(TARGET_X86)\r
801             ADD_PLATFORM_FLAGS("-arch i386 -DHAVE_X86")\r
802           ENDIF()\r
804           IF(TARGET_MIPS)\r
805             ADD_PLATFORM_FLAGS("-arch mips -DHAVE_MIPS")\r
806           ENDIF()\r
807         ELSEIF(TARGETS_COUNT EQUAL 0)\r
808           # Not using CMAKE_OSX_ARCHITECTURES, HAVE_XXX already defined before\r
809           IF(TARGET_ARM)\r
810             IF(TARGET_ARMV7S)\r
811               ADD_PLATFORM_FLAGS("-arch armv7s")\r
812             ENDIF()\r
814             IF(TARGET_ARMV7)\r
815               ADD_PLATFORM_FLAGS("-arch armv7")\r
816             ENDIF()\r
818             IF(TARGET_ARMV6)\r
819               ADD_PLATFORM_FLAGS("-arch armv6")\r
820             ENDIF()\r
822             IF(TARGET_ARMV5)\r
823               ADD_PLATFORM_FLAGS("-arch armv5")\r
824             ENDIF()\r
826             ADD_PLATFORM_FLAGS("-mthumb")\r
827           ENDIF()\r
829           IF(TARGET_X64)\r
830             ADD_PLATFORM_FLAGS("-arch x86_64")\r
831           ELSEIF(TARGET_X86)\r
832             ADD_PLATFORM_FLAGS("-arch i386")\r
833           ENDIF()\r
835           IF(TARGET_MIPS)\r
836             ADD_PLATFORM_FLAGS("-arch mips")\r
837           ENDIF()\r
838         ELSE()\r
839           IF(TARGET_ARMV6)\r
840             ADD_PLATFORM_FLAGS("-Xarch_armv6 -mthumb -Xarch_armv6 -DHAVE_ARM -Xarch_armv6 -DHAVE_ARMV6")\r
841           ENDIF()\r
843           IF(TARGET_ARMV7)\r
844             ADD_PLATFORM_FLAGS("-Xarch_armv7 -mthumb -Xarch_armv7 -DHAVE_ARM -Xarch_armv7 -DHAVE_ARMV7")\r
845           ENDIF()\r
847           IF(TARGET_X86)\r
848             ADD_PLATFORM_FLAGS("-Xarch_i386 -DHAVE_X86")\r
849           ENDIF()\r
851           IF(TARGET_X64)\r
852             ADD_PLATFORM_FLAGS("-Xarch_x86_64 -DHAVE_X64 -Xarch_x86_64 -DHAVE_X86_64")\r
853           ENDIF()\r
855           IF(TARGET_MIPS)\r
856             ADD_PLATFORM_FLAGS("-Xarch_mips -DHAVE_MIPS")\r
857           ENDIF()\r
858         ENDIF()\r
860         IF(IOS)\r
861           SET(CMAKE_OSX_SYSROOT "" CACHE PATH "" FORCE)\r
863           IF(IOS_VERSION)\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
868           ENDIF()\r
870           IF(CMAKE_IOS_SYSROOT)\r
871             IF(TARGET_ARMV7S)\r
872               IF(TARGETS_COUNT GREATER 1)\r
873                 SET(XARCH "-Xarch_armv7s ")\r
874               ENDIF()\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
879             ENDIF()\r
881             IF(TARGET_ARMV7)\r
882               IF(TARGETS_COUNT GREATER 1)\r
883                 SET(XARCH "-Xarch_armv7 ")\r
884               ENDIF()\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
889             ENDIF()\r
891             IF(TARGET_ARMV6)\r
892               IF(TARGETS_COUNT GREATER 1)\r
893                 SET(XARCH "-Xarch_armv6 ")\r
894               ENDIF()\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
899             ENDIF()\r
900           ENDIF()\r
902           IF(CMAKE_IOS_SIMULATOR_SYSROOT AND TARGET_X86)\r
903             IF(TARGETS_COUNT GREATER 1)\r
904               SET(XARCH "-Xarch_i386 ")\r
905             ENDIF()\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
911             ENDIF()\r
912           ENDIF()\r
913         ELSE()\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
918             ENDIF()\r
919             ADD_PLATFORM_LINKFLAGS("-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}")\r
920           ENDIF()\r
921         ENDIF()\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
931         ENDIF()\r
932       ENDIF()\r
933     ELSE()\r
934       IF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86")\r
935         ADD_PLATFORM_FLAGS("-m32 -march=i686")\r
936       ENDIF()\r
938       IF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64")\r
939         ADD_PLATFORM_FLAGS("-m64")\r
940       ENDIF()\r
941     ENDIF()\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
946     ENDIF()\r
948     ADD_PLATFORM_FLAGS("-D_REENTRANT")\r
950     # hardening\r
951     ADD_PLATFORM_FLAGS("-D_FORTIFY_SOURCE=2")\r
953     IF(NOT WITH_LOW_MEMORY)\r
954       ADD_PLATFORM_FLAGS("-pipe")\r
955     ENDIF()\r
957     IF(WITH_COVERAGE)\r
958       ADD_PLATFORM_FLAGS("-fprofile-arcs -ftest-coverage")\r
959     ENDIF()\r
961     IF(WITH_WARNINGS)\r
962       ADD_PLATFORM_FLAGS("-Wall")\r
963     ELSE()\r
964       # Check wrong formats in printf-like functions\r
965       ADD_PLATFORM_FLAGS("-Wformat -Werror=format-security")\r
966     ENDIF()\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
973     ELSEIF(CLANG)\r
974       ADD_PLATFORM_FLAGS("-Wno-unused-private-field -Wno-unused-local-typedef")\r
975     ENDIF()\r
977     IF(ANDROID)\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
983       IF(TARGET_ARM)\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
987         IF(TARGET_ARMV7)\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
992         ENDIF()\r
994         SET(TARGET_THUMB ON)\r
995         IF(TARGET_THUMB)\r
996           ADD_PLATFORM_FLAGS("-mthumb -finline-limit=64")\r
997           SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -marm")\r
998         ELSE()\r
999           ADD_PLATFORM_FLAGS("-funswitch-loops -finline-limit=300")\r
1000         ENDIF()\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
1008       ENDIF()\r
1009       ADD_PLATFORM_LINKFLAGS("-Wl,-z,noexecstack")\r
1010       ADD_PLATFORM_LINKFLAGS("-L${PLATFORM_ROOT}/usr/lib")\r
1011     ENDIF()\r
1013     IF(APPLE)\r
1014       ADD_PLATFORM_FLAGS("-gdwarf-2 -D_DARWIN_UNLIMITED_STREAMS")\r
1015     ENDIF()\r
1017     # Fix "relocation R_X86_64_32 against.." error on x64 platforms\r
1018     IF(NOT MINGW)\r
1019       ADD_PLATFORM_FLAGS("-fPIC")\r
1020     ENDIF()\r
1022     # hardening\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
1026     IF(WITH_WARNINGS)\r
1027       ADD_PLATFORM_FLAGS("-Wstack-protector")\r
1028     ENDIF()\r
1030     # Fix undefined reference to `__stack_chk_fail' error\r
1031     ADD_PLATFORM_LINKFLAGS("-lc")\r
1033     IF(NOT APPLE)\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
1038       ENDIF()\r
1039     ENDIF()\r
1041     IF(NOT APPLE)\r
1042       # hardening\r
1043       ADD_PLATFORM_LINKFLAGS("-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now")\r
1044     ENDIF()\r
1046     IF(WITH_SYMBOLS)\r
1047       SET(NL_RELEASE_CFLAGS "${NL_RELEASE_CFLAGS} -g")\r
1048     ELSE()\r
1049       IF(APPLE)\r
1050         SET(NL_RELEASE_LINKFLAGS "-Wl,-dead_strip ${NL_RELEASE_LINKFLAGS}")\r
1051       ELSE()\r
1052         SET(NL_RELEASE_LINKFLAGS "-Wl,-s ${NL_RELEASE_LINKFLAGS}")\r
1053       ENDIF()\r
1054     ENDIF()\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
1058   ENDIF()\r
1059 ENDMACRO()\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
1068   ## Debug\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
1075   ## Release\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
1087   ELSE()\r
1088     IF(WITH_UNIX_STRUCTURE)\r
1089       SET(${NAME_ABSOLUTE} ${CMAKE_INSTALL_PREFIX}/${${NAME_RELATIVE}})\r
1090     ELSE()\r
1091       SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}})\r
1092     ENDIF()\r
1093   ENDIF()\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
1099   ELSE()\r
1100     SET(LIB_SUFFIX "")\r
1101   ENDIF()\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
1107     ELSE()\r
1108       SET(NL_ETC_PREFIX "." CACHE PATH "Installation path for configurations")\r
1109     ENDIF()\r
1110   ENDIF()\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
1117     ELSE()\r
1118       SET(NL_SHARE_PREFIX "." CACHE PATH "Installation path for data.")\r
1119     ENDIF()\r
1120   ENDIF()\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
1127     ELSE()\r
1128       SET(NL_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.")\r
1129     ENDIF()\r
1130   ENDIF()\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
1137     ELSE()\r
1138       SET(NL_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.")\r
1139     ENDIF()\r
1140   ENDIF()\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
1147     ELSE()\r
1148       SET(NL_LIB_PREFIX "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries.")\r
1149     ENDIF()\r
1150   ENDIF()\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
1158       ELSE()\r
1159         IF(WIN32)\r
1160           SET(NL_DRIVER_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for drivers.")\r
1161         ELSE()\r
1162           SET(NL_DRIVER_PREFIX "lib${LIB_SUFFIX}/nel" CACHE PATH "Installation path for drivers.")\r
1163         ENDIF()\r
1164       ENDIF()\r
1165     ELSE()\r
1166       SET(NL_DRIVER_PREFIX "." CACHE PATH "Installation path for drivers.")\r
1167     ENDIF()\r
1168   ENDIF()\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
1177     ELSE()\r
1178       SET(RYZOM_ETC_PREFIX "." CACHE PATH "Installation path for configurations")\r
1179     ENDIF()\r
1180   ENDIF()\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
1187     ELSE()\r
1188       SET(RYZOM_SHARE_PREFIX "." CACHE PATH "Installation path for data.")\r
1189     ENDIF()\r
1190   ENDIF()\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
1197     ELSE()\r
1198       SET(RYZOM_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.")\r
1199     ENDIF()\r
1200   ENDIF()\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
1207     ELSE()\r
1208       SET(RYZOM_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.")\r
1209     ENDIF()\r
1210   ENDIF()\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
1217     ELSE()\r
1218       SET(RYZOM_LIB_PREFIX "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries.")\r
1219     ENDIF()\r
1220   ENDIF()\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
1227     ELSE()\r
1228       SET(RYZOM_GAMES_PREFIX "." CACHE PATH "Installation path for tools and applications.")\r
1229     ENDIF()\r
1230   ENDIF()\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
1236   IF(WITH_EXTERNAL)\r
1237     FIND_PACKAGE(External REQUIRED)\r
1238   ENDIF()\r
1240   IF(WIN32)\r
1241     IF (HUNTER_ENABLED)\r
1242       FIND_PACKAGE(External QUIET)\r
1243     ELSE()\r
1244       FIND_PACKAGE(External REQUIRED)\r
1245     ENDIF()\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
1251     ENDIF()\r
1252   ELSE()\r
1253     FIND_PACKAGE(External QUIET)\r
1255     IF(APPLE)\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
1259       ELSE()\r
1260         SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib .so .a)\r
1261       ENDIF()\r
1262     ELSE()\r
1263       IF(WITH_STATIC_EXTERNAL)\r
1264         SET(CMAKE_FIND_LIBRARY_SUFFIXES .a .so)\r
1265       ELSE()\r
1266         SET(CMAKE_FIND_LIBRARY_SUFFIXES .so .a)\r
1267       ENDIF()\r
1268     ENDIF()\r
1269   ENDIF()\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
1275   ELSE()\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
1279   ENDIF()\r
1281   IF(WITH_STLPORT)\r
1282     FIND_PACKAGE(STLport REQUIRED)\r
1283     INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR})\r
1284   ENDIF()\r
1286   IF(WIN32)\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
1291     # ENDIF()\r
1292   ENDIF()\r
1294   IF(MSVC)\r
1295     FIND_PACKAGE(MSVC REQUIRED)\r
1296     FIND_PACKAGE(WindowsSDK REQUIRED)\r
1297     IF(NOT DXSDK_DIR)\r
1298       MESSAGE(FATAL_ERROR "DirectX SDK or DirectX files from Windows SDK not found.")\r
1299     ENDIF()\r
1300   ENDIF()\r
1301 ENDMACRO()\r