-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
35 lines (28 loc) · 1.11 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
cmake_minimum_required(VERSION 3.19.1)
project(unity-examples)
set(UNITY_PATH "/Applications/Unity/Unity.app/Contents/MacOS")
set(PROJECT_PATH "${CMAKE_BINARY_DIR}")
file(GLOB_RECURSE ASSET_FILES "${CMAKE_SOURCE_DIR}/Assets/*")
# Add a custom target to trigger copying of files
add_custom_target(copy_assets ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Assets ${CMAKE_BINARY_DIR}/Assets
DEPENDS ${ASSET_FILES}
)
# Set the output directory for copied assets
set_property(TARGET copy_assets PROPERTY FOLDER "CMakePredefinedTargets")
set_target_properties(copy_assets PROPERTIES
OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Assets"
)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Builds/WebGL)
add_custom_target(webgl
COMMAND ${UNITY_PATH}/Unity
-quit
-batchmode
-nographics
-projectPath ${PROJECT_PATH}
-executeMethod WebGLBuilder.BuildWebGL
-buildTarget WebGL
-outputPath "${CMAKE_BINARY_DIR}/Builds/WebGL"
DEPENDS copy_assets
)
set_property(DIRECTORY ${CMAKE_BINARY_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})