-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
89 lines (72 loc) · 3.24 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
cmake_minimum_required(VERSION 3.0)
project(ffGraph VERSION 0.1.0 LANGUAGES CXX)
message(STATUS "VULKAN_SDK : $ENV{VULKAN_SDK}")
find_package(Threads REQUIRED)
find_package(Vulkan REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# Compiling shaders
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(GLSL_VALIDATOR "$ENV{VULKAN_SDK}/bin/glslangValidator")
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(GLSL_VALIDATOR "$ENV{VULKAN_SDK}/bin/glslangValidator")
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(GLSL_VALIDATOR "$ENV{VULKAN_SDK}/bin/glslangValidator.exe")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -D_DEBUG")
add_subdirectory(${CMAKE_SOURCE_DIR}/src/JSON)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/network)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Vulkan)
add_subdirectory(${CMAKE_SOURCE_DIR}/extern/glfw)
# Telling Cmake to compile a executable
add_executable(ffGraph ${CMAKE_SOURCE_DIR}/src/main.cpp)
list(APPEND GLSL_SOURCE_FILES
${CMAKE_SOURCE_DIR}/shaders/Geo2D.vert
${CMAKE_SOURCE_DIR}/shaders/Geo3D.vert
${CMAKE_SOURCE_DIR}/shaders/Vector.vert
${CMAKE_SOURCE_DIR}/shaders/Color.frag
${CMAKE_SOURCE_DIR}/shaders/UI.frag
${CMAKE_SOURCE_DIR}/shaders/UI.vert
)
foreach(GLSL ${GLSL_SOURCE_FILES})
get_filename_component(FILE_NAME ${GLSL} NAME)
set(SPIRV "${PROJECT_BINARY_DIR}/shaders/${FILE_NAME}.spirv")
add_custom_command(
OUTPUT ${SPIRV}
COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/shaders/"
COMMAND ${GLSL_VALIDATOR} -V ${GLSL} -o ${SPIRV}
DEPENDS ${GLSL})
list(APPEND SPIRV_BINARY_FILES ${SPIRV})
endforeach(GLSL)
add_custom_target(
Shaders
DEPENDS ${SPIRV_BINARY_FILES}
)
add_dependencies(ffGraph Shaders)
add_custom_command(TARGET ffGraph POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/shaders/"
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_BINARY_DIR}/shaders"
"${PROJECT_BINARY_DIR}/shaders"
)
file(COPY "${CMAKE_SOURCE_DIR}/shaders/grid.json" DESTINATION "${CMAKE_BINARY_DIR}/shaders")
# Done compiling shaders
if (WIN32)
target_link_libraries(ffGraph wsock32 ws2_32)
endif (WIN32)
# Using C++11 standard
set_target_properties(ffGraph PROPERTIES CXX_STANDARD 11)
# Linking libraries with target
target_include_directories(ffGraph PRIVATE ${Vulkan_INCLUDE_DIR})
target_include_directories(ffGraph PRIVATE ${CMAKE_SOURCE_DIR}/extern/asio/asio/include)
target_include_directories(ffGraph PRIVATE ${CMAKE_SOURCE_DIR}/extern/glfw/include)
target_include_directories(ffGraph PRIVATE ${CMAKE_SOURCE_DIR}/extern/VulkanMemoryAllocator/src)
target_include_directories(ffGraph PRIVATE ${CMAKE_SOURCE_DIR}/extern/glm)
target_include_directories(ffGraph PRIVATE ${CMAKE_SOURCE_DIR}/extern/json/include)
target_link_libraries(ffGraph Threads::Threads)
target_include_directories(ffGraph PRIVATE ${CMAKE_SOURCE_DIR}/src/JSON)
target_link_libraries(ffGraph ffGraph_JSON)
target_include_directories(ffGraph PRIVATE ${CMAKE_SOURCE_DIR}/src/network)
target_link_libraries(ffGraph ffGraph_NET)
target_include_directories(ffGraph PRIVATE ${CMAKE_SOURCE_DIR}/src/util)
target_link_libraries(ffGraph ffGraph_Vulkan)
target_include_directories(ffGraph PRIVATE ${CMAKE_SOURCE_DIR}/src/Vulkan)