1cmake_minimum_required (VERSION 2.8.11) 2 3set(LAYER_JSON_FILES 4 VkLayer_wrap_objects 5 VkLayer_device_profile_api 6 VkLayer_test 7 ) 8 9set(VK_LAYER_RPATH /usr/lib/x86_64-linux-gnu/vulkan/layer:/usr/lib/i386-linux-gnu/vulkan/layer) 10set(CMAKE_INSTALL_RPATH ${VK_LAYER_RPATH}) 11 12if (WIN32) 13 if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) 14 foreach (config_file ${LAYER_JSON_FILES}) 15 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/windows/${config_file}.json src_json) 16 if (CMAKE_GENERATOR MATCHES "^Visual Studio.*") 17 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/${config_file}.json dst_json) 18 else() 19 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/${config_file}.json dst_json) 20 endif() 21 add_custom_target(${config_file}-json ALL 22 COMMAND copy ${src_json} ${dst_json} 23 VERBATIM 24 ) 25 add_dependencies(${config_file}-json ${config_file}) 26 set_target_properties(${config_file}-json PROPERTIES FOLDER ${LVL_TARGET_FOLDER}) 27 endforeach(config_file) 28 endif() 29else() 30 # extra setup for out-of-tree builds 31 if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) 32 foreach (config_file ${LAYER_JSON_FILES}) 33 add_custom_target(${config_file}-json ALL 34 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json 35 VERBATIM 36 ) 37 endforeach(config_file) 38 endif() 39endif() 40 41if (WIN32) 42 macro(add_vk_layer target) 43 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/VkLayer_${target}.def DEF_FILE) 44 add_custom_target(copy-${target}-def-file ALL 45 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEF_FILE} VkLayer_${target}.def 46 VERBATIM 47 ) 48 set_target_properties(copy-${target}-def-file PROPERTIES FOLDER ${LVL_TARGET_FOLDER}) 49 add_library(VkLayer_${target} SHARED ${ARGN} VkLayer_${target}.def) 50 add_dependencies(VkLayer_${target} generate_helper_files VkLayer_utils) 51 endmacro() 52else() 53 macro(add_vk_layer target) 54 add_library(VkLayer_${target} SHARED ${ARGN}) 55 add_dependencies(VkLayer_${target} generate_helper_files VkLayer_utils) 56 set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic") 57 endmacro() 58endif() 59 60include_directories( 61 ${CMAKE_CURRENT_SOURCE_DIR} 62 ${CMAKE_CURRENT_SOURCE_DIR}/../../layers 63 ${CMAKE_CURRENT_SOURCE_DIR}/../../loader 64 ${CMAKE_CURRENT_SOURCE_DIR}/../../include/vulkan 65 ${CMAKE_CURRENT_BINARY_DIR} 66 ${PROJECT_BINARY_DIR} 67 ${CMAKE_BINARY_DIR} 68) 69 70if (WIN32) 71 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_CRT_SECURE_NO_WARNINGS") 72 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D_CRT_SECURE_NO_WARNINGS") 73 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS /bigobj") 74 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS /bigobj") 75else() 76 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpointer-arith -Wno-unused-function") 77 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith -Wno-unused-function") 78endif() 79 80set (WRAP_SRCS 81 wrap_objects.cpp 82 ${CMAKE_CURRENT_SOURCE_DIR}/../../layers/vk_layer_table.cpp 83 ${CMAKE_CURRENT_SOURCE_DIR}/../../layers/vk_layer_extension_utils.cpp 84 ) 85add_vk_layer(wrap_objects ${WRAP_SRCS}) 86 87set (TEST_SRCS 88 test.cpp 89 ${CMAKE_CURRENT_SOURCE_DIR}/../../layers/vk_layer_table.cpp 90 ${CMAKE_CURRENT_SOURCE_DIR}/../../layers/vk_layer_extension_utils.cpp 91 ) 92 93set (DEVICE_PROFILE_API_SRCS 94 device_profile_api.cpp 95 ${CMAKE_CURRENT_SOURCE_DIR}/../../layers/vk_layer_table.cpp 96 ${CMAKE_CURRENT_SOURCE_DIR}/../../layers/vk_layer_extension_utils.cpp 97 ) 98 99add_vk_layer(device_profile_api ${DEVICE_PROFILE_API_SRCS}) 100add_vk_layer(test ${TEST_SRCS}) 101 102if (WIN32) 103 # For Windows, copy necessary gtest DLLs to the right spot for the vk_layer_tests... 104 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/*device_profile_api.* SRC_LAYER) 105 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/windows/VkLayer_device_profile_api.json SRC_JSON) 106 FILE(TO_NATIVE_PATH ${CMAKE_BINARY_DIR}/layers/$<CONFIGURATION> DST_LAYER) 107 add_custom_command(TARGET VkLayer_device_profile_api POST_BUILD 108 COMMAND xcopy /Y /I ${SRC_LAYER} ${DST_LAYER} 109 COMMAND xcopy /Y /I ${SRC_JSON} ${DST_LAYER}) 110else() 111 add_custom_command(TARGET VkLayer_device_profile_api POST_BUILD 112 COMMAND ln -sf ${CMAKE_CURRENT_BINARY_DIR}/VkLayer_device_profile_api.json ${CMAKE_BINARY_DIR}/layers 113 COMMAND ln -sf ${CMAKE_CURRENT_BINARY_DIR}/libVkLayer_device_profile_api.so ${CMAKE_BINARY_DIR}/layers 114 VERBATIM 115 ) 116endif() 117