1# Copyright 2020 The SwiftShader Authors. All Rights Reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15set(ROOT_PROJECT_COMPILE_OPTIONS 16 ${SWIFTSHADER_COMPILE_OPTIONS} 17 ${WARNINGS_AS_ERRORS} 18) 19 20set(WSI_SRC_FILES 21 HeadlessSurfaceKHR.cpp 22 HeadlessSurfaceKHR.hpp 23 VkSurfaceKHR.cpp 24 VkSurfaceKHR.hpp 25 VkSwapchainKHR.cpp 26 VkSwapchainKHR.hpp 27) 28 29if(WIN32) 30 list(APPEND WSI_SRC_FILES 31 Win32SurfaceKHR.cpp 32 Win32SurfaceKHR.hpp 33 ) 34elseif(LINUX) 35 if(HAVE_XCB_H) 36 list(APPEND WSI_SRC_FILES 37 XcbSurfaceKHR.cpp 38 XcbSurfaceKHR.hpp 39 libXCB.cpp 40 libXCB.hpp 41 ) 42 endif() 43 44 if(WAYLAND) 45 list(APPEND WSI_SRC_FILES 46 WaylandSurfaceKHR.cpp 47 WaylandSurfaceKHR.hpp 48 ) 49 endif() 50 51 if(DIRECTFB) 52 list(APPEND WSI_SRC_FILES 53 DirectFBSurfaceEXT.cpp 54 DirectFBSurfaceEXT.hpp 55 ) 56 endif() 57 58 if(D2D) 59 list(APPEND WSI_SRC_FILES 60 DisplaySurfaceKHR.cpp 61 DisplaySurfaceKHR.hpp 62 ) 63 endif() 64elseif(APPLE) 65 list(APPEND WSI_SRC_FILES 66 MetalSurface.mm 67 MetalSurface.hpp 68 ) 69endif() 70 71set(WSI_COMPILE_OPTIONS "") 72if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 73 list(APPEND WSI_COMPILE_OPTIONS 74 "-Wexit-time-destructors" # declaration requires an exit-time destructor 75 ) 76endif() 77 78add_library(vk_wsi EXCLUDE_FROM_ALL 79 ${WSI_SRC_FILES} 80) 81 82set_target_properties(vk_wsi PROPERTIES 83 POSITION_INDEPENDENT_CODE 1 84 FOLDER "SwiftShader VK" 85) 86 87target_include_directories(vk_wsi 88 PUBLIC 89 ".." 90 "${SWIFTSHADER_DIR}/include" 91) 92 93target_compile_options(vk_wsi 94 PRIVATE 95 ${ROOT_PROJECT_COMPILE_OPTIONS} 96 ${WSI_COMPILE_OPTIONS} 97) 98 99target_link_options(vk_wsi 100 PUBLIC 101 ${SWIFTSHADER_LINK_FLAGS} 102) 103 104target_link_libraries(vk_wsi 105 PUBLIC 106 vk_pipeline 107) 108