-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
156 lines (131 loc) · 4.38 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
cmake_minimum_required(VERSION 3.18)
project(
iris
VERSION "4.0.1"
DESCRIPTION "Cross-platform game engine"
LANGUAGES C CXX)
include(CMakePackageConfigHelpers)
include(FetchContent)
include(GNUInstallDirs)
include(GenerateExportHeader)
# set options for library
option(IRIS_BUILD_UNIT_TESTS "whether to build unit tests" ON)
set(ASM_OPTIONS "-x assembler-with-cpp")
# if a platform wasn't supplied then default to current platform
if(NOT IRIS_PLATFORM)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_STANDARD 20)
set(IRIS_PLATFORM "MACOS")
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64")
set(IRIS_ARCH "ARM64")
else()
set(IRIS_ARCH "X86_64")
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(IRIS_PLATFORM "WIN32")
set(IRIS_ARCH "X86_64")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(IRIS_PLATFORM "LINUX")
set(IRIS_ARCH "X86_64")
else()
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
endif()
endif()
if(IRIS_PLATFORM MATCHES "MACOS" OR IRIS_PLATFORM MATCHES "IOS")
enable_language(OBJC)
enable_language(OBJCXX)
enable_language(ASM)
endif()
if(IRIS_PLATFORM MATCHES "LINUX")
enable_language(ASM)
endif()
# set options for third party libraries
set(BUILD_UNIT_TESTS OFF CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(BUILD_CPU_DEMOS OFF CACHE BOOL "" FORCE)
set(BUILD_BULLET2_DEMOS OFF CACHE BOOL "" FORCE)
set(BUILD_EXTRAS OFF CACHE BOOL "" FORCE)
set(BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_SAMPLES OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_ZLIB ON CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_FBX_IMPORTER ON CACHE BOOL "" FORCE)
set(ASSIMP_NO_EXPORT ON CACHE BOOL "" FORCE)
set(INJA_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(BUILD_BENCHMARK OFF CACHE BOOL "" FORCE)
set(COVERALLS OFF CACHE BOOL "" FORCE)
# fetch third party libraries
# note that in most cases we manually populate and add, this alloes us to use
# EXCLUDE_FROM_ALL to prevent them from being included in the install step
FetchContent_Declare(
assimp
GIT_REPOSITORY https://github.com/assimp/assimp
GIT_TAG v5.0.1)
FetchContent_GetProperties(assimp)
if(NOT assimp_POPULATED)
FetchContent_Populate(assimp)
add_subdirectory(${assimp_SOURCE_DIR} ${assimp_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
FetchContent_Declare(
bullet
GIT_REPOSITORY https://github.com/bulletphysics/bullet3
GIT_TAG 3.17)
FetchContent_GetProperties(bullet)
if(NOT bullet_POPULATED)
FetchContent_Populate(bullet)
add_subdirectory(${bullet_SOURCE_DIR} ${bullet_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
# stb doesn't have a cmake file, so just make it available
FetchContent_Declare(
stb
GIT_REPOSITORY https://github.com/nothings/stb
GIT_TAG c0c982601f40183e74d84a61237e968dca08380e
CONFIGURE_COMMAND "" BUILD_COMMAND "")
FetchContent_MakeAvailable(stb)
FetchContent_Declare(
lua
GIT_REPOSITORY https://github.com/lua/lua.git
GIT_TAG v5.4.3
CONFIGURE_COMMAND "" BUILD_COMMAND "")
FetchContent_MakeAvailable(lua)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.11.0)
FetchContent_GetProperties(googletest)
if(NOT googletest_POPULATED)
FetchContent_Populate(googletest)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
FetchContent_Declare(
inja
GIT_REPOSITORY https://github.com/pantor/inja
GIT_TAG v3.3.0)
FetchContent_GetProperties(inja)
if(NOT inja_POPULATED)
FetchContent_Populate(inja)
add_subdirectory(${inja_SOURCE_DIR} ${inja_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
if(IRIS_PLATFORM MATCHES "WIN32")
FetchContent_Declare(
directx-headers
GIT_REPOSITORY https://github.com/microsoft/DirectX-Headers.git
GIT_TAG v1.4.9)
FetchContent_GetProperties(directx-headers)
if(NOT directx-headers_POPULATED)
FetchContent_Populate(directx-headers)
add_subdirectory(${directx-headers_SOURCE_DIR} ${directx-headers_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
endif()
add_subdirectory("shaders")
add_subdirectory("src")
add_subdirectory("samples")
if(IRIS_BUILD_UNIT_TESTS)
enable_testing()
include(CTest)
add_subdirectory("tests")
endif()
include(cmake/cpack.cmake)