forked from SaschaWillems/Vulkan
-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
CMakeLists.txt
66 lines (51 loc) · 2.07 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
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
include("cmake/defaults.cmake")
set(NAME VulkanCppExamples)
include(${CMAKE_SOURCE_DIR}/cmake/ezvcpkg/ezvcpkg.cmake)
ezvcpkg_fetch(
COMMIT af2287382b1991dbdcb7e5112d236f3323b9dd7a
PACKAGES assimp basisu imgui glad glfw3 gli glm vulkan
UPDATE_TOOLCHAIN
)
project(${NAME})
if (NOT "${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
message( FATAL_ERROR "Only 64 bit builds supported." )
endif()
include("cmake/compiler.cmake")
find_package(Threads REQUIRED)
# This define is specific to Vulkan has a depth range of [0, 1], unlike OpenGL which has a [-1, 1]
add_definitions(-DGLM_FORCE_DEPTH_ZERO_TO_ONE)
if (NOT ANDROID)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/bin_debug")
set(CMAKE_DEBUG_POSTFIX "d")
add_custom_target(SetupRelease ALL ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/bin)
set_target_properties(SetupRelease PROPERTIES FOLDER "CMakeTargets")
add_custom_target(SetupDebug ALL ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/bin_debug)
set_target_properties(SetupDebug PROPERTIES FOLDER "CMakeTargets")
endif()
if (ANDROID)
add_definitions(-DVULKAN_HPP_NO_SMART_HANDLE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate")
set(APP_GLUE_DIR ${ANDROID_NDK}/sources/android/native_app_glue)
include_directories(${APP_GLUE_DIR})
add_library(app-glue STATIC ${APP_GLUE_DIR}/android_native_app_glue.c)
endif()
if (ANDROID)
add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR)
elseif (WIN32)
add_definitions(-DVK_USE_PLATFORM_WIN32_KHR)
else()
add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
find_package(XCB REQUIRED)
link_libraries(${XCB_LIBRARIES})
endif()
add_subdirectory(base)
include_directories(base)
if (NOT WIN32)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
link_libraries(${CMAKE_THREAD_LIBS_INIT})
endif()
add_subdirectory(examples)