-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
97 lines (69 loc) · 3.6 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
cmake_minimum_required(VERSION 3.10)
project( vkw LANGUAGES CXX)
################################################################################
# Create an interface for vkw so that it can be
# included as a subdir
################################################################################
add_library(vkw INTERFACE)
add_library(vkw::vkw ALIAS vkw)
target_include_directories(vkw INTERFACE include)
target_link_libraries( vkw INTERFACE)
################################################################################
################################################################################
# Only create examples if this project is a root project
# if it is included as a subdirectory it will not create the examples
################################################################################
get_directory_property(vkw_has_parent PARENT_DIRECTORY)
if(vkw_has_parent)
# Don't build examples if we are a submodule.
message("Not building examples")
option(VKW_BUILD_EXAMPLES "Build examples" OFF)
else()
option(VKW_BUILD_EXAMPLES "Build examples" ON)
endif()
################################################################################
if( VKW_BUILD_EXAMPLES )
# Set the current binary directory
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_MODULE_PATH})
# Needed for vulkan
find_package(Vulkan REQUIRED)
find_package(SDL2 REQUIRED)
find_package(glfw3 REQUIRED)
find_package(vulkan-validationlayers REQUIRED)
add_executable( example_GLFWWindow examples/example_GLFWWindow.cpp )
target_link_libraries(example_GLFWWindow glfw::glfw vkw::vkw Vulkan::Vulkan)
add_executable( example_SDLWindow examples/example_SDLWindow.cpp )
target_link_libraries(example_SDLWindow SDL2::SDL2 vkw::vkw Vulkan::Vulkan vulkan-validationlayers::vulkan-validationlayers)
add_executable( example_SDLWindow_vulkanProfiles examples/example_SDLWindow_vulkanProfiles.cpp )
target_link_libraries(example_SDLWindow_vulkanProfiles SDL2::SDL2 vkw::vkw Vulkan::Vulkan vulkan-validationlayers::vulkan-validationlayers)
add_executable( example_widget_sdl examples/example_widget.cpp )
target_link_libraries(example_widget_sdl SDL2::SDL2 vkw::vkw Vulkan::Vulkan)
target_compile_definitions(example_widget_sdl PRIVATE VKW_WINDOW_LIB=1)
add_executable( example_widget_glfw examples/example_widget.cpp )
target_link_libraries(example_widget_glfw glfw::glfw vkw::vkw Vulkan::Vulkan)
target_compile_definitions(example_widget_glfw PRIVATE VKW_WINDOW_LIB=2)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# First look for Qt6
find_package(Qt6 COMPONENTS Widgets)
if (QT6_INSTALL_PREFIX)
add_executable( example_widget_qt example_widget_qt.cpp )
target_link_libraries(example_widget_qt Qt6::Widgets pthread vkw::vkw vkw::vkw Vulkan::Vulkan)
else()
find_package(Qt5 COMPONENTS Widgets)
if( Qt5Widgets_FOUND )
if (Qt5Widgets_VERSION VERSION_LESS 5.15.0)
message(NOTICE "Minimum supported Qt5 version is 5.15. Cannot build Qt examples!")
else()
add_executable( example_widget_qt example_widget_qt.cpp )
target_link_libraries(example_widget_qt Qt5::Widgets pthread vkw::vkw vkw::vkw Vulkan::Vulkan)
endif()
else()
message(NOTICE "The Qt5 library could not be found! Not building Qt examples")
endif()
endif()
endif()
################################################################################