-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
76 lines (59 loc) · 2.09 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
cmake_minimum_required(VERSION 3.10)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++14")
endif(MSVC)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(VulkanEngine)
SET(OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY})
# Dependencies
# GLFW
message(STATUS "print_all_variables------------------------------------------{")
add_subdirectory(${CMAKE_SOURCE_DIR}/external/glfw)
set(GLFW_INC ${CMAKE_SOURCE_DIR}/external/glfw/include)
link_directories(${CMAKE_SOURCE_DIR}/external/glfw/lib)
# GLM
set(GLM_INC ${CMAKE_SOURCE_DIR}/external/glm/glm)
# Vulkan
find_package(Vulkan REQUIRED)
# Renderer
add_subdirectory("Renderer")
set(REDER_INC ${CMAKE_SOURCE_DIR}/Renderer/include)
link_directories("${CMAKE_SOURCE_DIR}/Renderer/include")
# Executable
include_directories(include)
file(GLOB_RECURSE SOURCES src/*.cpp include/*.h include/*.hpp)
add_executable(VkEngine ${SOURCES})
target_include_directories(VkEngine PUBLIC ${Vulkan_INCLUDE_DIRS})
target_include_directories(VkEngine PRIVATE ${GLM_INC})
target_include_directories(VkEngine PUBLIC ${GLFW_INC})
target_include_directories(VkEngine PUBLIC ${REDER_INC})
target_link_libraries(VkEngine renderer glfw ${GLFW_LIBRARIES} Vulkan::Vulkan)
# Compile the shaders based on platform
if(MSVC)
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/scripts/compile.bat)
endif(MSVC)
if(UNIX)
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/scripts/compile.sh)
endif(UNIX)
if (MSVC)
set_target_properties(VkEngine PROPERTIES
VS_DEBUGGER_WORKING_DIRECTORY
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(Configuration)
)
# Copy
add_custom_target(copy_resources ALL COMMAND ${CMAKE_COMMAND}
-E copy_directory
"${PROJECT_SOURCE_DIR}/resources"
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIGURATION>/resources
)
else()
# Copy
add_custom_target(copy_resources ALL COMMAND ${CMAKE_COMMAND}
-E copy_directory
"${PROJECT_SOURCE_DIR}/resources"
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}resources
)
endif()
add_dependencies(VkEngine copy_resources)