-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
108 lines (89 loc) · 3.21 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
cmake_minimum_required(VERSION 3.22)
project(
Heart
VERSION 0.1
DESCRIPTION "A 3d game engine"
)
option(HEART_BUILD_DOCS "Build documentation" OFF)
option(HEART_BUILD_EDITOR "Build the editor" OFF)
option(HEART_BUILD_RUNTIME "Build the standalone runtime" OFF)
option(HEART_BUILD_TESTS "Build the tests" OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(HEART_BUILD_DOCS)
find_package(Doxygen)
if(DOXYGEN_FOUND)
add_subdirectory("docs")
endif()
endif()
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
if (${CMAKE_GENERATOR} STREQUAL "Xcode")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE})
else()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE})
set(OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
set(CMAKE_CXX_STANDARD 17)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
message("Detected GNU compiler")
set(CMAKE_CXX_FLAGS "-fpermissive")
elseif(MSVC)
message("Detected MSVC compiler")
add_compile_options(/MP /INCREMENTAL)
# Override to only use level 1. Level 2 causes massive parallel performance issues
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
add_compile_definitions(_ITERATOR_DEBUG_LEVEL=1)
endif()
# https://github.com/actions/runner-images/issues/10004#issuecomment-2156109231
# https://github.com/YehudaKremer/msix/issues/272
add_compile_definitions(_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
message("Building HeartEngine in Debug mode")
add_compile_definitions(HE_DEBUG)
else()
message("Building HeartEngine in Release mode")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Macos intel testing
# if (APPLE)
# set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
# set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15")
# endif()
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0")
# Configure & locate dotnet hostfxr
find_package(Python3 COMPONENTS Interpreter)
if(Python3_FOUND)
execute_process(
COMMAND ${Python3_EXECUTABLE} "scripts/configure-hostfxr.py"
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE DOTNET_CONFIGURE_OUTPUT
)
list(GET DOTNET_CONFIGURE_OUTPUT 0 DOTNET_RUNTIME_DIR)
list(GET DOTNET_CONFIGURE_OUTPUT 1 DOTNET_HOSTFXR_PATH)
list(GET DOTNET_CONFIGURE_OUTPUT 2 DOTNET_RUNTIME_STR)
message("Dotnet runtime dir: ${DOTNET_RUNTIME_DIR}")
message("Dotnet hostfxr path: ${DOTNET_HOSTFXR_PATH}")
message("Dotnet runtime str: ${DOTNET_RUNTIME_STR}")
if (DOTNET_RUNTIME_DIR STREQUAL "")
message(FATAL_ERROR "Dotnet SDK not found ensure it is installed and in PATH")
endif()
else()
message(FATAL_ERROR "Python must be installed to configure Heart")
endif()
if (HEART_BUILD_RUNTIME)
message("Building the runtime")
add_compile_definitions(HE_DIST)
# add_subdirectory("HeartRuntime")
endif()
add_subdirectory("Heart")
add_subdirectory("HeartScripting")
if (HEART_BUILD_EDITOR)
message("Building the editor")
add_subdirectory("HeartEditor")
endif()
if (HEART_BUILD_TESTS)
message("Building the tests")
add_subdirectory("HeartTesting")
endif()