-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
160 lines (125 loc) · 4.83 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
157
158
159
160
cmake_minimum_required(VERSION 3.10)
project(Playground VERSION 1.0)
set(CMAKE_CXX_STANDARD 11)
set(tmp_dir ${CMAKE_CURRENT_BINARY_DIR}/obj)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${tmp_dir})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${tmp_dir})
set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src)
set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_LIST_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME})
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME})
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/CMakeModules)
set(SOURCES
${PROJECT_SOURCE_DIR}/FileUtils.h
${PROJECT_SOURCE_DIR}/FileUtils.cpp
${PROJECT_SOURCE_DIR}/gl.cpp
${PROJECT_SOURCE_DIR}/gl.h
${PROJECT_SOURCE_DIR}/Math.h
${PROJECT_SOURCE_DIR}/IndexBuffer.h
${PROJECT_SOURCE_DIR}/IndexBuffer.cpp
${PROJECT_SOURCE_DIR}/Shader.h
${PROJECT_SOURCE_DIR}/Shader.cpp
${PROJECT_SOURCE_DIR}/Texture.h
${PROJECT_SOURCE_DIR}/Texture.cpp
${PROJECT_SOURCE_DIR}/VertexBufferLayout.h
${PROJECT_SOURCE_DIR}/VertexArray.h
${PROJECT_SOURCE_DIR}/VertexArray.cpp
${PROJECT_SOURCE_DIR}/VertexBuffer.h
${PROJECT_SOURCE_DIR}/VertexBuffer.cpp
${PROJECT_SOURCE_DIR}/Renderer.h
${PROJECT_SOURCE_DIR}/Renderer.cpp
${PROJECT_SOURCE_DIR}/Camera.h
${PROJECT_SOURCE_DIR}/Camera.cpp
${PROJECT_SOURCE_DIR}/Transform.h
${PROJECT_SOURCE_DIR}/Transform.cpp
${PROJECT_SOURCE_DIR}/Asset.h
${PROJECT_SOURCE_DIR}/Asset.cpp
${PROJECT_SOURCE_DIR}/Mesh.h
${PROJECT_SOURCE_DIR}/Mesh.cpp
${PROJECT_SOURCE_DIR}/Renderable.h
${PROJECT_SOURCE_DIR}/Renderable.cpp
${PROJECT_SOURCE_DIR}/Scene.h
${PROJECT_SOURCE_DIR}/Scene.cpp
${PROJECT_SOURCE_DIR}/Light.h
${PROJECT_SOURCE_DIR}/Light.cpp
${PROJECT_SOURCE_DIR}/FrameData.h
${PROJECT_SOURCE_DIR}/FrameData.cpp
${PROJECT_SOURCE_DIR}/Allocator.h
${PROJECT_SOURCE_DIR}/Allocator.cpp
${PROJECT_SOURCE_DIR}/MemTracker.h
${PROJECT_SOURCE_DIR}/MemTracker.cpp
${PROJECT_SOURCE_DIR}/Cube.h
${PROJECT_SOURCE_DIR}/Cube.cpp
${PROJECT_SOURCE_DIR}/ShadowMap.h
${PROJECT_SOURCE_DIR}/ShadowMap.cpp
${PROJECT_SOURCE_DIR}/FrameBuffer.h
${PROJECT_SOURCE_DIR}/FrameBuffer.cpp
${PROJECT_SOURCE_DIR}/FullscreenQuad.h
${PROJECT_SOURCE_DIR}/FullscreenQuad.cpp
${PROJECT_SOURCE_DIR}/Quad.h
${PROJECT_SOURCE_DIR}/Quad.cpp
${PROJECT_SOURCE_DIR}/PostProcessing.h
${PROJECT_SOURCE_DIR}/PostProcessing.cpp
${PROJECT_SOURCE_DIR}/external/stb_image.cpp
external/src/imgui/imgui.cpp
external/src/imgui/imgui_draw.cpp
external/src/imgui/imgui_widgets.cpp
external/src/imgui/examples/imgui_impl_opengl3.cpp
external/src/imgui/examples/imgui_impl_sdl.cpp
${PROJECT_SOURCE_DIR}/main.cpp
)
add_executable(${PROJECT_NAME} ${SOURCES})
# SDL
add_subdirectory(external/src/sdl)
set(SDL_STATIC OFF)
include_directories(external/src/sdl/include)
target_link_libraries(${PROJECT_NAME} SDL2)
# GLAD
add_subdirectory(external/src/glad)
set(GLAD_ALL_EXTENSIONS ON)
include_directories(external/src/glad/include/glad)
target_link_libraries(${PROJECT_NAME} glad)
# D3D11
if(WIN32)
target_sources(${PROJECT_NAME}
PRIVATE
src/pixel.hlsl
src/vertex.hlsl
)
set(ShaderModel 5.0)
set_source_files_properties(src/vertex.hlsl PROPERTIES VS_SHADER_FLAGS "/Fh \"$(OutDir)%(Filename).h\"" VS_SHADER_TYPE Vertex VS_SHADER_MODEL ${ShaderModel} VS_SHADER_ENTRYPOINT vert)
set_source_files_properties(src/pixel.hlsl PROPERTIES VS_SHADER_FLAGS "/Fh \"$(OutDir)%(Filename).h\"" VS_SHADER_TYPE Pixel VS_SHADER_MODEL ${ShaderModel} VS_SHADER_ENTRYPOINT frag)
target_link_libraries(${PROJECT_NAME} d3d11 D3DCompiler)
# work dir for visual studio
# set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)")
endif()
# Vulkan
find_package(Vulkan)
if(VULKAN_FOUND)
# add_definitions(VULKAN)
include_directories(${VULKAN_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${VULKAN_LIBRARY})
if(WIN32)
# post build hook for transpiling glsl to spv
# add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND call "$(SolutionDir)scripts/transpileGlsl.bat" "$(OutDir)shaders")
endif()
endif(VULKAN_FOUND)
# std headers
include_directories(external/src/stb)
# assimp
# todo: figure out a way to override the destination for this shit. ASSIMP_BIN_INSTALL_DIR is a cached var
set(ASSIMP_NO_EXPORT ON)
set(ASSIMP_INSTALL OFF)
set(ASSIMP_BUILD_TESTS OFF)
set(ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT OFF)
set(ASSIMP_BUILD_FBX_IMPORTER ON)
set(ASSIMP_BUILD_ZLIB ON)
set(ASSIMP_BUILD_ASSIMP_TOOLS OFF)
# set(ASSIMP_BIN_INSTALL_DIR ${EXECUTABLE_OUTPUT_PATH})
add_subdirectory(external/src/assimp)
target_link_libraries(${PROJECT_NAME} assimp)
# imgui
include_directories(external/src/imgui)
include_directories(external/src/imgui/examples)
# glm
include_directories(external/src/glm)