2 # Header guard to avoid duplicate execution when configuring (template) projects with OPTION_ENGINE
3 # Templates include Configure.cmake and add_subdirectory(${CRYENGINE_DIR}) which also includes Configure.cmake
4 # Templates do need Configure.cmake to set up some defines.
5 # In order to not have duplicate add_subdirectory calls (which causes errors), we need an include guard here.
7 if(OPTION_ENGINE OR OPTION_SHADERCACHEGEN OR OPTION_SCALEFORMHELPER OR OPTION_SANDBOX OR OPTION_PAKTOOLS OR OPTION_DOXYGEN_EXAMPLES)
8 # Add custom project with just listing of cmake files
9 add_subdirectory("${TOOLS_CMAKE_DIR}")
11 # Order currently matters for Engine, Games and Launchers
13 include ("${TOOLS_CMAKE_DIR}/BuildEngine.cmake")
17 if (OPTION_SANDBOX AND OPTION_STATIC_LINKING)
18 message(STATUS "Disabling Sandbox - requires dynamic linking")
19 set(OPTION_SANDBOX OFF)
22 if (OPTION_SANDBOX AND WINDOWS)
23 set(QT_DEPLOY_ROOT "${SDK_DIR}/Qt/5.12.3_python_37/msvc2017_64")
24 set(QT_DIR "${QT_DEPLOY_ROOT}/Qt")
25 set(Qt5_DIR "${QT_DIR}")
27 find_package(Qt5 COMPONENTS Core Gui OpenGL Widgets REQUIRED PATHS "${QT_DIR}" NO_DEFAULT_PATH)
29 set(QT_DIR "${QT_DIR}" CACHE INTERNAL "QT directory" FORCE)
30 set(Qt5_DIR "${Qt5_DIR}" CACHE INTERNAL "QT directory" FORCE)
32 set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER "${VS_FOLDER_PREFIX}/Sandbox/AUTOGEN")
34 message(STATUS "Include Sandbox Editor")
35 include ("${TOOLS_CMAKE_DIR}/BuildSandbox.cmake")
38 # Only allow building legacy GameDLL's with the engine, assuming that we're not using the project system
39 if(OPTION_ENGINE AND NOT PROJECT_BUILD)
41 add_subdirectories_glob("Code/Game*")
44 # 3. Extensions (deprecated / legacy)
45 if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Code/CryExtensions")
46 add_subdirectory(Code/CryExtensions)
51 add_subdirectory(Code/CryPlugins)
55 include ("${TOOLS_CMAKE_DIR}/BuildLaunchers.cmake")
58 add_subdirectory(Code/CryManaged)
61 macro(generate_crytest_targets target_name using_runner_target_name)
62 add_custom_target(${target_name})
63 set_target_properties(${target_name} PROPERTIES EXCLUDE_FROM_ALL TRUE)
64 set_target_properties(${target_name} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE)
65 set_property(TARGET ${target_name} PROPERTY FOLDER "_TEST_")
66 get_property(runner TARGET ${using_runner_target_name} PROPERTY OUTPUT_NAME )
68 set(runner ${using_runner_target_name})
70 #message("WindowsLauncherExe = ${WindowsLauncherExe}")
71 file( WRITE "${CMAKE_CURRENT_BINARY_DIR}/${target_name}.vcxproj.user"
72 "<?xml version=\"1.0\" encoding=\"utf-8\"?>
73 <Project ToolsVersion=\"14.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">
74 <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">
75 <LocalDebuggerCommand>${OUTPUT_DIRECTORY}/${runner}.exe</LocalDebuggerCommand>
76 <LocalDebuggerWorkingDirectory>${OUTPUT_DIRECTORY}</LocalDebuggerWorkingDirectory>
77 <LocalDebuggerCommandArguments>-run_crytest -crytest_open_report</LocalDebuggerCommandArguments>
78 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
80 <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Profile|x64'\">
81 <LocalDebuggerCommand>${OUTPUT_DIRECTORY}/${runner}.exe</LocalDebuggerCommand>
82 <LocalDebuggerWorkingDirectory>${OUTPUT_DIRECTORY}</LocalDebuggerWorkingDirectory>
83 <LocalDebuggerCommandArguments>-run_crytest -crytest_open_report</LocalDebuggerCommandArguments>
84 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
86 <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">
87 <LocalDebuggerCommand>${OUTPUT_DIRECTORY}/${runner}.exe</LocalDebuggerCommand>
88 <LocalDebuggerWorkingDirectory>${OUTPUT_DIRECTORY}</LocalDebuggerWorkingDirectory>
89 <LocalDebuggerCommandArguments>-run_crytest -crytest_open_report</LocalDebuggerCommandArguments>
90 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
97 if (OPTION_ENGINE AND WINDOWS)
98 generate_crytest_targets(run_crytest WindowsLauncher)
101 if (OPTION_SANDBOX AND WINDOWS)
102 generate_crytest_targets(run_crytest_sandbox Sandbox)
105 if(WINDOWS AND EXISTS "${CRYENGINE_DIR}/Code/Tools/ShaderCacheGen/ShaderCacheGen")
106 option(OPTION_SHADERCACHEGEN "Build the shader cache generator." OFF)
109 if (OPTION_SHADERCACHEGEN)
110 add_subdirectory(Code/Tools/ShaderCacheGen/ShaderCacheGen)
113 if (OPTION_PAKTOOLS AND EXISTS "${CRYENGINE_DIR}/Code/Tools/PakEncrypt")
114 add_subdirectory(Code/Tools/PakEncrypt)
117 if (OPTION_RC AND EXISTS "${CRYENGINE_DIR}/Code/Tools/RC")
118 include(ExternalProject)
119 ExternalProject_Add(RC
120 CMAKE_ARGS "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" "-DCMAKE_BUILD_TYPE=$<$<CONFIG:Profile>:Release>$<$<NOT:$<CONFIG:Profile>>:$<CONFIG>>"
121 SOURCE_DIR "${CRYENGINE_DIR}/Code/Tools/RC"
122 BUILD_COMMAND "${CMAKE_COMMAND}" --build "." --config $<$<CONFIG:Profile>:Release>$<$<NOT:$<CONFIG:Profile>>:$<CONFIG>>
123 INSTALL_COMMAND echo "Skipping install"
128 add_subdirectory(Code/Tools/PhysDebugger)
132 set(CMAKE_INSTALL_MESSAGE LAZY)
133 install(FILES "${TOOLS_CMAKE_DIR}/modules/CryCommonConfig.cmake" DESTINATION share/cmake)
134 install(FILES "${TOOLS_CMAKE_DIR}/modules/CryActionConfig.cmake" DESTINATION share/cmake)
136 copy_binary_files_to_target()