From 4b2019bf934227e526f72df5b045b3bbfb646b63 Mon Sep 17 00:00:00 2001 From: BtbN Date: Mon, 7 Sep 2020 20:07:39 +0200 Subject: [PATCH 2/4] Fixes for MinGW build Adapted from https://github.com/msys2/MINGW-packages/blob/348f1d46d9d273a2cc928deadf9d9114f7a69c2f/mingw-w64-vulkan-loader/002-proper-def-files-for-32bit.patch --- loader/CMakeLists.txt | 6 ++++-- loader/loader.h | 4 +++- tests/layers/vk_format_utils.h | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index 219b99bd5..ab0a49c55 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -71,6 +71,7 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") if(WIN32) # Use static MSVCRT libraries + if(MSVC) foreach(configuration in CMAKE_C_FLAGS_DEBUG @@ -89,6 +90,7 @@ if(WIN32) "${${configuration}}") endif() endforeach() + endif() if(ENABLE_WIN10_ONECORE) # Note: When linking your app or driver to OneCore.lib, be sure to remove any links to non-umbrella libs (such as @@ -238,7 +240,7 @@ if(WIN32) "") target_link_libraries(vulkan Vulkan::Headers) - if(ENABLE_WIN10_ONECORE) + if(ENABLE_WIN10_ONECORE AND MSVC) target_link_libraries(vulkan OneCoreUAP.lib LIBCMT.LIB LIBCMTD.LIB LIBVCRUNTIME.LIB LIBUCRT.LIB) set_target_properties(vulkan PROPERTIES LINK_FLAGS "/NODEFAULTLIB") else() @@ -326,11 +328,11 @@ else() ) # cmake-format: on endif() +endif() if(NOT APPLE) target_compile_definitions(vulkan PRIVATE _XOPEN_SOURCE=500) # hush compiler warnings for readlink endif() -endif() # Generate pkg-config file. include(FindPkgConfig QUIET) diff --git a/loader/loader.h b/loader/loader.h index 2182f187c..d0570cb97 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -38,7 +38,9 @@ #include "vk_layer_dispatch_table.h" #include "vk_loader_extensions.h" -#if defined(__GNUC__) && __GNUC__ >= 4 +#if defined(_WIN32) +#define LOADER_EXPORT __declspec(dllexport) +#elif defined(__GNUC__) && __GNUC__ >= 4 #define LOADER_EXPORT __attribute__((visibility("default"))) #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) #define LOADER_EXPORT __attribute__((visibility("default"))) diff --git a/tests/layers/vk_format_utils.h b/tests/layers/vk_format_utils.h index e76f9ec2f..ef06e12af 100644 --- a/tests/layers/vk_format_utils.h +++ b/tests/layers/vk_format_utils.h @@ -25,7 +25,9 @@ #include "vulkan/vulkan.h" #if !defined(VK_LAYER_EXPORT) -#if defined(__GNUC__) && __GNUC__ >= 4 +#if defined(_WIN32) +#define VK_LAYER_EXPORT __declspec(dllexport) +#elif defined(__GNUC__) && __GNUC__ >= 4 #define VK_LAYER_EXPORT __attribute__((visibility("default"))) #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) #define VK_LAYER_EXPORT __attribute__((visibility("default"))) -- 2.25.1