Jon Ashburn | d38bfb1 | 2014-10-14 19:15:22 -0600 | [diff] [blame] | 1 | cmake_minimum_required (VERSION 2.8.11) |
| 2 | |
Tony Barbour | 29cc952 | 2016-12-07 11:18:19 -0700 | [diff] [blame] | 3 | if(CMAKE_SYSTEM_NAME STREQUAL "Windows") |
| 4 | add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN) |
| 5 | set(DisplayServer Win32) |
| 6 | elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") |
| 7 | add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR) |
| 8 | elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 9 | if (BUILD_WSI_XCB_SUPPORT) |
| 10 | add_definitions(-DVK_USE_PLATFORM_XCB_KHR) |
| 11 | endif() |
| 12 | |
| 13 | if (BUILD_WSI_XLIB_SUPPORT) |
| 14 | add_definitions(-DVK_USE_PLATFORM_XLIB_KHR) |
| 15 | endif() |
| 16 | |
| 17 | if (BUILD_WSI_WAYLAND_SUPPORT) |
| 18 | add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR) |
| 19 | endif() |
| 20 | |
| 21 | if (BUILD_WSI_MIR_SUPPORT) |
| 22 | add_definitions(-DVK_USE_PLATFORM_MIR_KHR) |
Tony Barbour | c53c727 | 2016-12-07 10:19:21 -0700 | [diff] [blame] | 23 | include_directories(${MIR_INCLUDE_DIR}) |
Tony Barbour | 29cc952 | 2016-12-07 11:18:19 -0700 | [diff] [blame] | 24 | endif() |
| 25 | else() |
| 26 | message(FATAL_ERROR "Unsupported Platform!") |
| 27 | endif() |
| 28 | |
Mark Lobodzinski | 2e9a492 | 2016-12-06 13:14:55 -0700 | [diff] [blame] | 29 | macro(run_vk_xml_generate dependency output) |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 30 | add_custom_command(OUTPUT ${output} |
Mark Lobodzinski | e10b354 | 2016-11-18 15:04:50 -0700 | [diff] [blame] | 31 | COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/lvl_genvk.py -registry ${SCRIPTS_DIR}/vk.xml ${output} |
| 32 | DEPENDS ${SCRIPTS_DIR}/vk.xml ${SCRIPTS_DIR}/generator.py ${SCRIPTS_DIR}/${dependency} ${SCRIPTS_DIR}/lvl_genvk.py ${SCRIPTS_DIR}/reg.py |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 33 | ) |
Mike Stroyan | 845bdc4 | 2015-11-02 15:30:20 -0700 | [diff] [blame] | 34 | endmacro() |
Mark Lobodzinski | c97e264 | 2016-10-13 08:58:38 -0600 | [diff] [blame] | 35 | |
Courtney Goeltzenleuchter | b38936a | 2015-07-07 14:27:31 -0600 | [diff] [blame] | 36 | set(LAYER_JSON_FILES |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 37 | VkLayer_core_validation |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 38 | VkLayer_image |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 39 | VkLayer_object_tracker |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 40 | VkLayer_unique_objects |
Mark Lobodzinski | 739391a | 2016-03-17 15:08:18 -0600 | [diff] [blame] | 41 | VkLayer_parameter_validation |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 42 | VkLayer_swapchain |
| 43 | VkLayer_threading |
Courtney Goeltzenleuchter | b38936a | 2015-07-07 14:27:31 -0600 | [diff] [blame] | 44 | ) |
| 45 | |
Karl Schultz | c61bc7a | 2016-04-08 09:17:18 -0600 | [diff] [blame] | 46 | if (WIN32) |
Courtney Goeltzenleuchter | b38936a | 2015-07-07 14:27:31 -0600 | [diff] [blame] | 47 | if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) |
Mark Mueller | b33052d | 2016-04-18 11:04:36 -0600 | [diff] [blame] | 48 | if (CMAKE_GENERATOR MATCHES "^Visual Studio.*") |
| 49 | foreach (config_file ${LAYER_JSON_FILES}) |
| 50 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/windows/${config_file}.json src_json) |
| 51 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/${config_file}.json dst_json) |
| 52 | add_custom_target(${config_file}-json ALL |
| 53 | COMMAND copy ${src_json} ${dst_json} |
| 54 | VERBATIM |
| 55 | ) |
Mike Stroyan | 1c00162 | 2016-09-16 09:45:14 -0600 | [diff] [blame] | 56 | add_dependencies(${config_file}-json ${config_file}) |
Mark Mueller | b33052d | 2016-04-18 11:04:36 -0600 | [diff] [blame] | 57 | endforeach(config_file) |
| 58 | else() |
| 59 | foreach (config_file ${LAYER_JSON_FILES}) |
| 60 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/windows/${config_file}.json src_json) |
| 61 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/${config_file}.json dst_json) |
| 62 | add_custom_target(${config_file}-json ALL |
| 63 | COMMAND copy ${src_json} ${dst_json} |
| 64 | VERBATIM |
| 65 | ) |
Mike Stroyan | 1c00162 | 2016-09-16 09:45:14 -0600 | [diff] [blame] | 66 | add_dependencies(${config_file}-json ${config_file}) |
Mark Mueller | b33052d | 2016-04-18 11:04:36 -0600 | [diff] [blame] | 67 | endforeach(config_file) |
| 68 | endif() |
Courtney Goeltzenleuchter | b38936a | 2015-07-07 14:27:31 -0600 | [diff] [blame] | 69 | endif() |
Karl Schultz | c61bc7a | 2016-04-08 09:17:18 -0600 | [diff] [blame] | 70 | else() |
| 71 | # extra setup for out-of-tree builds |
| 72 | if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) |
| 73 | foreach (config_file ${LAYER_JSON_FILES}) |
| 74 | add_custom_target(${config_file}-json ALL |
| 75 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json |
| 76 | VERBATIM |
| 77 | ) |
Mike Stroyan | 1c00162 | 2016-09-16 09:45:14 -0600 | [diff] [blame] | 78 | add_dependencies(${config_file}-json ${config_file}) |
Karl Schultz | c61bc7a | 2016-04-08 09:17:18 -0600 | [diff] [blame] | 79 | endforeach(config_file) |
| 80 | endif() |
Courtney Goeltzenleuchter | b38936a | 2015-07-07 14:27:31 -0600 | [diff] [blame] | 81 | endif() |
| 82 | |
Karl Schultz | e089d7d | 2016-09-30 13:32:16 -0600 | [diff] [blame] | 83 | # Add targets for JSON file install on Linux. |
| 84 | # Need to remove the "./" from the library path before installing to /etc. |
| 85 | if(UNIX) |
| 86 | foreach (config_file ${LAYER_JSON_FILES}) |
| 87 | add_custom_target(${config_file}-staging-json ALL |
| 88 | COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/staging-json |
| 89 | COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json ${CMAKE_CURRENT_BINARY_DIR}/staging-json |
| 90 | COMMAND sed -i -e "/\"library_path\":/s$./libVkLayer$libVkLayer$" ${CMAKE_CURRENT_BINARY_DIR}/staging-json/${config_file}.json |
| 91 | VERBATIM |
| 92 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json |
| 93 | ) |
John Zupin | f5d304a | 2016-10-27 13:15:27 -0600 | [diff] [blame] | 94 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/staging-json/${config_file}.json DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/vulkan/explicit_layer.d) |
Karl Schultz | e089d7d | 2016-09-30 13:32:16 -0600 | [diff] [blame] | 95 | endforeach(config_file) |
| 96 | endif() |
| 97 | |
Ian Elliott | 2d4ab1e | 2015-01-13 17:52:38 -0700 | [diff] [blame] | 98 | if (WIN32) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 99 | macro(add_vk_layer target) |
Mark Lobodzinski | 4567849 | 2016-12-08 08:40:02 -0700 | [diff] [blame] | 100 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/VkLayer_${target}.def DEF_FILE) |
| 101 | add_custom_target(copy-${target}-def-file ALL |
| 102 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEF_FILE} VkLayer_${target}.def |
| 103 | VERBATIM |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 104 | ) |
| 105 | add_library(VkLayer_${target} SHARED ${ARGN} VkLayer_${target}.def) |
Karl Schultz | c61bc7a | 2016-04-08 09:17:18 -0600 | [diff] [blame] | 106 | target_link_Libraries(VkLayer_${target} VkLayer_utils) |
Mark Lobodzinski | d23ff06 | 2017-01-09 14:42:52 -0700 | [diff] [blame] | 107 | add_dependencies(VkLayer_${target} generate_dispatch_table_helper generate_vk_helper_files VkLayer_utils) |
Ian Elliott | 2d4ab1e | 2015-01-13 17:52:38 -0700 | [diff] [blame] | 108 | endmacro() |
| 109 | else() |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 110 | macro(add_vk_layer target) |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 111 | add_library(VkLayer_${target} SHARED ${ARGN}) |
Karl Schultz | c61bc7a | 2016-04-08 09:17:18 -0600 | [diff] [blame] | 112 | target_link_Libraries(VkLayer_${target} VkLayer_utils) |
Mark Lobodzinski | d23ff06 | 2017-01-09 14:42:52 -0700 | [diff] [blame] | 113 | add_dependencies(VkLayer_${target} generate_dispatch_table_helper generate_vk_helper_files VkLayer_utils) |
Mike Stroyan | 6d650f1 | 2016-09-28 15:15:51 -0600 | [diff] [blame] | 114 | set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic,--exclude-libs,ALL") |
John Zupin | f5d304a | 2016-10-27 13:15:27 -0600 | [diff] [blame] | 115 | install(TARGETS VkLayer_${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
Ian Elliott | 2d4ab1e | 2015-01-13 17:52:38 -0700 | [diff] [blame] | 116 | endmacro() |
| 117 | endif() |
Jon Ashburn | d38bfb1 | 2014-10-14 19:15:22 -0600 | [diff] [blame] | 118 | |
Chia-I Wu | 21bddab | 2014-11-19 23:05:04 +0800 | [diff] [blame] | 119 | include_directories( |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 120 | ${CMAKE_CURRENT_SOURCE_DIR} |
| 121 | ${CMAKE_CURRENT_SOURCE_DIR}/../loader |
| 122 | ${CMAKE_CURRENT_SOURCE_DIR}/../include/vulkan |
| 123 | ${CMAKE_CURRENT_BINARY_DIR} |
Chia-I Wu | 21bddab | 2014-11-19 23:05:04 +0800 | [diff] [blame] | 124 | ) |
| 125 | |
Ian Elliott | 1962880 | 2015-02-04 12:06:46 -0700 | [diff] [blame] | 126 | if (WIN32) |
Mark Young | b445e40 | 2016-01-18 17:22:48 -0700 | [diff] [blame] | 127 | set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_CRT_SECURE_NO_WARNINGS") |
| 128 | set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D_CRT_SECURE_NO_WARNINGS") |
Mark Lobodzinski | 9ee6621 | 2016-03-15 10:31:44 -0600 | [diff] [blame] | 129 | set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS /bigobj") |
| 130 | set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS /bigobj") |
Karl Schultz | c61bc7a | 2016-04-08 09:17:18 -0600 | [diff] [blame] | 131 | else() |
Mike Stroyan | 084e6af | 2016-09-27 14:23:43 -0600 | [diff] [blame] | 132 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpointer-arith -Wno-unused-function -Wno-sign-compare") |
| 133 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith -Wno-unused-function -Wno-sign-compare") |
Ian Elliott | 1962880 | 2015-02-04 12:06:46 -0700 | [diff] [blame] | 134 | endif() |
Jon Ashburn | d38bfb1 | 2014-10-14 19:15:22 -0600 | [diff] [blame] | 135 | |
Mark Lobodzinski | f42b37c | 2016-12-29 13:00:51 -0700 | [diff] [blame] | 136 | add_custom_target(generate_vk_helper_files DEPENDS |
Mike Stroyan | 1c00162 | 2016-09-16 09:45:14 -0600 | [diff] [blame] | 137 | vk_enum_string_helper.h |
Mark Lobodzinski | 2b5fc81 | 2016-12-29 12:58:30 -0700 | [diff] [blame] | 138 | vk_struct_size_helper.h |
| 139 | vk_struct_size_helper.c |
Mark Lobodzinski | d23ff06 | 2017-01-09 14:42:52 -0700 | [diff] [blame] | 140 | vk_safe_struct.h |
| 141 | vk_safe_struct.cpp |
Mike Stroyan | 1c00162 | 2016-09-16 09:45:14 -0600 | [diff] [blame] | 142 | ) |
| 143 | |
| 144 | add_custom_target(generate_dispatch_table_helper DEPENDS |
| 145 | vk_dispatch_table_helper.h |
Chia-I Wu | db2b387 | 2014-12-19 10:59:01 +0800 | [diff] [blame] | 146 | ) |
Chia-I Wu | db2b387 | 2014-12-19 10:59:01 +0800 | [diff] [blame] | 147 | |
Mark Lobodzinski | d23ff06 | 2017-01-09 14:42:52 -0700 | [diff] [blame] | 148 | run_vk_xml_generate(helper_file_generator.py vk_safe_struct.h) |
| 149 | run_vk_xml_generate(helper_file_generator.py vk_safe_struct.cpp) |
Mark Lobodzinski | 2b5fc81 | 2016-12-29 12:58:30 -0700 | [diff] [blame] | 150 | run_vk_xml_generate(helper_file_generator.py vk_struct_size_helper.h) |
| 151 | run_vk_xml_generate(helper_file_generator.py vk_struct_size_helper.c) |
Mark Lobodzinski | 1fa20f9 | 2016-12-27 14:36:51 -0700 | [diff] [blame] | 152 | run_vk_xml_generate(helper_file_generator.py vk_enum_string_helper.h) |
Mark Lobodzinski | 2e9a492 | 2016-12-06 13:14:55 -0700 | [diff] [blame] | 153 | run_vk_xml_generate(threading_generator.py thread_check.h) |
| 154 | run_vk_xml_generate(parameter_validation_generator.py parameter_validation.h) |
| 155 | run_vk_xml_generate(unique_objects_generator.py unique_objects_wrappers.h) |
| 156 | run_vk_xml_generate(dispatch_table_generator.py vk_dispatch_table_helper.h) |
Chia-I Wu | db2b387 | 2014-12-19 10:59:01 +0800 | [diff] [blame] | 157 | |
Karl Schultz | c61bc7a | 2016-04-08 09:17:18 -0600 | [diff] [blame] | 158 | # Layer Utils Library |
Mark Lobodzinski | 8005bb4 | 2016-06-21 15:53:37 -0600 | [diff] [blame] | 159 | # For Windows, we use a static lib because the Windows loader has a fairly restrictive loader search |
| 160 | # path that can't be easily modified to point it to the same directory that contains the layers. |
Ian Elliott | a6bbf3e | 2015-02-12 11:36:44 -0700 | [diff] [blame] | 161 | if (WIN32) |
Mark Lobodzinski | 8005bb4 | 2016-06-21 15:53:37 -0600 | [diff] [blame] | 162 | add_library(VkLayer_utils STATIC vk_layer_config.cpp vk_layer_extension_utils.cpp vk_layer_utils.cpp) |
Mike Stroyan | 897d475 | 2015-07-10 12:51:14 -0600 | [diff] [blame] | 163 | else() |
Karl Schultz | c61bc7a | 2016-04-08 09:17:18 -0600 | [diff] [blame] | 164 | add_library(VkLayer_utils SHARED vk_layer_config.cpp vk_layer_extension_utils.cpp vk_layer_utils.cpp) |
John Zupin | f5d304a | 2016-10-27 13:15:27 -0600 | [diff] [blame] | 165 | install(TARGETS VkLayer_utils DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
Ian Elliott | a6bbf3e | 2015-02-12 11:36:44 -0700 | [diff] [blame] | 166 | endif() |
Karl Schultz | c61bc7a | 2016-04-08 09:17:18 -0600 | [diff] [blame] | 167 | |
Mike Stroyan | b985fca | 2016-11-01 11:50:16 -0600 | [diff] [blame] | 168 | add_vk_layer(core_validation core_validation.cpp vk_layer_table.cpp descriptor_sets.cpp) |
Mark Lobodzinski | 9bab866 | 2016-07-01 10:53:31 -0600 | [diff] [blame] | 169 | add_vk_layer(object_tracker object_tracker.cpp vk_layer_table.cpp) |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 170 | add_vk_layer(image image.cpp vk_layer_table.cpp) |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 171 | add_vk_layer(swapchain swapchain.cpp vk_layer_table.cpp) |
Chia-I Wu | db2b387 | 2014-12-19 10:59:01 +0800 | [diff] [blame] | 172 | # generated |
Mike Stroyan | 845bdc4 | 2015-11-02 15:30:20 -0700 | [diff] [blame] | 173 | add_vk_layer(threading threading.cpp thread_check.h vk_layer_table.cpp) |
Mike Stroyan | b985fca | 2016-11-01 11:50:16 -0600 | [diff] [blame] | 174 | add_vk_layer(unique_objects unique_objects.cpp unique_objects_wrappers.h vk_layer_table.cpp) |
Mark Lobodzinski | 739391a | 2016-03-17 15:08:18 -0600 | [diff] [blame] | 175 | add_vk_layer(parameter_validation parameter_validation.cpp parameter_validation.h vk_layer_table.cpp) |
Chris Forbes | a13ab8a | 2016-04-04 09:52:11 +1200 | [diff] [blame] | 176 | |
| 177 | # Core validation has additional dependencies |
| 178 | target_include_directories(VkLayer_core_validation PRIVATE ${GLSLANG_SPIRV_INCLUDE_DIR}) |
| 179 | target_include_directories(VkLayer_core_validation PRIVATE ${SPIRV_TOOLS_INCLUDE_DIR}) |
Karl Schultz | cca25a6 | 2016-04-28 12:09:34 -0600 | [diff] [blame] | 180 | target_link_libraries(VkLayer_core_validation ${SPIRV_TOOLS_LIBRARIES}) |