-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
86 lines (60 loc) · 3.21 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
cmake_minimum_required(VERSION 3.9)
# This CMake project is not made for using inside of other projects,
# Always required :
# A CMake installation on the system PATH
# Git, also on PATH
# Compiling CMake on windows requires a MinGW installation on the PATH.
# MinGW can be downloaded from here : [https://sourceforge.net/projects/mingw-w64/files/latest/download]
# Unpack the zip in any directory, but preferrably C:\MinGW
# To add MinGW to PATH, search for environment variables in settings, edit PATH, then add the MinGW/bin directory
# When running CMake, specify using MinGW files with '-G"MinGW Makefiles"' in the command line.
# Linux normally has GCC installed for compilation, but if not, you can use a package manager to get it.
# Make sure to have 'make' installed for makefile compilation.
# CMake should handle the rest. Probably. Just run cmake -Bbuild
# For all systems, compilation command should be >'cmake --build <build folder>'
# I have no clue about Mac. Probably more finicky as you'll need MoltenVK for Vulkan, and I don't know about CMake on Apple either.
project(VulkanTest)
set(EXE_NAME VulkanTest_x86-64)
file(GLOB SRC CONFIGURE_DEPENDS "*.cpp")
add_executable(${EXE_NAME} ${SRC})
include(ExternalProject)
set(EXTERNAL ${CMAKE_BINARY_DIR}/external)
set(EXTERNAL_PACKAGE_DIR ${EXTERNAL}/packages)
set(EXTERNAL_INSTALL_DIR ${EXTERNAL}/install)
set(EXTERNAL_INCLUDE_DIR ${EXTERNAL_INSTALL_DIR}/include)
set(IMPORTED_LIB_DIR ${EXTERNAL_INSTALL_DIR}/lib)
ExternalProject_Add(vulkan
GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers
GIT_TAG main
PREFIX ${EXTERNAL_PACKAGE_DIR}/vulkan
CMAKE_ARGS -DBUILD_TESTS=Off -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_DIR}
)
ExternalProject_Add(glfw
GIT_REPOSITORY https://github.com/glfw/glfw
GIT_TAG master
PREFIX ${EXTERNAL_PACKAGE_DIR}/glfw
CMAKE_ARGS -DGLFW_BUILD_EXAMPLES=Off -DGLFW_BUILD_TESTS=Off -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_DIR}
)
ExternalProject_Add(glm
GIT_REPOSITORY https://github.com/g-truc/glm
GIT_TAG master
PREFIX ${EXTERNAL_PACKAGE_DIR}/glm
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_DIR}
)
add_dependencies(${EXE_NAME} vulkan glfw glm)
# TODO : Make this correctly download sometime
#FetchContent_Declare(VULKAN_VALIDATION
# GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers
# GIT_TAG master
# CMAKE_ARGS -DBUILD_TESTS=Off -DBUILD_DEMOS=Off -DBUILD_WSI_MIR_SUPPORT=Off -DBUILD_WSI_WAYLAND_SUPPORT=Off -DBUILD_WSI_XLIB_SUPPORT=Off -DBUILD_WSI_XCB_SUPPORT=Off -DCMAKE_BINARY_DIR=${EXTERNAL_INSTALL_DIR}
#)
# set include directory
target_include_directories(${EXE_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty ${EXTERNAL_INCLUDE_DIR})
# TODO : Find out how to identify the proper glfw libraries
set(GLFW_LIB "${IMPORTED_LIB_DIR}/libglfw3.a")
target_link_libraries(${EXE_NAME} ${GLFW_LIB})
file(COPY resources DESTINATION ${CMAKE_BINARY_DIR})
file(COPY shaders DESTINATION ${CMAKE_BINARY_DIR})
install(TARGETS ${EXE_NAME} DESTINATION ${CMAKE_BINARY_DIR}/bin)
install(DIRECTORY resources DESTINATION ${CMAKE_BINARY_DIR}/bin)
install(DIRECTORY shaders DESTINATION ${CMAKE_BINARY_DIR}/bin)