-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
68 lines (56 loc) · 1.82 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
cmake_minimum_required(VERSION 3.11) # FetchContent is available in 3.11+
project(main)
# Set directories
set(PROJECT_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
set(RELEASE_ROOT_DIR "${PROJECT_ROOT}/release")
if ("${PLATFORM}" STREQUAL "Web")
set(RELEASE_ROOT_DIR "${PROJECT_ROOT}/release-web")
elseif(WIN32)
set(RELEASE_ROOT_DIR "${PROJECT_ROOT}/release-windows")
endif()
# Generate compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Option to build examples
option(BUILD_EXAMPLE "Build examples" ON)
# Option to build utils
option(BUILD_UTILS "Build utils" ON)
message("BUILD_EXAMPLES " ${BUILD_EXAMPLES})
message("BUILD_UTILS " ${BUILD_UTILS})
include_directories(${CMAKE_SOURCE_DIR}/include)
# build engine
add_subdirectory(src)
# example projects
if(BUILD_EXAMPLE)
if ("${PLATFORM}" STREQUAL "Web")
add_subdirectory(examples/holojam)
else()
add_subdirectory(examples/test-game)
add_subdirectory(examples/holojam)
endif()
endif()
# utils
if(BUILD_UTILS)
if ("${PLATFORM}" STREQUAL "Web")
else()
add_subdirectory(utils)
endif()
endif()
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_compile_definitions(engine PRIVATE $<$<CONFIG:Debug>:ENGINE_DEBUG>)
endif()
# add engine headers to global include
target_include_directories(engine INTERFACE ${CMAKE_SOURCE_DIR}/src/engine)
if ("${PLATFORM}" STREQUAL "Web")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --cflags
OUTPUT_VARIABLE EM_CFLAGS
COMMAND_ERROR_IS_FATAL ANY
)
string(STRIP "${EM_CFLAGS}" EM_CFLAGS)
find_package(Python3 REQUIRED)
message("Python: ${Python3_EXECUTABLE}")
set(ENV{EXTRA_FLAGS} "${EM_CFLAGS}")
execute_process(
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/fix_compile_commands.py
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()