-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
136 lines (110 loc) · 5.49 KB
/
Copy pathCMakeLists.txt
File metadata and controls
136 lines (110 loc) · 5.49 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# Detects whether this is a top-level project
get_directory_property(HAS_PARENT PARENT_DIRECTORY)
if(HAS_PARENT)
set(MOLTEN_VK_TOPLEVEL_PROJECT OFF)
else()
set(MOLTEN_VK_TOPLEVEL_PROJECT ON)
endif()
# Check required CMake version
set(REQUIRED_CMAKE_VERSION "3.18.0")
if(MOLTEN_VK_TOPLEVEL_PROJECT)
cmake_minimum_required(VERSION ${REQUIRED_CMAKE_VERSION})
else()
# Don't use cmake_minimum_required here to avoid implicitly overriding parent policies
if(${CMAKE_VERSION} VERSION_LESS ${REQUIRED_CMAKE_VERSION})
message(FATAL_ERROR "CMake required version to build MoltenVK is ${REQUIRED_CMAKE_VERSION}")
endif()
endif()
# Include user-provided default options if available. We do that before the main
# `project()` so that we can define the C/C++ compilers from the option file.
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/MoltenVKOptions.cmake)
message(STATUS "Using local options file: ${CMAKE_CURRENT_SOURCE_DIR}/MoltenVKOptions.cmake")
include(${CMAKE_CURRENT_SOURCE_DIR}/MoltenVKOptions.cmake)
endif()
# Enable ccache if available
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
option(MOLTEN_VK_WITH_CCACHE "Enable ccache when building MoltenVK" ${MOLTEN_VK_TOPLEVEL_PROJECT})
else()
option(MOLTEN_VK_WITH_CCACHE "Enable ccache when building MoltenVK" OFF)
endif()
if(MOLTEN_VK_WITH_CCACHE AND CCACHE_PROGRAM)
message(STATUS "Enabling Ccache support (${CCACHE_PROGRAM})")
set(ccacheEnv
CCACHE_BASEDIR=${CMAKE_BINARY_DIR}
CCACHE_SLOPPINESS=clang_index_store,include_file_ctime,include_file_mtime,locale,pch_defines,time_macros
)
foreach(lang IN ITEMS C CXX)
set(CMAKE_${lang}_COMPILER_LAUNCHER
${CMAKE_COMMAND} -E env ${ccacheEnv} ${CCACHE_PROGRAM}
)
endforeach()
endif()
################################################################################
# CMake Policies
################################################################################
cmake_policy(SET CMP0054 NEW) # Only interpret if() arguments as variables or keywords when unquoted.
cmake_policy(SET CMP0076 NEW) # target_sources() command converts relative paths to absolute.
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24")
cmake_policy(SET CMP0135 NEW) # Set the timestamps of all extracted contents to the time of the extraction.
endif()
cmake_policy(SET CMP0114 NEW) # Support the Xcode "new build system"
################################################################################
project(MoltenVK
DESCRIPTION "MoltenVK is a Vulkan Portability implementation. It layers a subset of the high-performance, industry-standard Vulkan graphics and compute API over Apple's Metal graphics framework, enabling Vulkan applications to run on macOS, iOS and tvOS."
LANGUAGES C CXX OBJC OBJCXX
VERSION "1.4.2")
set(MVK_CONFIG_LOG_LEVEL "info" CACHE STRING "Set the default log level for MoltenVK. Options are: debug, info, warn, error, off. Default is 'info'.")
set_property(CACHE MVK_CONFIG_LOG_LEVEL PROPERTY STRINGS "debug" "info" "warn" "error" "off")
option(MVK_EXCLUDE_SPIRV_TOOLS "Exclude the SPIRV-Tools dependency. If excluded, disables printing debug SPIR-V disassembly." OFF)
option(MVK_EXCLUDE_CEREAL "Exclude the cereal dependency. If excluded, disables reading and writing pipeline caches." OFF)
option(MVK_USE_METAL_PRIVATE_API "If enabled, MoltenVK will use private interfaces exposed by Metal to implement Vulkan features that are difficult to support otherwise." OFF)
option(MVK_BUILD_SHADER_CONVERTER_TOOL "If enabled, the MoltenVKShaderConverter executable will be built." OFF)
# Set default minimum C++ standard
if(MOLTEN_VK_TOPLEVEL_PROJECT)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
### Configuration
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/MoltenVK/")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/recipes/")
# General CMake utils
set(CPM_USE_NAMED_CACHE_DIRECTORIES 1)
include(MoltenVK_CPM_Cache)
# Generate position-independent code by default
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(NOT DEFINED MOLTEN_VK_EXTERNAL_REVISIONS_DIR)
set(MOLTEN_VK_EXTERNAL_REVISIONS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ExternalRevisions")
endif()
################################################################################
# MoltenVK Libraries
################################################################################
# MoltenVK::Common
add_subdirectory("Common")
# MoltenVK::ShaderConverter
add_subdirectory("MoltenVKShaderConverter/MoltenVKShaderConverter")
## MoltenVK::MoltenVK
add_subdirectory("MoltenVK")
## MoltenVKShaderConverter
if(MVK_BUILD_SHADER_CONVERTER_TOOL)
add_subdirectory("MoltenVKShaderConverter/MoltenVKShaderConverterTool")
endif()
################################################################################
# Install
################################################################################
if(MOLTEN_VK_TOPLEVEL_PROJECT)
include(GNUInstallDirs)
install(TARGETS MoltenVK
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/MoltenVK")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Templates/cmake/MoltenVK.pc.in" MoltenVK.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/MoltenVK.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Templates/cmake/MoltenVK_icd.json.in" MoltenVK_icd.json @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/MoltenVK_icd.json
DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/vulkan/icd.d)
if(MVK_BUILD_SHADER_CONVERTER_TOOL)
install(TARGETS MoltenVKShaderConverter)
endif()
endif()