-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
71 lines (67 loc) · 1.98 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
cmake_minimum_required(VERSION 3.24)
project(blocks)
set(BINARY_DIR ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${BINARY_DIR})
make_directory(${BINARY_DIR})
add_subdirectory(lib/SDL)
add_executable(blocks WIN32
lib/sqlite3/sqlite3.c
lib/stb/stb.c
lib/tinycthread/tinycthread.c
src/block.c
src/camera.c
src/chunk.c
src/database.c
src/helpers.c
src/main.c
src/noise.c
src/pipeline.c
src/raycast.c
src/voxel.c
src/world.c
)
target_link_libraries(blocks PUBLIC SDL3::SDL3)
if(UNIX)
target_link_libraries(blocks PUBLIC m)
endif()
target_include_directories(blocks PUBLIC lib/sqlite3)
target_include_directories(blocks PUBLIC lib/stb)
target_include_directories(blocks PUBLIC lib/tinycthread)
set_target_properties(blocks PROPERTIES C_STANDARD 11)
function(shader FILE)
set(SOURCE shaders/${FILE})
set(OUTPUT ${BINARY_DIR}/${FILE})
add_custom_command(
OUTPUT ${OUTPUT}
COMMAND glslc ${SOURCE} -o ${OUTPUT} -I src
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS ${SOURCE} shaders/helpers.glsl src/config.h
COMMENT ${SOURCE}
)
string(REPLACE . _ NAME ${FILE})
add_custom_target(${NAME} DEPENDS ${OUTPUT})
add_dependencies(blocks ${NAME})
endfunction()
shader(composite.frag)
shader(fullscreen.vert)
shader(opaque.frag)
shader(opaque.vert)
shader(random.frag)
shader(raycast.frag)
shader(raycast.vert)
shader(shadow.frag)
shader(shadow.vert)
shader(sky.frag)
shader(sky.vert)
shader(ssao.frag)
shader(transparent.frag)
shader(transparent.vert)
shader(ui.frag)
configure_file(LICENSE.txt ${BINARY_DIR} COPYONLY)
configure_file(README.md ${BINARY_DIR} COPYONLY)
configure_file(textures/atlas.png ${BINARY_DIR} COPYONLY)