1cmake_minimum_required (VERSION 2.8.11) 2 3set(LAYER_JSON_FILES 4 VkLayer_wrap_objects 5 VkLayer_test 6 ) 7 8set(VK_LAYER_RPATH /usr/lib/x86_64-linux-gnu/vulkan/layer:/usr/lib/i386-linux-gnu/vulkan/layer) 9set(CMAKE_INSTALL_RPATH ${VK_LAYER_RPATH}) 10 11if (WIN32) 12 if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) 13 foreach (config_file ${LAYER_JSON_FILES}) 14 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/windows/${config_file}.json src_json) 15 if (CMAKE_GENERATOR MATCHES "^Visual Studio.*") 16 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/${config_file}.json dst_json) 17 else() 18 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/${config_file}.json dst_json) 19 endif() 20 add_custom_target(${config_file}-json ALL 21 COMMAND copy ${src_json} ${dst_json} 22 VERBATIM 23 ) 24 add_dependencies(${config_file}-json ${config_file}) 25 endforeach(config_file) 26 endif() 27else() 28 # extra setup for out-of-tree builds 29 if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) 30 foreach (config_file ${LAYER_JSON_FILES}) 31 add_custom_target(${config_file}-json ALL 32 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json 33 VERBATIM 34 ) 35 endforeach(config_file) 36 endif() 37endif() 38 39if (WIN32) 40 macro(add_vk_layer target) 41 add_custom_command(OUTPUT VkLayer_${target}.def 42 COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/vk-generate.py ${DisplayServer} win-def-file VkLayer_${target} layer > VkLayer_${target}.def 43 DEPENDS ${PROJECT_SOURCE_DIR}/vk-generate.py ${PROJECT_SOURCE_DIR}/vulkan.py 44 ) 45 add_library(VkLayer_${target} SHARED ${ARGN} VkLayer_${target}.def) 46 add_dependencies(VkLayer_${target} generate_tests_dispatch_table_helper VkLayer_utils) 47 endmacro() 48else() 49 macro(add_vk_layer target) 50 add_library(VkLayer_${target} SHARED ${ARGN}) 51 add_dependencies(VkLayer_${target} generate_tests_dispatch_table_helper VkLayer_utils) 52 set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic") 53 endmacro() 54endif() 55 56include_directories( 57 ${CMAKE_CURRENT_SOURCE_DIR} 58 ${CMAKE_CURRENT_SOURCE_DIR}/../../layers 59 ${CMAKE_CURRENT_SOURCE_DIR}/../../loader 60 ${CMAKE_CURRENT_SOURCE_DIR}/../../include/vulkan 61 ${CMAKE_CURRENT_BINARY_DIR} 62 ${CMAKE_CURRENT_BINARY_DIR}/../../layers 63) 64 65if (WIN32) 66 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_CRT_SECURE_NO_WARNINGS") 67 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D_CRT_SECURE_NO_WARNINGS") 68 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS /bigobj") 69 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS /bigobj") 70else() 71 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpointer-arith -Wno-unused-function") 72 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith -Wno-unused-function") 73endif() 74 75add_custom_command(OUTPUT vk_dispatch_table_helper.h 76 COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/vk-generate.py ${DisplayServer} dispatch-table-ops layer > vk_dispatch_table_helper.h 77 DEPENDS ${PROJECT_SOURCE_DIR}/vk-generate.py ${PROJECT_SOURCE_DIR}/vulkan.py) 78 79add_custom_target(generate_tests_dispatch_table_helper DEPENDS 80 vk_dispatch_table_helper.h 81) 82 83set (WRAP_SRCS 84 wrap_objects.cpp 85 ${CMAKE_CURRENT_SOURCE_DIR}/../../layers/vk_layer_table.cpp 86 ${CMAKE_CURRENT_SOURCE_DIR}/../../layers/vk_layer_extension_utils.cpp 87 ) 88add_vk_layer(wrap_objects ${WRAP_SRCS}) 89 90set (TEST_SRCS 91 test.cpp 92 ${CMAKE_CURRENT_SOURCE_DIR}/../../layers/vk_layer_table.cpp 93 ${CMAKE_CURRENT_SOURCE_DIR}/../../layers/vk_layer_extension_utils.cpp 94 ) 95add_vk_layer(test ${TEST_SRCS}) 96 97 98