Jon Ashburn | d38bfb1 | 2014-10-14 19:15:22 -0600 | [diff] [blame] | 1 | cmake_minimum_required (VERSION 2.8.11) |
| 2 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3 | macro(run_vk_helper subcmd) |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 4 | add_custom_command(OUTPUT ${ARGN} |
| 5 | COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/vk_helper.py --${subcmd} ${PROJECT_SOURCE_DIR}/include/vulkan/vulkan.h --abs_out_dir ${CMAKE_CURRENT_BINARY_DIR} |
| 6 | DEPENDS ${PROJECT_SOURCE_DIR}/vk_helper.py ${PROJECT_SOURCE_DIR}/include/vulkan/vulkan.h |
| 7 | ) |
Chia-I Wu | db2b387 | 2014-12-19 10:59:01 +0800 | [diff] [blame] | 8 | endmacro() |
| 9 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 10 | macro(run_vk_layer_generate subcmd output) |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 11 | add_custom_command(OUTPUT ${output} |
| 12 | COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/vk-layer-generate.py ${DisplayServer} ${subcmd} ${PROJECT_SOURCE_DIR}/include/vulkan/vulkan.h > ${output} |
| 13 | DEPENDS ${PROJECT_SOURCE_DIR}/vk-layer-generate.py ${PROJECT_SOURCE_DIR}/include/vulkan/vulkan.h ${PROJECT_SOURCE_DIR}/vulkan.py |
| 14 | ) |
Chia-I Wu | db2b387 | 2014-12-19 10:59:01 +0800 | [diff] [blame] | 15 | endmacro() |
| 16 | |
Mike Stroyan | 845bdc4 | 2015-11-02 15:30:20 -0700 | [diff] [blame] | 17 | macro(run_vk_layer_xml_generate subcmd output) |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 18 | add_custom_command(OUTPUT ${output} |
| 19 | COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/genvk.py -registry ${PROJECT_SOURCE_DIR}/vk.xml ${output} |
| 20 | DEPENDS ${PROJECT_SOURCE_DIR}/vk.xml ${PROJECT_SOURCE_DIR}/generator.py ${PROJECT_SOURCE_DIR}/genvk.py ${PROJECT_SOURCE_DIR}/reg.py |
| 21 | ) |
Mike Stroyan | 845bdc4 | 2015-11-02 15:30:20 -0700 | [diff] [blame] | 22 | endmacro() |
Courtney Goeltzenleuchter | b38936a | 2015-07-07 14:27:31 -0600 | [diff] [blame] | 23 | set(LAYER_JSON_FILES |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 24 | VkLayer_core_validation |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 25 | VkLayer_image |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 26 | VkLayer_object_tracker |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 27 | VkLayer_unique_objects |
Mark Lobodzinski | 739391a | 2016-03-17 15:08:18 -0600 | [diff] [blame] | 28 | VkLayer_parameter_validation |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 29 | VkLayer_swapchain |
| 30 | VkLayer_threading |
Courtney Goeltzenleuchter | b38936a | 2015-07-07 14:27:31 -0600 | [diff] [blame] | 31 | ) |
| 32 | |
Karl Schultz | c61bc7a | 2016-04-08 09:17:18 -0600 | [diff] [blame] | 33 | if (WIN32) |
Courtney Goeltzenleuchter | b38936a | 2015-07-07 14:27:31 -0600 | [diff] [blame] | 34 | if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) |
Mark Mueller | b33052d | 2016-04-18 11:04:36 -0600 | [diff] [blame] | 35 | if (CMAKE_GENERATOR MATCHES "^Visual Studio.*") |
| 36 | foreach (config_file ${LAYER_JSON_FILES}) |
| 37 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/windows/${config_file}.json src_json) |
| 38 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/${config_file}.json dst_json) |
| 39 | add_custom_target(${config_file}-json ALL |
| 40 | COMMAND copy ${src_json} ${dst_json} |
| 41 | VERBATIM |
| 42 | ) |
| 43 | endforeach(config_file) |
| 44 | else() |
| 45 | foreach (config_file ${LAYER_JSON_FILES}) |
| 46 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/windows/${config_file}.json src_json) |
| 47 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/${config_file}.json dst_json) |
| 48 | add_custom_target(${config_file}-json ALL |
| 49 | COMMAND copy ${src_json} ${dst_json} |
| 50 | VERBATIM |
| 51 | ) |
| 52 | endforeach(config_file) |
| 53 | endif() |
Courtney Goeltzenleuchter | b38936a | 2015-07-07 14:27:31 -0600 | [diff] [blame] | 54 | endif() |
Karl Schultz | c61bc7a | 2016-04-08 09:17:18 -0600 | [diff] [blame] | 55 | else() |
| 56 | # extra setup for out-of-tree builds |
| 57 | if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) |
| 58 | foreach (config_file ${LAYER_JSON_FILES}) |
| 59 | add_custom_target(${config_file}-json ALL |
| 60 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json |
| 61 | VERBATIM |
| 62 | ) |
| 63 | endforeach(config_file) |
| 64 | endif() |
Courtney Goeltzenleuchter | b38936a | 2015-07-07 14:27:31 -0600 | [diff] [blame] | 65 | endif() |
| 66 | |
Ian Elliott | 2d4ab1e | 2015-01-13 17:52:38 -0700 | [diff] [blame] | 67 | if (WIN32) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 68 | macro(add_vk_layer target) |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 69 | add_custom_command(OUTPUT VkLayer_${target}.def |
| 70 | COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/vk-generate.py ${DisplayServer} win-def-file VkLayer_${target} layer > VkLayer_${target}.def |
| 71 | DEPENDS ${PROJECT_SOURCE_DIR}/vk-generate.py ${PROJECT_SOURCE_DIR}/vulkan.py |
| 72 | ) |
| 73 | add_library(VkLayer_${target} SHARED ${ARGN} VkLayer_${target}.def) |
Karl Schultz | c61bc7a | 2016-04-08 09:17:18 -0600 | [diff] [blame] | 74 | target_link_Libraries(VkLayer_${target} VkLayer_utils) |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 75 | add_dependencies(VkLayer_${target} generate_vk_layer_helpers) |
| 76 | set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "/DEF:${CMAKE_CURRENT_BINARY_DIR}/VkLayer_${target}.def") |
Ian Elliott | 2d4ab1e | 2015-01-13 17:52:38 -0700 | [diff] [blame] | 77 | endmacro() |
| 78 | else() |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 79 | macro(add_vk_layer target) |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 80 | add_library(VkLayer_${target} SHARED ${ARGN}) |
Karl Schultz | c61bc7a | 2016-04-08 09:17:18 -0600 | [diff] [blame] | 81 | target_link_Libraries(VkLayer_${target} VkLayer_utils) |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 82 | add_dependencies(VkLayer_${target} generate_vk_layer_helpers) |
| 83 | set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic") |
| 84 | install(TARGETS VkLayer_${target} DESTINATION ${PROJECT_BINARY_DIR}/install_staging) |
Ian Elliott | 2d4ab1e | 2015-01-13 17:52:38 -0700 | [diff] [blame] | 85 | endmacro() |
| 86 | endif() |
Jon Ashburn | d38bfb1 | 2014-10-14 19:15:22 -0600 | [diff] [blame] | 87 | |
Chia-I Wu | 21bddab | 2014-11-19 23:05:04 +0800 | [diff] [blame] | 88 | include_directories( |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 89 | ${CMAKE_CURRENT_SOURCE_DIR} |
| 90 | ${CMAKE_CURRENT_SOURCE_DIR}/../loader |
| 91 | ${CMAKE_CURRENT_SOURCE_DIR}/../include/vulkan |
| 92 | ${CMAKE_CURRENT_BINARY_DIR} |
Chia-I Wu | 21bddab | 2014-11-19 23:05:04 +0800 | [diff] [blame] | 93 | ) |
| 94 | |
Ian Elliott | 1962880 | 2015-02-04 12:06:46 -0700 | [diff] [blame] | 95 | if (WIN32) |
Mark Young | b445e40 | 2016-01-18 17:22:48 -0700 | [diff] [blame] | 96 | set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_CRT_SECURE_NO_WARNINGS") |
| 97 | 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] | 98 | set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS /bigobj") |
| 99 | 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] | 100 | else() |
Ian Elliott | 1962880 | 2015-02-04 12:06:46 -0700 | [diff] [blame] | 101 | set (CMAKE_CXX_FLAGS "-std=c++11") |
Jon Ashburn | ce816b6 | 2016-01-12 11:33:33 -0700 | [diff] [blame] | 102 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpointer-arith") |
| 103 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith") |
Ian Elliott | 1962880 | 2015-02-04 12:06:46 -0700 | [diff] [blame] | 104 | endif() |
Jon Ashburn | d38bfb1 | 2014-10-14 19:15:22 -0600 | [diff] [blame] | 105 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 106 | add_custom_command(OUTPUT vk_dispatch_table_helper.h |
Mark Young | 7b2214e | 2016-08-01 11:06:53 -0600 | [diff] [blame] | 107 | COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/vk-generate.py AllPlatforms dispatch-table-ops layer > vk_dispatch_table_helper.h |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 108 | DEPENDS ${PROJECT_SOURCE_DIR}/vk-generate.py ${PROJECT_SOURCE_DIR}/vulkan.py) |
Chia-I Wu | aa4121f | 2015-01-04 23:11:43 +0800 | [diff] [blame] | 109 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 110 | run_vk_helper(gen_enum_string_helper vk_enum_string_helper.h) |
| 111 | run_vk_helper(gen_struct_wrappers |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 112 | vk_struct_string_helper.h |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 113 | vk_struct_string_helper_cpp.h |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 114 | vk_struct_string_helper_no_addr.h |
| 115 | vk_struct_string_helper_no_addr_cpp.h |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 116 | vk_struct_size_helper.h |
| 117 | vk_struct_size_helper.c |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 118 | vk_struct_wrappers.h |
| 119 | vk_struct_wrappers.cpp |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 120 | vk_safe_struct.h |
| 121 | vk_safe_struct.cpp |
Chia-I Wu | db2b387 | 2014-12-19 10:59:01 +0800 | [diff] [blame] | 122 | ) |
Chia-I Wu | db2b387 | 2014-12-19 10:59:01 +0800 | [diff] [blame] | 123 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 124 | add_custom_target(generate_vk_layer_helpers DEPENDS |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 125 | vk_dispatch_table_helper.h |
| 126 | vk_enum_string_helper.h |
| 127 | vk_struct_string_helper.h |
| 128 | vk_struct_string_helper_no_addr.h |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 129 | vk_struct_string_helper_cpp.h |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 130 | vk_struct_string_helper_no_addr_cpp.h |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 131 | vk_struct_size_helper.h |
| 132 | vk_struct_size_helper.c |
Karl Schultz | 4ea0550 | 2016-04-07 15:11:59 -0600 | [diff] [blame] | 133 | vk_struct_wrappers.h |
| 134 | vk_struct_wrappers.cpp |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 135 | vk_safe_struct.h |
| 136 | vk_safe_struct.cpp |
Chia-I Wu | db2b387 | 2014-12-19 10:59:01 +0800 | [diff] [blame] | 137 | ) |
| 138 | |
Mike Stroyan | 845bdc4 | 2015-11-02 15:30:20 -0700 | [diff] [blame] | 139 | run_vk_layer_xml_generate(Threading thread_check.h) |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 140 | run_vk_layer_generate(unique_objects unique_objects.cpp) |
Mark Lobodzinski | 739391a | 2016-03-17 15:08:18 -0600 | [diff] [blame] | 141 | run_vk_layer_xml_generate(ParamChecker parameter_validation.h) |
Chia-I Wu | db2b387 | 2014-12-19 10:59:01 +0800 | [diff] [blame] | 142 | |
Karl Schultz | c61bc7a | 2016-04-08 09:17:18 -0600 | [diff] [blame] | 143 | # Layer Utils Library |
Mark Lobodzinski | 8005bb4 | 2016-06-21 15:53:37 -0600 | [diff] [blame] | 144 | # For Windows, we use a static lib because the Windows loader has a fairly restrictive loader search |
| 145 | # 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] | 146 | if (WIN32) |
Mark Lobodzinski | 8005bb4 | 2016-06-21 15:53:37 -0600 | [diff] [blame] | 147 | 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] | 148 | else() |
Karl Schultz | c61bc7a | 2016-04-08 09:17:18 -0600 | [diff] [blame] | 149 | add_library(VkLayer_utils SHARED vk_layer_config.cpp vk_layer_extension_utils.cpp vk_layer_utils.cpp) |
| 150 | install(TARGETS VkLayer_utils DESTINATION ${PROJECT_BINARY_DIR}/install_staging) |
Ian Elliott | a6bbf3e | 2015-02-12 11:36:44 -0700 | [diff] [blame] | 151 | endif() |
Karl Schultz | c61bc7a | 2016-04-08 09:17:18 -0600 | [diff] [blame] | 152 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 153 | add_vk_layer(core_validation core_validation.cpp vk_layer_table.cpp vk_safe_struct.cpp descriptor_sets.cpp) |
Mark Lobodzinski | 9bab866 | 2016-07-01 10:53:31 -0600 | [diff] [blame] | 154 | add_vk_layer(object_tracker object_tracker.cpp vk_layer_table.cpp) |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 155 | add_vk_layer(image image.cpp vk_layer_table.cpp) |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 156 | add_vk_layer(swapchain swapchain.cpp vk_layer_table.cpp) |
Chia-I Wu | db2b387 | 2014-12-19 10:59:01 +0800 | [diff] [blame] | 157 | # generated |
Mike Stroyan | 845bdc4 | 2015-11-02 15:30:20 -0700 | [diff] [blame] | 158 | add_vk_layer(threading threading.cpp thread_check.h vk_layer_table.cpp) |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 159 | add_vk_layer(unique_objects unique_objects.cpp vk_layer_table.cpp vk_safe_struct.cpp) |
Mark Lobodzinski | 739391a | 2016-03-17 15:08:18 -0600 | [diff] [blame] | 160 | 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] | 161 | |
| 162 | # Core validation has additional dependencies |
| 163 | target_include_directories(VkLayer_core_validation PRIVATE ${GLSLANG_SPIRV_INCLUDE_DIR}) |
| 164 | target_include_directories(VkLayer_core_validation PRIVATE ${SPIRV_TOOLS_INCLUDE_DIR}) |
Karl Schultz | cca25a6 | 2016-04-28 12:09:34 -0600 | [diff] [blame] | 165 | target_link_libraries(VkLayer_core_validation ${SPIRV_TOOLS_LIBRARIES}) |