1 cmake_minimum_required(VERSION 3.5)
2 set_property(GLOBAL PROPERTY DEBUG_CONFIGURATIONS Debug Profile)
4 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Tools/CMake/modules")
7 # C/C++ languages required.
10 # Force C++11 support requirement
11 set (CMAKE_CXX_STANDARD 11)
13 if (DURANGO OR ORBIS OR ANDROID)
18 if (WIN32) # Either Win32 or Win64
20 include(Tools/CMake/toolchain/windows/WindowsPC-MSVC.cmake)
23 if(NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio")
24 set(valid_configs Debug Profile Release)
25 list(FIND valid_configs "${CMAKE_BUILD_TYPE}" config_index)
26 if(${config_index} EQUAL -1)
27 message(SEND_ERROR "Build type \"${CMAKE_BUILD_TYPE}\" is not supported, set CMAKE_BUILD_TYPE to one of ${valid_configs}")
31 include(${CMAKE_SOURCE_DIR}/Tools/CMake/CopyFilesToBin.cmake)
40 set(METADATA_PROJECT_NAME "CryEngine" CACHE STRING "Name of the solution project")
41 project(${METADATA_PROJECT_NAME}_CMake_${BUILD_PLATFORM} CXX C)
43 set(MODULES CACHE INTERNAL "Modules for monolithic builds" FORCE)
44 set(GAME_MODULES CACHE INTERNAL "Game Modules for monolithic builds" FORCE)
46 if (DURANGO OR ORBIS OR ANDROID)
47 # WIN32 Should be unset again after project( line to work correctly
52 set(game_folder CACHE INTERNAL "Game folder used for resource files on Windows" FORCE)
55 if (NOT METADATA_COMPANY)
56 set(METADATA_COMPANY "Crytek GmbH")
58 set(METADATA_COMPANY ${METADATA_COMPANY} CACHE STRING "Company name for executable metadata")
60 if (NOT METADATA_COPYRIGHT)
61 string(TIMESTAMP year "%Y")
62 set(METADATA_COPYRIGHT "(C) ${year} ${METADATA_COMPANY}")
64 set(METADATA_COPYRIGHT ${METADATA_COPYRIGHT} CACHE STRING "Copyright string for executable metadata")
67 set(VERSION "1.0.0.0")
69 set(METADATA_VERSION ${VERSION} CACHE STRING "Version number for executable metadata" FORCE)
70 string(REPLACE . , METADATA_VERSION_COMMA ${METADATA_VERSION})
73 if(LINUX32 OR LINUX64)
78 option(OPTION_PROFILE "Enable Profiling" ON)
79 option(OPTION_UNITY_BUILD "Enable Unity Build" ON)
81 option(OPTION_ENABLE_BROFILER "Enable Brofiler profiler support" ON)
84 if(WIN64 AND EXISTS "${CMAKE_SOURCE_DIR}/Code/Sandbox")
85 option(OPTION_SANDBOX "Enable Sandbox" OFF)
86 if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
87 set(OPTION_SANDBOX OFF)
90 # Sandbox cannot be built in release mode
91 set(CMAKE_CONFIGURATION_TYPES Debug Profile CACHE STRING "Reset the configurations to what we need" FORCE)
95 option(OPTION_RC "Include RC in the build" OFF)
96 option(OPTION_PCH "Enable Precompiled Headers" OFF)
99 option(PLUGIN_FPSPLUGIN "Frames per second sample plugin" OFF)
100 option(PLUGIN_VR_OCULUS "Oculus support" ON)
101 option(PLUGIN_VR_OPENVR "OpenVR support" ON)
102 option(PLUGIN_VR_OSVR "OSVR support" ON)
105 option(OPTION_CRYMONO "C# support" OFF)
108 # Print current project settings
109 MESSAGE(STATUS "CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}")
110 MESSAGE(STATUS "CMAKE_GENERATOR = ${CMAKE_GENERATOR}")
111 MESSAGE(STATUS "CMAKE_CONFIGURATION_TYPES = ${CMAKE_CONFIGURATION_TYPES}")
112 MESSAGE(STATUS "BUILD_PLATFORM = ${BUILD_PLATFORM}")
113 MESSAGE(STATUS "OPTION_PROFILE = ${OPTION_PROFILE}")
114 MESSAGE(STATUS "OPTION_PCH = ${OPTION_PCH}")
117 set_property( DIRECTORY PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Release>:_PROFILE> )
119 set_property( DIRECTORY PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Release>:_RELEASE> )
122 if(OPTION_UNITY_BUILD)
123 message(STATUS "UNITY BUILD Enabled")
127 set(OPTION_STATIC_LINKING TRUE)
129 option(OPTION_STATIC_LINKING "Link all CryEngine modules as static libs to single exe" OFF)
132 if (MSVC_VERSION EQUAL 1900) # Visual Studio 2015
133 set(MSVC_LIB_PREFIX vc140)
134 set(QT_DIR ${CMAKE_SOURCE_DIR}/Code/SDKs/Qt/5.6/msvc2015_64)
135 elseif (MSVC_VERSION EQUAL 1800) # Visual Studio 2013
136 set(MSVC_LIB_PREFIX vc120)
137 set(QT_DIR ${CMAKE_SOURCE_DIR}/Code/SDKs/Qt/5.6/msvc2013_64)
138 elseif (MSVC_VERSION EQUAL 1700) # Visual Studio 2012
139 set(MSVC_LIB_PREFIX "vc110")
140 set(QT_DIR ${CMAKE_SOURCE_DIR}/Code/SDKs/Qt/5.6/msvc2012_64)
142 set(MSVC_LIB_PREFIX "")
144 set(Qt5_DIR ${QT_DIR})
147 set(SDK_DIR ${CMAKE_SOURCE_DIR}/Code/SDKs)
148 set(CRY_LIBS_DIR ${CMAKE_SOURCE_DIR}/Code/Libs)
149 set(CRY_EXTENSIONS_DIR ${CMAKE_SOURCE_DIR}/Code/CryExtensions)
150 #set(DXSDK_DIR ${CMAKE_SOURCE_DIR}/Code/SDKs/DXSDK)
151 set(WINSDK_SDK_DIR "${CMAKE_SOURCE_DIR}/Code/SDKs/Microsoft Windows SDK")
152 set(WINSDK_SDK_LIB_DIR "${WINSDK_SDK_DIR}/V8.0/Lib/Win8/um")
153 set(WINSDK_SDK_INCLUDE_DIR "${WINSDK_SDK_DIR}/V8.0/Include/um")
156 set(global_defines "CRYENGINE_DEFINE")
158 if(OPTION_STATIC_LINKING)
159 # Enable static libraries
160 MESSAGE(STATUS "Use Static Linking (.lib)" )
161 set(BUILD_SHARED_LIBS FALSE)
163 # Enable dynamic libraries
164 MESSAGE(STATUS "Use Dynamic Linking (.dll)" )
165 set(BUILD_SHARED_LIBS TRUE)
168 if (OUTPUT_DIRECTORY)
169 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}")
170 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}")
171 set(EXECUTABLE_OUTPUT_PATH "${OUTPUT_DIRECTORY}")
173 # Make sure the output directory exists
174 file(MAKE_DIRECTORY ${OUTPUT_DIRECTORY})
175 endif (OUTPUT_DIRECTORY)
178 if(EXISTS ${CMAKE_SOURCE_DIR}/Tools/CMake/Bootstrap.cmake)
179 include(${CMAKE_SOURCE_DIR}/Tools/CMake/Bootstrap.cmake)
180 if(OPTION_AUTO_BOOTSTRAP)
181 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "bootstrap.dat")
185 include(${CMAKE_SOURCE_DIR}/Tools/CMake/ConfigureChecks.cmake)
186 include(${CMAKE_SOURCE_DIR}/Tools/CMake/CommonMacros.cmake)
188 include_directories( ${SDK_DIR} )
189 include_directories( ${CMAKE_SOURCE_DIR}/Code/CryEngine/CryCommon )
191 set( BOOST_DIR ${SDK_DIR}/boost )
192 include_directories( ${BOOST_DIR} )
195 # Common Libriries linked to all targets
196 set(COMMON_LIBS Ntdll User32 Advapi32 Ntdll Ws2_32)
198 if (EXISTS ${SDK_DIR}/GPA)
199 include_directories( ${SDK_DIR}/GPA/include )
201 link_directories( ${SDK_DIR}/GPA/lib64 )
203 link_directories( ${SDK_DIR}/GPA/lib32 )
205 set(COMMON_LIBS ${COMMON_LIBS} jitprofiling libittnotify)
208 # Common Libriries linked to all targets
212 # Serialization library
213 include_directories( ${CRY_LIBS_DIR}/yasli )
214 include_directories( ${SDK_DIR}/yasli )
217 foreach( current_define ${platform_defines} )
218 add_definitions(-D${current_define})
221 if ((WIN32 OR WIN64) AND OPTION_ENABLE_BROFILER)
222 add_definitions(-DUSE_BROFILER)
223 include_directories( ${SDK_DIR}/Brofiler )
224 link_directories( ${SDK_DIR}/Brofiler )
226 set(COMMON_LIBS ${COMMON_LIBS} ProfilerCore64)
228 set(COMMON_LIBS ${COMMON_LIBS} ProfilerCore32)
232 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
233 if (OPTION_GAME_PROJECT STREQUAL "BenchmarkVR")
234 add_subdirectory(Code/Game_Skyharbor/BenchmarkFramework)
235 add_subdirectory(Code/Game_Skyharbor/GameDll)
236 set_solution_folder("Projects" BenchmarkFramework)
237 set_solution_folder("Projects" CryGameSkyharbor)
241 if (NOT (WIN32 OR WIN64 OR LINUX))
242 # WWise is only supported audio on these platforms
245 if (EXISTS ${SDK_DIR}/Audio/fmod)
246 include(${CMAKE_CURRENT_SOURCE_DIR}/Tools/CMake/modules/fmod.cmake)
247 option(AUDIO_FMOD "FMod sound system support" ON)
249 if (EXISTS ${SDK_DIR}/Audio/portaudio AND EXISTS ${SDK_DIR}/Audio/libsndfile AND (WIN32 OR WIN64))
250 include(${CMAKE_CURRENT_SOURCE_DIR}/Tools/CMake/modules/PortAudio.cmake)
251 option(AUDIO_PORTAUDIO "PortAudio sound system support" ON)
253 option(AUDIO_SDL_MIXER "SDLMixer sound system support" ON)
254 if (EXISTS ${SDK_DIR}/Audio/wwise)
255 option(AUDIO_WWISE "WWise Sound System support" ON)
260 if(NOT (ORBIS OR ANDROID))
261 OPTION(RENDERER_DX11 "Renderer for DirectX 11" ON)
265 if (NOT MSVC_VERSION EQUAL 1900)
266 message(STATUS "MSVC 14.0 is not being used - CryRenderD3D12 cannot be built.")
268 OPTION(RENDERER_DX12 "Renderer for DirectX 12" ON)
273 set(RENDERER_OPENGL ON)
274 elseif (NOT (DURANGO OR ORBIS))
275 OPTION(RENDERER_OPENGL "Renderer for OpenGL" ON)
278 if (EXISTS ${SDK_DIR}/Orbis AND EXISTS ${CMAKE_SOURCE_DIR/}Code/CryEngine/RenderDll/XRenderD3D9/GNM)
281 #option(RENDERER_GNM "GNM renderer" ON)
284 #option(RENDERER_GNM_SHADER_COMPILER "Shader compiler for Orbis" ON)
288 if(ORBIS AND NOT RENDERER_GNM)
289 SET(RENDERER_DX11 ON)
293 include(${CMAKE_CURRENT_SOURCE_DIR}/Tools/CMake/modules/FbxSdk.cmake)
294 include(${CMAKE_CURRENT_SOURCE_DIR}/Tools/CMake/modules/SDL2.cmake)
295 include(${CMAKE_CURRENT_SOURCE_DIR}/Tools/CMake/modules/SDL_mixer.cmake)
296 include(${CMAKE_CURRENT_SOURCE_DIR}/Tools/CMake/modules/Boost.cmake)
297 include(${CMAKE_CURRENT_SOURCE_DIR}/Tools/CMake/modules/ncurses.cmake)
299 if (OPTION_SANDBOX AND WIN64)
300 # Find Qt before including any plugin subdirectories
301 find_package(Qt5 COMPONENTS Core Gui OpenGL Widgets REQUIRED PATHS "${QT_DIR}")
302 set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER "AUTOGEN")
303 set_property(GLOBAL PROPERTY AUTOMOC_TARGETS_FOLDER "AUTOMOC")
308 add_subdirectory(Code/CryEngine/Cry3DEngine)
309 add_subdirectory(Code/CryEngine/CryAction)
310 add_subdirectory(Code/CryEngine/CryAISystem)
311 add_subdirectory(Code/CryEngine/CryAnimation)
312 add_subdirectory(Code/CryEngine/CryDynamicResponseSystem)
313 add_subdirectory(Code/CryEngine/CryEntitySystem)
314 add_subdirectory(Code/CryEngine/CryFont)
315 add_subdirectory(Code/CryEngine/CryInput)
316 add_subdirectory(Code/CryEngine/CryMovie)
317 add_subdirectory(Code/CryEngine/CryNetwork)
318 add_subdirectory(Code/CryEngine/CryPhysics)
319 add_subdirectory(Code/CryEngine/RenderDll/XRenderD3D9)
320 add_subdirectory(Code/CryEngine/CryScriptSystem)
321 add_subdirectory(Code/CryEngine/CryAudioSystem)
322 add_subdirectory(Code/CryEngine/CryAudioSystem/Common)
323 add_subdirectory(Code/CryEngine/CryAudioSystem/implementations/CryAudioImplFmod)
324 add_subdirectory(Code/CryEngine/CryAudioSystem/implementations/CryAudioImplPortAudio)
325 add_subdirectory(Code/CryEngine/CryAudioSystem/implementations/CryAudioImplSDLMixer)
326 add_subdirectory(Code/CryEngine/CryAudioSystem/implementations/CryAudioImplWwise)
327 add_subdirectory(Code/CryEngine/CrySystem)
329 # CryCommon headers only project
330 add_subdirectory(Code/CryEngine/CryCommon)
332 # Shaders custom project
333 add_subdirectory(Engine/Shaders)
336 add_subdirectory(Code/CryEngine/CryLiveCreate)
338 #add_subdirectory(Code/CryExtensions/GameStream)
341 # Mandatory plugin, contains entities required by the engine
342 add_subdirectory(Code/CryPlugins/CryDefaultEntities/Module)
345 add_subdirectory(Code/CryExtensions)
349 add_subdirectory(Code/CryPlugins/CryFramesPerSecond/Module)
352 if (PLUGIN_VR_OCULUS)
353 add_subdirectory(Code/CryPlugins/VR/CryOculusVR/Module)
355 if (PLUGIN_VR_OPENVR)
356 add_subdirectory(Code/CryPlugins/VR/CryOpenVR/Module)
359 add_subdirectory(Code/CryPlugins/VR/CryOSVR/Module)
362 add_custom_target(CE DEPENDS CryPhysics CrySystem CryAction CryRenderD3D11
363 CryFont CryNetwork CryMovie CryInput CryAISystem CryAnimation Cry3DEngine
364 CryScriptSystem CryEntitySystem CryAudioSystem CryAudioImplSDLMixer
365 CryDynamicResponseSystem)
369 add_subdirectories_glob("Code/Game*")
372 add_subdirectory(Code/CryManaged/CryMonoBridge)
373 add_subdirectory(Code/CryManaged/CESharp)
378 add_subdirectory(Code/Launcher/DurangoLauncher)
380 add_subdirectory(Code/Launcher/OrbisLauncher)
382 add_subdirectory(Code/Launcher/AndroidLauncher)
384 add_subdirectory(Code/Launcher/DedicatedLauncher)
385 add_subdirectory(Code/Launcher/WindowsLauncher)
389 add_subdirectory(Code/Libs/freetype)
390 add_subdirectory(Code/Libs/expat)
391 add_subdirectory(Code/Libs/lua)
392 add_subdirectory(Code/Libs/zlib)
393 add_subdirectory(Code/Libs/lz4)
394 add_subdirectory(Code/Libs/md5)
395 add_subdirectory(Code/Libs/tiff)
396 add_subdirectory(Code/Libs/lzma)
397 add_subdirectory(Code/Libs/lzss)
398 add_subdirectory(Code/Libs/bigdigits)
399 add_subdirectory(Code/Libs/strophe)
400 add_subdirectory(Code/Libs/yasli)
401 add_subdirectory(Code/Libs/tomcrypt)
402 add_subdirectory(Code/Libs/prt)
403 add_subdirectory(Code/Libs/python)
404 add_subdirectory(Code/Libs/jsmn)
405 add_subdirectory(Code/Libs/vco)
406 add_subdirectory(Code/Libs/oculus)
409 if (OPTION_SANDBOX AND WIN64)
410 MESSAGE(STATUS "Include Sandbox Editor")
411 set(CMAKE_INCLUDE_CURRENT_DIR ON)
412 set(CMAKE_AUTOMOC_RELAXED_MODE TRUE)
414 set(EDITOR_DIR "${CMAKE_SOURCE_DIR}/Code/Sandbox/EditorQt" )
415 add_subdirectory(Code/Sandbox/EditorQt)
416 add_subdirectory(Code/Sandbox/Plugins/3DConnexionPlugin)
417 add_subdirectory(Code/Sandbox/Plugins/EditorConsole)
418 add_subdirectory(Code/CryExtensions/CryLink/EditorPlugin)
420 add_custom_target(GameAndTools DEPENDS ${GAME_TARGET} Sandbox)
422 add_subdirectory(Code/Sandbox/Plugins/EditorCommon)
423 add_subdirectory(Code/Sandbox/EditorInterface)
425 add_subdirectory(Code/Sandbox/Plugins/CryDesigner)
426 add_subdirectory(Code/Sandbox/Plugins/EditorAudioControlsEditor)
427 add_subdirectory(Code/Sandbox/Plugins/EditorAudioControlsEditor/common)
429 add_subdirectory(Code/Sandbox/Plugins/EditorAudioControlsEditor/EditorFmod)
432 add_subdirectory(Code/Sandbox/Plugins/EditorAudioControlsEditor/EditorSDLMixer)
435 add_subdirectory(Code/Sandbox/Plugins/EditorAudioControlsEditor/EditorWwise)
437 add_subdirectory(Code/Sandbox/Plugins/EditorAnimation)
438 add_subdirectory(Code/Sandbox/Plugins/EditorDynamicResponseSystem)
439 add_subdirectory(Code/Sandbox/Plugins/EditorEnvironment)
440 add_subdirectory(Code/Sandbox/Plugins/EditorParticle)
441 add_subdirectory(Code/Sandbox/Plugins/EditorTrackView)
442 add_subdirectory(Code/Sandbox/Plugins/FbxPlugin)
443 add_subdirectory(Code/Sandbox/Plugins/MeshImporter)
444 add_subdirectory(Code/Sandbox/Plugins/PerforcePlugin)
448 if(WIN64 AND EXISTS "${CMAKE_SOURCE_DIR}/Code/Tools/ShaderCacheGen/ShaderCacheGen")
449 option(OPTION_SHADERCACHEGEN "Build the shader cache generator." OFF)
452 if (OPTION_SHADERCACHEGEN)
453 add_subdirectory(Code/Tools/ShaderCacheGen/ShaderCacheGen)
456 if (OPTION_RC AND EXISTS "${CMAKE_SOURCE_DIR}/Code/Tools/rc")
457 include(ExternalProject)
458 ExternalProject_Add(RC
459 SOURCE_DIR "${CMAKE_SOURCE_DIR}/Code/Tools/rc"
460 INSTALL_COMMAND echo "Skipping install"
464 set(CMAKE_INSTALL_MESSAGE LAZY)
465 install(FILES Tools/CMake/modules/CryCommonConfig.cmake DESTINATION share/cmake)
466 install(FILES Tools/CMake/modules/CryActionConfig.cmake DESTINATION share/cmake)
468 copy_binary_files_to_target()