Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
cmake_minimum_required(VERSION 3.28)
project(AdvancedCMakeTitanEngineExample LANGUAGES C CXX)

# Extract engine assets/libraries from provided zip archives if needed
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(UnpackEngine)
unpack_engine_files()

# Global compiler settings
if(MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "" FORCE)
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The project now builds two executables: a **client** sample and a **server** tha

## Preparing the engine files

The large engine assets and libraries are stored in the repository as zip archives. Extract them **in place** before configuring the build:
The large engine assets and libraries are stored in the repository as zip archives. If the extracted files are missing, CMake will unpack them automatically during configuration:

```
assets/Engine.zip -> assets/Engine.pak
Expand All @@ -15,6 +15,9 @@ third_party/EE/EngineDebug64DX11.zip -> third_party/EE/EngineDebug64DX11.lib
third_party/EE/EngineDebug64DX11_pdb.zip-> third_party/EE/EngineDebug64DX11.pdb (optional debug symbols)
```

The configure step automatically unpacks these archives when the extracted
files are missing, so you normally don't need to run any manual commands.

## Building

CMake presets are provided for both platforms. **The Linux presets use Clang,**
Expand Down
37 changes: 37 additions & 0 deletions cmake/UnpackEngine.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function(unpack_engine_files)
set(base "${PROJECT_SOURCE_DIR}")
set(assets_dir "${base}/assets")
set(ee_dir "${base}/third_party/EE")

# Engine.pak
set(asset_zip "${assets_dir}/Engine.zip")
set(asset_file "${assets_dir}/Engine.pak")
if(NOT EXISTS "${asset_file}" AND EXISTS "${asset_zip}")
message(STATUS "Extracting ${asset_zip}")
file(ARCHIVE_EXTRACT INPUT "${asset_zip}" DESTINATION "${assets_dir}")
endif()

set(archives
Engine.zip
Engine64DX11.zip
EngineDebug64DX11.zip
EngineDebug64DX11_pdb.zip)
set(outputs
Engine.a
Engine64DX11.lib
EngineDebug64DX11.lib
EngineDebug64DX11.pdb)

list(LENGTH archives count)
math(EXPR last_index "${count}-1")
foreach(i RANGE 0 ${last_index})
list(GET archives ${i} archive)
list(GET outputs ${i} out_file)
set(zip_path "${ee_dir}/${archive}")
set(out_path "${ee_dir}/${out_file}")
if(NOT EXISTS "${out_path}" AND EXISTS "${zip_path}")
message(STATUS "Extracting ${archive}")
file(ARCHIVE_EXTRACT INPUT "${zip_path}" DESTINATION "${ee_dir}")
endif()
endforeach()
endfunction()