blob: 9d6705b8c40605e27c2ba7ccf66410e15162fd90 [file] [log] [blame]
Jon Ashburnd38bfb12014-10-14 19:15:22 -06001cmake_minimum_required (VERSION 2.8.11)
2
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06003macro(run_vk_helper subcmd)
Karl Schultz4ea05502016-04-07 15:11:59 -06004 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 Wudb2b3872014-12-19 10:59:01 +08008endmacro()
9
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060010macro(run_vk_layer_generate subcmd output)
Karl Schultz4ea05502016-04-07 15:11:59 -060011 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 Wudb2b3872014-12-19 10:59:01 +080015endmacro()
16
Mike Stroyan845bdc42015-11-02 15:30:20 -070017macro(run_vk_layer_xml_generate subcmd output)
Karl Schultz4ea05502016-04-07 15:11:59 -060018 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 Stroyan845bdc42015-11-02 15:30:20 -070022endmacro()
Courtney Goeltzenleuchterb38936a2015-07-07 14:27:31 -060023set(LAYER_JSON_FILES
Tobin Ehlisc96f8062016-03-09 16:12:48 -070024 VkLayer_core_validation
Tobin Ehlisc96f8062016-03-09 16:12:48 -070025 VkLayer_image
Mark Lobodzinski0d054fe2015-12-30 08:16:12 -070026 VkLayer_object_tracker
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070027 VkLayer_unique_objects
Mark Lobodzinski739391a2016-03-17 15:08:18 -060028 VkLayer_parameter_validation
Mark Lobodzinski0d054fe2015-12-30 08:16:12 -070029 VkLayer_swapchain
30 VkLayer_threading
Courtney Goeltzenleuchterb38936a2015-07-07 14:27:31 -060031 )
32
Karl Schultzc61bc7a2016-04-08 09:17:18 -060033if (WIN32)
Courtney Goeltzenleuchterb38936a2015-07-07 14:27:31 -060034 if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
Mark Muellerb33052d2016-04-18 11:04:36 -060035 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 Goeltzenleuchterb38936a2015-07-07 14:27:31 -060054 endif()
Karl Schultzc61bc7a2016-04-08 09:17:18 -060055else()
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 Goeltzenleuchterb38936a2015-07-07 14:27:31 -060065endif()
66
Ian Elliott2d4ab1e2015-01-13 17:52:38 -070067if (WIN32)
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060068 macro(add_vk_layer target)
Karl Schultz4ea05502016-04-07 15:11:59 -060069 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 Schultzc61bc7a2016-04-08 09:17:18 -060074 target_link_Libraries(VkLayer_${target} VkLayer_utils)
Karl Schultz4ea05502016-04-07 15:11:59 -060075 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 Elliott2d4ab1e2015-01-13 17:52:38 -070077 endmacro()
78else()
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060079 macro(add_vk_layer target)
Karl Schultz4ea05502016-04-07 15:11:59 -060080 add_library(VkLayer_${target} SHARED ${ARGN})
Karl Schultzc61bc7a2016-04-08 09:17:18 -060081 target_link_Libraries(VkLayer_${target} VkLayer_utils)
Karl Schultz4ea05502016-04-07 15:11:59 -060082 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 Elliott2d4ab1e2015-01-13 17:52:38 -070085 endmacro()
86endif()
Jon Ashburnd38bfb12014-10-14 19:15:22 -060087
Chia-I Wu21bddab2014-11-19 23:05:04 +080088include_directories(
Karl Schultz4ea05502016-04-07 15:11:59 -060089 ${CMAKE_CURRENT_SOURCE_DIR}
90 ${CMAKE_CURRENT_SOURCE_DIR}/../loader
91 ${CMAKE_CURRENT_SOURCE_DIR}/../include/vulkan
92 ${CMAKE_CURRENT_BINARY_DIR}
Chia-I Wu21bddab2014-11-19 23:05:04 +080093)
94
Ian Elliott19628802015-02-04 12:06:46 -070095if (WIN32)
Mark Youngb445e402016-01-18 17:22:48 -070096 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 Lobodzinski9ee66212016-03-15 10:31:44 -060098 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 Schultzc61bc7a2016-04-08 09:17:18 -0600100else()
Ian Elliott19628802015-02-04 12:06:46 -0700101 set (CMAKE_CXX_FLAGS "-std=c++11")
Jon Ashburnce816b62016-01-12 11:33:33 -0700102 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpointer-arith")
103 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith")
Ian Elliott19628802015-02-04 12:06:46 -0700104endif()
Jon Ashburnd38bfb12014-10-14 19:15:22 -0600105
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600106add_custom_command(OUTPUT vk_dispatch_table_helper.h
Mark Young7b2214e2016-08-01 11:06:53 -0600107 COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/vk-generate.py AllPlatforms dispatch-table-ops layer > vk_dispatch_table_helper.h
Karl Schultz4ea05502016-04-07 15:11:59 -0600108 DEPENDS ${PROJECT_SOURCE_DIR}/vk-generate.py ${PROJECT_SOURCE_DIR}/vulkan.py)
Chia-I Wuaa4121f2015-01-04 23:11:43 +0800109
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600110run_vk_helper(gen_enum_string_helper vk_enum_string_helper.h)
111run_vk_helper(gen_struct_wrappers
Karl Schultz4ea05502016-04-07 15:11:59 -0600112 vk_struct_string_helper.h
Mark Lobodzinski0d054fe2015-12-30 08:16:12 -0700113 vk_struct_string_helper_cpp.h
Karl Schultz4ea05502016-04-07 15:11:59 -0600114 vk_struct_string_helper_no_addr.h
115 vk_struct_string_helper_no_addr_cpp.h
Mark Lobodzinski0d054fe2015-12-30 08:16:12 -0700116 vk_struct_size_helper.h
117 vk_struct_size_helper.c
Karl Schultz4ea05502016-04-07 15:11:59 -0600118 vk_struct_wrappers.h
119 vk_struct_wrappers.cpp
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700120 vk_safe_struct.h
121 vk_safe_struct.cpp
Chia-I Wudb2b3872014-12-19 10:59:01 +0800122)
Chia-I Wudb2b3872014-12-19 10:59:01 +0800123
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600124add_custom_target(generate_vk_layer_helpers DEPENDS
Karl Schultz4ea05502016-04-07 15:11:59 -0600125 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 Lobodzinski0d054fe2015-12-30 08:16:12 -0700129 vk_struct_string_helper_cpp.h
Karl Schultz4ea05502016-04-07 15:11:59 -0600130 vk_struct_string_helper_no_addr_cpp.h
Mark Lobodzinski0d054fe2015-12-30 08:16:12 -0700131 vk_struct_size_helper.h
132 vk_struct_size_helper.c
Karl Schultz4ea05502016-04-07 15:11:59 -0600133 vk_struct_wrappers.h
134 vk_struct_wrappers.cpp
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700135 vk_safe_struct.h
136 vk_safe_struct.cpp
Chia-I Wudb2b3872014-12-19 10:59:01 +0800137)
138
Mike Stroyan845bdc42015-11-02 15:30:20 -0700139run_vk_layer_xml_generate(Threading thread_check.h)
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700140run_vk_layer_generate(unique_objects unique_objects.cpp)
Mark Lobodzinski739391a2016-03-17 15:08:18 -0600141run_vk_layer_xml_generate(ParamChecker parameter_validation.h)
Chia-I Wudb2b3872014-12-19 10:59:01 +0800142
Karl Schultzc61bc7a2016-04-08 09:17:18 -0600143# Layer Utils Library
Mark Lobodzinski8005bb42016-06-21 15:53:37 -0600144# 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 Elliotta6bbf3e2015-02-12 11:36:44 -0700146if (WIN32)
Mark Lobodzinski8005bb42016-06-21 15:53:37 -0600147 add_library(VkLayer_utils STATIC vk_layer_config.cpp vk_layer_extension_utils.cpp vk_layer_utils.cpp)
Mike Stroyan897d4752015-07-10 12:51:14 -0600148else()
Karl Schultzc61bc7a2016-04-08 09:17:18 -0600149 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 Elliotta6bbf3e2015-02-12 11:36:44 -0700151endif()
Karl Schultzc61bc7a2016-04-08 09:17:18 -0600152
Tobin Ehlis0a43bde2016-05-03 08:31:08 -0600153add_vk_layer(core_validation core_validation.cpp vk_layer_table.cpp vk_safe_struct.cpp descriptor_sets.cpp)
Mark Lobodzinski9bab8662016-07-01 10:53:31 -0600154add_vk_layer(object_tracker object_tracker.cpp vk_layer_table.cpp)
Mark Lobodzinski0d054fe2015-12-30 08:16:12 -0700155add_vk_layer(image image.cpp vk_layer_table.cpp)
Mark Lobodzinski0d054fe2015-12-30 08:16:12 -0700156add_vk_layer(swapchain swapchain.cpp vk_layer_table.cpp)
Chia-I Wudb2b3872014-12-19 10:59:01 +0800157# generated
Mike Stroyan845bdc42015-11-02 15:30:20 -0700158add_vk_layer(threading threading.cpp thread_check.h vk_layer_table.cpp)
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700159add_vk_layer(unique_objects unique_objects.cpp vk_layer_table.cpp vk_safe_struct.cpp)
Mark Lobodzinski739391a2016-03-17 15:08:18 -0600160add_vk_layer(parameter_validation parameter_validation.cpp parameter_validation.h vk_layer_table.cpp)
Chris Forbesa13ab8a2016-04-04 09:52:11 +1200161
162# Core validation has additional dependencies
163target_include_directories(VkLayer_core_validation PRIVATE ${GLSLANG_SPIRV_INCLUDE_DIR})
164target_include_directories(VkLayer_core_validation PRIVATE ${SPIRV_TOOLS_INCLUDE_DIR})
Karl Schultzcca25a62016-04-28 12:09:34 -0600165target_link_libraries(VkLayer_core_validation ${SPIRV_TOOLS_LIBRARIES})