blob: 77177b017f2fb0492c01a46e9878f9506400f0cb [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)
Chia-I Wudb2b3872014-12-19 10:59:01 +08004 add_custom_command(OUTPUT ${ARGN}
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06005 COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/vk_helper.py --${subcmd} ${PROJECT_SOURCE_DIR}/include/vulkan.h --abs_out_dir ${CMAKE_CURRENT_BINARY_DIR}
6 DEPENDS ${PROJECT_SOURCE_DIR}/vk_helper.py ${PROJECT_SOURCE_DIR}/include/vulkan.h
Chia-I Wudb2b3872014-12-19 10:59:01 +08007 )
8endmacro()
9
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060010macro(run_vk_layer_generate subcmd output)
Chia-I Wudb2b3872014-12-19 10:59:01 +080011 add_custom_command(OUTPUT ${output}
Courtney Goeltzenleuchterf53c3cb2015-04-14 14:55:44 -060012 COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/vk-layer-generate.py ${subcmd} ${PROJECT_SOURCE_DIR}/include/vulkan.h > ${output}
13 DEPENDS ${PROJECT_SOURCE_DIR}/vk-layer-generate.py ${PROJECT_SOURCE_DIR}/include/vulkan.h ${PROJECT_SOURCE_DIR}/vulkan.py
Chia-I Wudb2b3872014-12-19 10:59:01 +080014 )
15endmacro()
16
Courtney Goeltzenleuchterb38936a2015-07-07 14:27:31 -060017set(LAYER_JSON_FILES
Jon Ashburn4efec942015-07-07 15:21:07 -060018 api_dump
19 basic
20 draw_state
21 generic
22 image
23 mem_tracker
24 multi
25 object_tracker
26 param_checker
27 screenshot
28 shader_checker
Ian Elliott0b4d6242015-09-22 10:51:24 -060029 swapchain
Jon Ashburn4efec942015-07-07 15:21:07 -060030 threading
Tobin Ehlisb5fc4fb2015-09-03 09:50:06 -060031 device_limits
Courtney Goeltzenleuchterb38936a2015-07-07 14:27:31 -060032 )
33
Mike Stroyan897d4752015-07-10 12:51:14 -060034set(VK_LAYER_RPATH /usr/lib/x86_64-linux-gnu/vulkan/layer:/usr/lib/i386-linux-gnu/vulkan/layer)
35set(CMAKE_INSTALL_RPATH ${VK_LAYER_RPATH})
36
Courtney Goeltzenleuchterb38936a2015-07-07 14:27:31 -060037if (NOT WIN32)
38 # extra setup for out-of-tree builds
39 if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
40 foreach (config_file ${LAYER_JSON_FILES})
41 add_custom_target(${config_file}-json ALL
Courtney Goeltzenleuchter0eae6fd2015-07-30 10:49:03 -060042 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json
Courtney Goeltzenleuchterb38936a2015-07-07 14:27:31 -060043 VERBATIM
44 )
45 endforeach(config_file)
46 endif()
47else()
48 if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
49 foreach (config_file ${LAYER_JSON_FILES})
Courtney Goeltzenleuchter0eae6fd2015-07-30 10:49:03 -060050 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/windows/${config_file}.json src_json)
David Pinedo5d78eb82015-09-15 10:58:27 -060051 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/${config_file}.json dst_json)
Cody Northrop5c7533b2015-07-08 16:22:51 -060052 add_custom_target(${config_file}-json ALL
Cody Northrop06a455b2015-07-09 10:47:40 -060053 COMMAND copy ${src_json} ${dst_json}
Courtney Goeltzenleuchterb38936a2015-07-07 14:27:31 -060054 VERBATIM
55 )
56 endforeach(config_file)
57 endif()
58endif()
59
Ian Elliott2d4ab1e2015-01-13 17:52:38 -070060if (WIN32)
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060061 macro(add_vk_layer target)
62 add_custom_command(OUTPUT VKLayer${target}.def
Ian Elliott2ff21672015-04-15 11:16:04 -060063 COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/vk-generate.py win-def-file VKLayer${target} layer > VKLayer${target}.def
64 DEPENDS ${PROJECT_SOURCE_DIR}/vk-generate.py ${PROJECT_SOURCE_DIR}/vk.py
Ian Elliott2d4ab1e2015-01-13 17:52:38 -070065 )
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060066 add_library(VKLayer${target} SHARED ${ARGN} VKLayer${target}.def)
67 target_link_Libraries(VKLayer${target} layer_utils)
Cody Northropd0892c82015-05-28 10:09:50 -060068 add_dependencies(VKLayer${target} layer_utils_static)
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060069 add_dependencies(VKLayer${target} generate_vk_layer_helpers)
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060070 set_target_properties(VKLayer${target} PROPERTIES LINK_FLAGS "/DEF:${CMAKE_CURRENT_BINARY_DIR}/VKLayer${target}.def")
Ian Elliott2d4ab1e2015-01-13 17:52:38 -070071 endmacro()
72else()
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060073 macro(add_vk_layer target)
74 add_library(VKLayer${target} SHARED ${ARGN})
75 target_link_Libraries(VKLayer${target} layer_utils)
76 add_dependencies(VKLayer${target} generate_vk_layer_helpers)
77 set_target_properties(VKLayer${target} PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic")
Mike Stroyan897d4752015-07-10 12:51:14 -060078 install(TARGETS VKLayer${target} DESTINATION ${PROJECT_BINARY_DIR}/install_staging)
Ian Elliott2d4ab1e2015-01-13 17:52:38 -070079 endmacro()
80endif()
Jon Ashburnd38bfb12014-10-14 19:15:22 -060081
Chia-I Wu21bddab2014-11-19 23:05:04 +080082include_directories(
83 ${CMAKE_CURRENT_SOURCE_DIR}
Ian Elliott2d4ab1e2015-01-13 17:52:38 -070084 ${CMAKE_CURRENT_SOURCE_DIR}/../loader
Chia-I Wu21bddab2014-11-19 23:05:04 +080085 ${CMAKE_CURRENT_BINARY_DIR}
86)
87
Ian Elliott19628802015-02-04 12:06:46 -070088if (WIN32)
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060089 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_PROTOTYPES -D_CRT_SECURE_NO_WARNINGS")
90 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVK_PROTOTYPES -D_CRT_SECURE_NO_WARNINGS")
Ian Elliott19628802015-02-04 12:06:46 -070091endif()
92if (NOT WIN32)
93 set (CMAKE_CXX_FLAGS "-std=c++11")
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060094 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_PROTOTYPES -Wpointer-arith")
95 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVK_PROTOTYPES -Wpointer-arith")
Ian Elliott19628802015-02-04 12:06:46 -070096endif()
Jon Ashburnd38bfb12014-10-14 19:15:22 -060097
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060098add_custom_command(OUTPUT vk_dispatch_table_helper.h
Courtney Goeltzenleuchterf53c3cb2015-04-14 14:55:44 -060099 COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/vk-generate.py dispatch-table-ops layer > vk_dispatch_table_helper.h
100 DEPENDS ${PROJECT_SOURCE_DIR}/vk-generate.py ${PROJECT_SOURCE_DIR}/vulkan.py)
Chia-I Wuaa4121f2015-01-04 23:11:43 +0800101
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600102run_vk_helper(gen_enum_string_helper vk_enum_string_helper.h)
103run_vk_helper(gen_struct_wrappers
104 vk_struct_string_helper.h
105 vk_struct_string_helper_cpp.h
106 vk_struct_string_helper_no_addr.h
107 vk_struct_string_helper_no_addr_cpp.h
108 vk_struct_size_helper.h
109 vk_struct_size_helper.c
110 vk_struct_wrappers.h
111 vk_struct_wrappers.cpp
Chia-I Wudb2b3872014-12-19 10:59:01 +0800112)
Chia-I Wudb2b3872014-12-19 10:59:01 +0800113
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600114add_custom_target(generate_vk_layer_helpers DEPENDS
115 vk_dispatch_table_helper.h
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600116 vk_enum_string_helper.h
117 vk_struct_string_helper.h
118 vk_struct_string_helper_no_addr.h
119 vk_struct_string_helper_cpp.h
120 vk_struct_string_helper_no_addr_cpp.h
121 vk_struct_size_helper.h
122 vk_struct_size_helper.c
123 vk_struct_wrappers.h
124 vk_struct_wrappers.cpp
Chia-I Wudb2b3872014-12-19 10:59:01 +0800125)
126
Tony Barboura05dbaa2015-07-09 17:31:46 -0600127run_vk_layer_generate(Generic generic_layer.cpp)
Mark Lobodzinski4c7ac0a2015-05-26 09:29:09 -0500128run_vk_layer_generate(APIDump api_dump.cpp)
Tony Barboura05dbaa2015-07-09 17:31:46 -0600129run_vk_layer_generate(ObjectTracker object_track.cpp)
Mike Stroyanbe2b5d82015-07-09 11:01:07 -0600130run_vk_layer_generate(Threading threading.cpp)
Chia-I Wudb2b3872014-12-19 10:59:01 +0800131
Mark Lobodzinski6f2274e2015-09-22 09:33:21 -0600132add_library(layer_utils SHARED vk_layer_config.cpp vk_layer_extension_utils.cpp vk_layer_utils.cpp)
Ian Elliotta6bbf3e2015-02-12 11:36:44 -0700133if (WIN32)
Mark Lobodzinski6f2274e2015-09-22 09:33:21 -0600134 add_library(layer_utils_static STATIC vk_layer_config.cpp vk_layer_extension_utils.cpp vk_layer_utils.cpp)
Ian Elliotta6bbf3e2015-02-12 11:36:44 -0700135 set_target_properties(layer_utils_static PROPERTIES OUTPUT_NAME layer_utils)
136 target_link_libraries(layer_utils)
Mike Stroyan897d4752015-07-10 12:51:14 -0600137else()
138 install(TARGETS layer_utils DESTINATION ${PROJECT_BINARY_DIR}/install_staging)
Ian Elliotta6bbf3e2015-02-12 11:36:44 -0700139endif()
Jon Ashburnba606282015-01-13 15:22:19 -0700140
Courtney Goeltzenleuchter4ad43f72015-07-09 19:04:04 -0600141add_vk_layer(Basic basic.cpp vk_layer_table.cpp)
Jon Ashburn1e41a442015-08-12 16:43:01 -0600142add_vk_layer(Multi multi.cpp vk_layer_table.cpp)
Tobin Ehlis60a9b4f2015-07-07 10:42:20 -0600143add_vk_layer(DrawState draw_state.cpp vk_layer_debug_marker_table.cpp vk_layer_table.cpp)
Mark Lobodzinski6f2274e2015-09-22 09:33:21 -0600144add_vk_layer(DeviceLimits device_limits.cpp vk_layer_debug_marker_table.cpp vk_layer_table.cpp vk_layer_utils.cpp)
Tobin Ehlis257d9742015-07-08 17:08:02 -0600145add_vk_layer(MemTracker mem_tracker.cpp vk_layer_table.cpp)
Chris Forbes9715d4a2015-07-10 09:06:54 +1200146add_vk_layer(ShaderChecker shader_checker.cpp vk_layer_table.cpp)
Tony Barboura05dbaa2015-07-09 17:31:46 -0600147add_vk_layer(Image image.cpp vk_layer_table.cpp)
Courtney Goeltzenleuchteree5d80b2015-07-10 19:50:17 -0600148add_vk_layer(ParamChecker param_checker.cpp vk_layer_debug_marker_table.cpp vk_layer_table.cpp)
David Pinedo8897e192015-07-31 10:56:20 -0600149add_vk_layer(ScreenShot screenshot.cpp vk_layer_table.cpp)
Ian Elliott0b4d6242015-09-22 10:51:24 -0600150add_vk_layer(Swapchain swapchain.cpp vk_layer_table.cpp)
Chia-I Wudb2b3872014-12-19 10:59:01 +0800151# generated
Tony Barboura05dbaa2015-07-09 17:31:46 -0600152add_vk_layer(Generic generic_layer.cpp vk_layer_table.cpp)
Tobin Ehlisa0cb02e2015-07-03 10:15:26 -0600153add_vk_layer(APIDump api_dump.cpp vk_layer_table.cpp)
Tony Barboura05dbaa2015-07-09 17:31:46 -0600154add_vk_layer(ObjectTracker object_track.cpp vk_layer_table.cpp)
Mike Stroyanbe2b5d82015-07-09 11:01:07 -0600155add_vk_layer(Threading threading.cpp vk_layer_table.cpp)