1 if(DURANGO OR ORBIS OR ANDROID OR LINUX)
4 elseif(WIN32) # Either Win32 or Win64
5 include("${CMAKE_CURRENT_LIST_DIR}/toolchain/windows/WindowsPC-MSVC.cmake")
8 # C/C++ languages required.
12 if(NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio")
13 set(valid_configs Debug Profile Release)
14 list(FIND valid_configs "${CMAKE_BUILD_TYPE}" config_index)
15 if(${config_index} EQUAL -1)
16 message(SEND_ERROR "Build type \"${CMAKE_BUILD_TYPE}\" is not supported, set CMAKE_BUILD_TYPE to one of ${valid_configs}")
20 # Correct output directory slashes, has to be done after toolchain includes
22 string(REPLACE "\\" "/" OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}")
24 # Note that PROJECT_DIR can be different depending on whether we're building the engine or a standalone game / plugin project
25 set(OUTPUT_DIRECTORY "${PROJECT_DIR}/bin")
28 if(OUTPUT_DIRECTORY_NAME)
29 set(OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}/${OUTPUT_DIRECTORY_NAME}")
30 set(OUTPUT_DIRECTORY_NAME "")
33 set(BASE_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}")
34 set(BASE_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}")
35 set(BASE_OUTPUT_DIRECTORY_PROFILE "${OUTPUT_DIRECTORY}")
36 set(BASE_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}_release")
38 set(OUTPUT_DIRECTORY_SUFFIX "" CACHE STRING "Optional suffix for the binary output directory")
39 if(OUTPUT_DIRECTORY_SUFFIX)
40 set(OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}_${OUTPUT_DIRECTORY_SUFFIX}")
43 set(METADATA_PROJECT_NAME "CryEngine" CACHE STRING "Name of the solution project")
44 project("${METADATA_PROJECT_NAME}_CMake_${BUILD_PLATFORM}" CXX C)
46 # Prefix all Visual Studio solution folder names with this string
47 set( VS_FOLDER_PREFIX "CRYENGINE/" )
49 set(MODULES CACHE INTERNAL "List of engine modules being built" FORCE)
50 set(GAME_MODULES CACHE INTERNAL "List of game modules being built" FORCE)
52 if (DURANGO OR ORBIS OR ANDROID OR LINUX)
53 # WIN32 Should be unset again after project( line to work correctly
58 set(game_folder CACHE INTERNAL "Game folder used for resource files on Windows" FORCE)
61 get_property(global_defines DIRECTORY "${CRYENGINE_DIR}" PROPERTY COMPILE_DEFINITIONS)
62 get_property(global_includes DIRECTORY "${CRYENGINE_DIR}" PROPERTY INCLUDE_DIRECTORIES)
63 get_property(global_links DIRECTORY "${CRYENGINE_DIR}" PROPERTY LINK_DIRECTORIES)
66 set_property( DIRECTORY PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Release>:_PROFILE> )
68 set_property( DIRECTORY PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Release>:_RELEASE> )
71 if(OPTION_UNITY_BUILD)
72 message(STATUS "UNITY BUILD Enabled")
76 if (LINUX AND LINUX_BOOTSTRAP_FOLDER)
77 set(SDK_DIR "${LINUX_BOOTSTRAP_FOLDER}")
79 set(SDK_DIR "${CRYENGINE_DIR}/Code/SDKs")
82 set(CRY_LIBS_DIR "${CRYENGINE_DIR}/Code/Libs")
83 set(CRY_EXTENSIONS_DIR "${CRYENGINE_DIR}/Code/CryExtensions")
85 set(WINSDK_SDK_DIR "${SDK_DIR}/Microsoft Windows SDK")
86 set(WINSDK_SDK_LIB_DIR "${WINSDK_SDK_DIR}/V8.0/Lib/Win8/um")
87 set(WINSDK_SDK_INCLUDE_DIR "${WINSDK_SDK_DIR}/V8.0/Include/um")
89 if (NOT EXISTS "${CMAKE_BINARY_DIR}/ProjectCVarOverrides.h")
90 file(WRITE "${CMAKE_BINARY_DIR}/ProjectCVarOverrides.h" "")
92 list(APPEND global_defines "CRY_CVAR_OVERRIDE_FILE=\"${CMAKE_BINARY_DIR}/ProjectCVarOverrides.h\"")
94 if (NOT EXISTS "${CMAKE_BINARY_DIR}/ProjectCVarWhitelist.h")
95 file(WRITE "${CMAKE_BINARY_DIR}/ProjectCVarWhitelist.h" "")
97 list(APPEND global_defines "CRY_CVAR_WHITELIST_FILE=\"${CMAKE_BINARY_DIR}/ProjectCVarWhitelist.h\"")
99 if (NOT EXISTS "${CMAKE_BINARY_DIR}/ProjectEngineDefineOverrides.h")
100 file(WRITE "${CMAKE_BINARY_DIR}/ProjectEngineDefineOverrides.h" "")
102 list(APPEND global_defines "CRY_ENGINE_DEFINE_OVERRIDE_FILE=\"${CMAKE_BINARY_DIR}/ProjectEngineDefineOverrides.h\"")
104 if (OPTION_RUNTIME_CVAR_OVERRIDES)
105 list(APPEND global_defines "USE_RUNTIME_CVAR_OVERRIDES")
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}")
115 MESSAGE(STATUS "MSVC = ${MSVC}")
116 MESSAGE(STATUS "CRYENGINE_DIR = ${CRYENGINE_DIR}")
117 MESSAGE(STATUS "SDK_DIR = ${SDK_DIR}")
120 list(APPEND global_defines "CRYENGINE_DEFINE")
122 include("${TOOLS_CMAKE_DIR}/CommonOptions.cmake")
124 # Must be included after SDK_DIR definition
125 include("${TOOLS_CMAKE_DIR}/CopyFilesToBin.cmake")
127 if(MSVC_VERSION AND NOT OPTION_PGO STREQUAL "Off")
129 MESSAGE(STATUS "Cannot support Recode with PGO enabled - disabling Recode support")
130 set(OPTION_RECODE OFF CACHE BOOL "Enable support for Recode" FORCE)
133 MESSAGE(STATUS "OPTION_LTCG is required for PGO - enabling LTCG")
134 set(OPTION_LTCG ON CACHE BOOL "Enable link-time code generation/optimization" FORCE)
139 if (OPTION_STATIC_LINKING_WITH_GAME_AS_DLL)
140 MESSAGE(STATUS "Enabling OPTION_STATIC_LINKING because OPTION_STATIC_LINKING_WITH_GAME_AS_DLL was set")
141 set(OPTION_STATIC_LINKING ON CACHE BOOL "Enabling OPTION_STATIC_LINKING because OPTION_STATIC_LINKING_WITH_GAME_AS_DLL was set" FORCE)
144 if(OPTION_STATIC_LINKING)
145 # Enable static libraries
146 MESSAGE(STATUS "Use Static Linking (.lib/.a)" )
147 set(BUILD_SHARED_LIBS FALSE)
149 # Enable dynamic librariesboost
150 MESSAGE(STATUS "Use Dynamic Linking (.dll/.so)" )
151 set(BUILD_SHARED_LIBS TRUE)
154 if (OUTPUT_DIRECTORY)
155 if(OPTION_DEDICATED_SERVER)
156 set(OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}_dedicated")
159 message(STATUS "OUTPUT_DIRECTORY=${OUTPUT_DIRECTORY}")
160 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}")
161 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}")
162 set(EXECUTABLE_OUTPUT_PATH "${OUTPUT_DIRECTORY}")
164 # Make sure the output directory exists
165 file(MAKE_DIRECTORY "${OUTPUT_DIRECTORY}")
166 endif (OUTPUT_DIRECTORY)
168 include("${TOOLS_CMAKE_DIR}/ConfigureChecks.cmake")
169 include("${TOOLS_CMAKE_DIR}/CommonMacros.cmake")
170 include("${TOOLS_CMAKE_DIR}/Recode.cmake")
173 # Common Libriries linked to all targets
174 set(COMMON_LIBS Ntdll User32 Advapi32 Ntdll Ws2_32)
176 if (EXISTS "${SDK_DIR}/GPA" AND OPTION_ENGINE)
177 list(APPEND global_includes "${SDK_DIR}/GPA/include" )
178 list(APPEND global_links "${SDK_DIR}/GPA/lib64" )
179 set(COMMON_LIBS ${COMMON_LIBS} jitprofiling libittnotify)
182 # Common Libriries linked to all targets
187 foreach( current_define ${platform_defines} )
188 list(APPEND global_defines "${current_define}")
191 if (OPTION_RELEASE_PROFILING)
192 list(APPEND global_defines "$<$<CONFIG:Release>:PERFORMANCE_BUILD>")
194 if (OPTION_RELEASE_LOGGING)
195 list(APPEND global_defines "$<$<CONFIG:Release>:RELEASE_LOGGING>")
201 include("${TOOLS_CMAKE_DIR}/modules/SDL2.cmake")
203 if(NOT TARGET ncursesw)
204 include("${TOOLS_CMAKE_DIR}/modules/ncurses.cmake")
207 option(OPTION_GEOM_CACHES "Enable Geom Cache" ON)
209 if(OPTION_GEOM_CACHES)
210 list(APPEND global_defines USE_GEOM_CACHES=1)
213 option(OPTION_FPE "Enable floating point exceptions" OFF)
216 list(APPEND global_defines USE_FPE=1)
219 include("${TOOLS_CMAKE_DIR}/modules/Boost.cmake")
221 # Apply global defines
222 set_property(DIRECTORY "${CRYENGINE_DIR}" PROPERTY COMPILE_DEFINITIONS ${global_defines})
223 set_property(DIRECTORY "${CRYENGINE_DIR}" PROPERTY INCLUDE_DIRECTORIES ${global_includes})
224 set_property(DIRECTORY "${CRYENGINE_DIR}" PROPERTY LINK_DIRECTORIES ${global_links})
225 # Used by game project when they share the solution with the engine.
226 set_property(DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY COMPILE_DEFINITIONS ${global_defines})
227 set_property(DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY INCLUDE_DIRECTORIES ${global_includes})
228 set_property(DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY LINK_DIRECTORIES ${global_links})
230 if (MSVC_VERSION GREATER 1900) # Visual Studio > 2015
231 set(MSVC_LIB_PREFIX vc140)
232 elseif (MSVC_VERSION EQUAL 1900) # Visual Studio 2015
233 set(MSVC_LIB_PREFIX vc140)
234 elseif (MSVC_VERSION EQUAL 1800) # Visual Studio 2013
235 set(MSVC_LIB_PREFIX vc120)
236 elseif (MSVC_VERSION EQUAL 1700) # Visual Studio 2012
237 set(MSVC_LIB_PREFIX "vc110")
239 set(MSVC_LIB_PREFIX "")
244 if (METADATA_VERSION)
245 set(VERSION ${METADATA_VERSION})
247 set(VERSION "1.0.0.0")
250 set(METADATA_VERSION ${VERSION} CACHE STRING "Version number for executable metadata" FORCE)
253 if (NOT METADATA_COMPANY)
254 set(METADATA_COMPANY "Crytek GmbH")
256 set(METADATA_COMPANY "${METADATA_COMPANY}" CACHE STRING "Company name for executable metadata")
258 if (NOT METADATA_COPYRIGHT)
259 string(TIMESTAMP year "%Y")
260 set(METADATA_COPYRIGHT "(C) ${year} ${METADATA_COMPANY}")
262 set(METADATA_COPYRIGHT "${METADATA_COPYRIGHT}" CACHE STRING "Copyright string for executable metadata")
264 string(REPLACE . , METADATA_VERSION_COMMA ${METADATA_VERSION})
265 set(METADATA_VERSION_COMMA ${METADATA_VERSION_COMMA} CACHE INTERNAL "" FORCE)
268 include("${TOOLS_CMAKE_DIR}/Build.cmake")