forked from KhronosGroup/Vulkan-Profiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
106 lines (84 loc) · 4.06 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
98
99
100
101
102
103
104
105
106
cmake_minimum_required(VERSION 3.17.2)
enable_testing()
project(VULKAN_PROFILES LANGUAGES CXX C)
include(GNUInstallDirs)
option(PROFILES_BUILD_TESTS "Build profile tests" ON)
set(PROFILES_CPP_STANDARD 17 CACHE STRING "Set the C++ standard to build against.")
set(CMAKE_CXX_STANDARD ${PROFILES_CPP_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
set(CMAKE_C_VISIBILITY_PRESET "hidden")
set(CMAKE_VISIBILITY_INLINES_HIDDEN "YES")
# Regenerating profiles requires Python 3.7.2 or better (for typing.OrderedDict).
# Regeneration jsoncpp requires Python 3.
# Otherwise Python is not required, as checked-in generated code and
# headers will be used.
find_package(PythonInterp 3.7.2 REQUIRED)
add_subdirectory(scripts)
find_package(VulkanHeaders REQUIRED CONFIG QUIET)
find_file(VVL_INCLUDE_DIR vk_dispatch_table_helper.h REQUIRED CMAKE_FIND_ROOT_PATH_BOTH)
get_filename_component(VVL_INCLUDE_DIR ${VVL_INCLUDE_DIR} DIRECTORY)
# Effectively the header files installed by VVL are part of Vulkan::Headers
# This reflects the current structure of the VulkanSDK.
target_include_directories(Vulkan::Headers INTERFACE ${VVL_INCLUDE_DIR})
find_package(valijson REQUIRED CONFIG)
find_package(jsoncpp REQUIRED CONFIG)
if(PROFILES_BUILD_TESTS)
find_package(GTest REQUIRED CONFIG)
endif()
if (NOT ANDROID)
# The vulkan loader search is:
# User-supplied setting of CMAKE_PREFIX_PATH
# VULKAN_LOADER_INSTALL_DIR defined via cmake option
# VULKAN_LOADER_INSTALL_DIR defined via environment variable
# Default findVulkan operation if the VULKAN_SDK environment variable is defined
set(VULKAN_LOADER_INSTALL_DIR "LOADER-NOTFOUND" CACHE PATH "Absolute path to a Vulkan-Loader install directory")
if (VULKAN_LOADER_INSTALL_DIR)
message(STATUS "VULKAN_LOADER_INSTALL_DIR specified, using find_package to locate Vulkan")
elseif(ENV{VULKAN_LOADER_INSTALL_DIR})
message(STATUS "VULKAN_LOADER_INSTALL_DIR environment variable specified, using find_package to locate Vulkan")
endif()
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH};${VULKAN_LOADER_INSTALL_DIR};${VULKAN_HEADERS_INSTALL_DIR};$ENV{VULKAN_LOADER_INSTALL_DIR};$ENV{VULKAN_HEADERS_INSTALL_DIR})
find_package(Vulkan)
endif()
# Enable GUI folders
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# NOTE: The idiom for open source projects is to not enable warnings as errors.
# This reduces problems for users who simply want to build the repository.
option(BUILD_WERROR "Treat compiler warnings as errors" OFF)
if (BUILD_WERROR)
add_compile_options("$<IF:$<CXX_COMPILER_ID:MSVC>,/WX,-Werror>")
endif()
# Platform-specific compiler switches
if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
add_compile_options(-Werror)
endif()
if(${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)")
add_compile_options(-Werror)
elseif(MSVC)
add_compile_options(/W4 /WX)
add_link_options(/WX)
# Ignore some warnings that we know we'll generate. In the future the
# code that generates these warnings should be fixed properly.
# vk_layer_logging.h provokes:
# warning C4100: 'default_flag_is_spec': unreferenced formal parameter
# vk_loader_platform.h provokes:
# warning C4505: unreferenced local function has been removed
# jsoncpp.cpp provokes:
# warning C4702: unreachable code
# gtest.h provokes:
# warning C4389: '==': signed/unsigned mismatch
# warning C4018: '>=': signed/unsigned mismatch
# vulkan_profiles.hpp provokes:
# warning C4245: '=': conversion from 'int' to 'uint64_t', signed/unsigned mismatch
# warning C4305: '=': truncation from 'double' to 'float'
add_compile_options(/wd4100 /wd4505 /wd4702 /wd4389 /wd4245 /wd4305 /wd4018)
endif()
set(PROFILES_SCHEMA_FILENAME "profiles-0.8-latest.json")
# The profiles directory regenerates the Profiles source and headers.
add_subdirectory(profiles)
add_subdirectory(library)
add_subdirectory(layer-utils)
add_subdirectory(layer)