!XF (CMake) Remove references to specific game and extension sub-projects from the...
[CRYENGINE.git] / CMakeLists.txt
bloba587d2b843f79627563296d4aaaf6d85586912c2
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.
8 enable_language(C)
9 enable_language(CXX)
10 # Force C++11 support requirement
11 set (CMAKE_CXX_STANDARD 11)
13 if (DURANGO OR ORBIS OR ANDROID)
14         unset(WIN32)
15         unset(WIN64)
16 endif ()
18 if (WIN32)  # Either Win32 or Win64
19         set(WINDOWS TRUE)
20         include(Tools/CMake/toolchain/windows/WindowsPC-MSVC.cmake)
21 endif(WIN32)
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}")
28         endif()
29 endif()
31 include(${CMAKE_SOURCE_DIR}/Tools/CMake/CopyFilesToBin.cmake)
33 #set(ANDROID TRUE)
35 if(ANDROID)
36         unset(WIN32)
37         unset(WIN64)
38 endif(ANDROID)
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
48         unset(WIN32)
49         unset(WIN64)
50 endif ()
52 set(game_folder CACHE INTERNAL "Game folder used for resource files on Windows" FORCE)
54 if(WIN32)
55         if (NOT METADATA_COMPANY)
56                 set(METADATA_COMPANY "Crytek GmbH")
57         endif()
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}")
63         endif()
64         set(METADATA_COPYRIGHT ${METADATA_COPYRIGHT} CACHE STRING "Copyright string for executable metadata")   
65         
66         if (NOT VERSION)
67                 set(VERSION "1.0.0.0")
68         endif()
69         set(METADATA_VERSION ${VERSION} CACHE STRING "Version number for executable metadata" FORCE)
70         string(REPLACE . , METADATA_VERSION_COMMA ${METADATA_VERSION})
71 endif()
73 if(LINUX32 OR LINUX64)
74         set(LINUX TRUE)
75 endif()
77 # Define Options
78 option(OPTION_PROFILE "Enable Profiling" ON)
79 option(OPTION_UNITY_BUILD "Enable Unity Build" ON)
80 if(WIN32 OR WIN64)
81         option(OPTION_ENABLE_BROFILER "Enable Brofiler profiler support" ON)
82 endif()
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)
88         endif()
89         if(OPTION_SANDBOX)
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)
92         endif()
93 endif()
95 option(OPTION_RC "Include RC in the build" OFF)
96 option(OPTION_PCH "Enable Precompiled Headers" OFF)
98 #Plugins
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)
104 if(WIN32 OR WIN64)
105         option(OPTION_CRYMONO "C# support" OFF)
106 endif()
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}")
116 if (OPTION_PROFILE)
117         set_property( DIRECTORY PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Release>:_PROFILE> )
118 else()
119         set_property( DIRECTORY PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Release>:_RELEASE> )
120 endif()
122 if(OPTION_UNITY_BUILD)
123         message(STATUS "UNITY BUILD Enabled")
124 endif()
126 if(ORBIS OR ANDROID)
127         set(OPTION_STATIC_LINKING TRUE)
128 else()
129         option(OPTION_STATIC_LINKING "Link all CryEngine modules as static libs to single exe" OFF)
130 endif()
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)
141 else()
142         set(MSVC_LIB_PREFIX "")
143 endif()
144 set(Qt5_DIR ${QT_DIR})
146 # SDK Directory
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")
155 # custom defines
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)
162 else()
163         # Enable dynamic libraries
164         MESSAGE(STATUS "Use Dynamic Linking (.dll)" )
165         set(BUILD_SHARED_LIBS TRUE)
166 endif()
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)
177 # Bootstrap support
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")
182         endif()
183 endif()
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} )
194 if(WIN32)
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 )
200                 if (WIN64)
201                         link_directories( ${SDK_DIR}/GPA/lib64 )
202                 else()
203                         link_directories( ${SDK_DIR}/GPA/lib32 )
204                 endif()
205                 set(COMMON_LIBS ${COMMON_LIBS} jitprofiling libittnotify)
206         endif()
207 else()
208         # Common Libriries linked to all targets
209         set(COMMON_LIBS )
210 endif()
212 # Serialization library
213 include_directories( ${CRY_LIBS_DIR}/yasli )
214 include_directories( ${SDK_DIR}/yasli )
216 # add global defines
217 foreach( current_define ${platform_defines} )
218         add_definitions(-D${current_define})
219 endforeach()
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 )
225         if (WIN64)
226                 set(COMMON_LIBS ${COMMON_LIBS} ProfilerCore64)
227         elseif(WIN32)
228                 set(COMMON_LIBS ${COMMON_LIBS} ProfilerCore32)
229         endif()
230 endif()
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)
238 endif()
240 #Audio modules
241 if (NOT (WIN32 OR WIN64 OR LINUX))
242         # WWise is only supported audio on these platforms
243         set(AUDIO_WWISE ON)
244 else()
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)
248         endif()
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)
252         endif()
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)
256         endif()
257 endif()
259 #Renderer modules
260 if(NOT (ORBIS OR ANDROID))
261         OPTION(RENDERER_DX11 "Renderer for DirectX 11" ON)
262 endif()
264 if (WIN32 OR WIN64)
265         if (NOT MSVC_VERSION EQUAL 1900)
266                 message(STATUS "MSVC 14.0 is not being used - CryRenderD3D12 cannot be built.")
267         else()
268                 OPTION(RENDERER_DX12 "Renderer for DirectX 12" ON)
269         endif()
270 endif()
272 if(LINUX OR ANDROID)
273         set(RENDERER_OPENGL ON)
274 elseif (NOT (DURANGO OR ORBIS))
275         OPTION(RENDERER_OPENGL "Renderer for OpenGL" ON)
276 endif()
278 if (EXISTS ${SDK_DIR}/Orbis AND EXISTS ${CMAKE_SOURCE_DIR/}Code/CryEngine/RenderDll/XRenderD3D9/GNM)
279         if(ORBIS)
280                 #Force DX11 renderer
281                 #option(RENDERER_GNM "GNM renderer" ON)
282         endif()
283         if(WIN64)
284                 #option(RENDERER_GNM_SHADER_COMPILER "Shader compiler for Orbis" ON)
285         endif()
286 endif()
288 if(ORBIS AND NOT RENDERER_GNM)
289         SET(RENDERER_DX11 ON)
290 endif()
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")
304 endif()
307 # CryEngine
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)
335 if (WIN32)
336         add_subdirectory(Code/CryEngine/CryLiveCreate)
337         # CryExtensions
338         #add_subdirectory(Code/CryExtensions/GameStream)
339 endif (WIN32)
341 # Mandatory plugin, contains entities required by the engine
342 add_subdirectory(Code/CryPlugins/CryDefaultEntities/Module)
344 # CryExtensions
345 add_subdirectory(Code/CryExtensions)
347 # Example plugin
348 if (PLUGIN_FPS)
349         add_subdirectory(Code/CryPlugins/CryFramesPerSecond/Module)
350 endif()
351 # VR plugins
352 if (PLUGIN_VR_OCULUS)
353         add_subdirectory(Code/CryPlugins/VR/CryOculusVR/Module)
354 endif()
355 if (PLUGIN_VR_OPENVR)   
356         add_subdirectory(Code/CryPlugins/VR/CryOpenVR/Module)
357 endif() 
358 if (PLUGIN_VR_OSVR)     
359         add_subdirectory(Code/CryPlugins/VR/CryOSVR/Module)
360 endif()
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)
368 # Game
369 add_subdirectories_glob("Code/Game*")
371 if (OPTION_CRYMONO)
372         add_subdirectory(Code/CryManaged/CryMonoBridge)
373         add_subdirectory(Code/CryManaged/CESharp)
374 endif()
376 # Launchers
377 if (DURANGO)
378         add_subdirectory(Code/Launcher/DurangoLauncher)
379 elseif (ORBIS)
380         add_subdirectory(Code/Launcher/OrbisLauncher)
381 elseif (ANDROID)
382         add_subdirectory(Code/Launcher/AndroidLauncher)
383 elseif (WIN32)
384         add_subdirectory(Code/Launcher/DedicatedLauncher)
385         add_subdirectory(Code/Launcher/WindowsLauncher)
386 endif ()
388 #Libs
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)
408 # Sandbox Editor
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)
419                 
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)
428         if(AUDIO_FMOD)
429                 add_subdirectory(Code/Sandbox/Plugins/EditorAudioControlsEditor/EditorFmod)
430         endif()
431         if(AUDIO_SDL_MIXER)
432                 add_subdirectory(Code/Sandbox/Plugins/EditorAudioControlsEditor/EditorSDLMixer)
433         endif()
434         if (AUDIO_WWISE)
435                 add_subdirectory(Code/Sandbox/Plugins/EditorAudioControlsEditor/EditorWwise)
436         endif()
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)
445 endif()
448 if(WIN64 AND EXISTS "${CMAKE_SOURCE_DIR}/Code/Tools/ShaderCacheGen/ShaderCacheGen")
449         option(OPTION_SHADERCACHEGEN "Build the shader cache generator." OFF)
450 endif()
452 if (OPTION_SHADERCACHEGEN)
453         add_subdirectory(Code/Tools/ShaderCacheGen/ShaderCacheGen)
454 endif()
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"
461         )
462 endif()
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()