diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index 8bb10fd..fc38ecc 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -127,7 +127,7 @@ set(ASM_FAILURE_MSG "${ASM_FAILURE_MSG}Note that this may be unsafe, as the C co set(ASM_FAILURE_MSG "${ASM_FAILURE_MSG} the stack frame for certain calls. If the compiler does not do this, then unknown device") set(ASM_FAILURE_MSG "${ASM_FAILURE_MSG} extensions will suffer from a corrupted stack.") if(WIN32) - if(MINGW) + if(NOT MINGW) find_program(JWASM_FOUND jwasm) if (JWASM_FOUND) set(CMAKE_ASM_MASM_COMPILER ${JWASM_FOUND}) @@ -145,7 +145,7 @@ if(WIN32) if (USE_MASM) enable_language(ASM_MASM) endif () - if(CMAKE_ASM_MASM_COMPILER_WORKS OR JWASM_FOUND) + if(MSVC AND CMAKE_ASM_MASM_COMPILER_WORKS OR JWASM_FOUND) if(MINGW) set(CMAKE_ASM_MASM_FLAGS ${CMAKE_ASM_MASM_FLAGS} ${JWASM_FLAGS}) elseif(NOT CMAKE_CL_64 AND NOT JWASM_FOUND) @@ -161,12 +161,14 @@ if(WIN32) target_link_libraries(loader-unknown-chain Vulkan::Headers) target_include_directories(loader-unknown-chain PUBLIC $) add_dependencies(loader-unknown-chain loader_asm_gen_files) + set_target_properties(loader-unknown-chain PROPERTIES DEFINE_SYMBOL "VK_BUILDING_DLL") else() message(WARNING "Could not find working MASM assebler\n${ASM_FAILURE_MSG}") add_custom_target(loader_asm_gen_files) add_library(loader-unknown-chain OBJECT unknown_ext_chain.c) target_link_libraries(loader-unknown-chain loader_specific_options) set_target_properties(loader-unknown-chain PROPERTIES CMAKE_C_FLAGS_DEBUG "${MODIFIED_C_FLAGS_DEBUG}") + set_target_properties(loader-unknown-chain PROPERTIES DEFINE_SYMBOL "VK_BUILDING_DLL") endif() elseif(APPLE) # For MacOS, use the C code and force the compiler's tail-call optimization instead of using assembly code. @@ -261,6 +263,7 @@ endif() if(WIN32) add_library(loader-opt STATIC ${OPT_LOADER_SRCS}) + set_target_properties(loader-opt PROPERTIES DEFINE_SYMBOL "VK_BUILDING_DLL") target_link_libraries(loader-opt PUBLIC loader_specific_options) add_dependencies(loader-opt loader_asm_gen_files) set_target_properties(loader-opt PROPERTIES CMAKE_C_FLAGS_DEBUG "${MODIFIED_C_FLAGS_DEBUG}") @@ -237,10 +240,17 @@ if(WIN32) # when adding the suffix the import and runtime library names must be consistent # mingw: libvulkan-1.dll.a / libvulkan-1.dll # msvc: vulkan-1.lib / vulkan-1.dll + if(MSVC) set_target_properties(vulkan PROPERTIES OUTPUT_NAME vulkan-1) - + else() + set_target_properties(vulkan + PROPERTIES + LIBRARY_OUTPUT_NAME vulkan + RUNTIME_OUTPUT_NAME vulkan-1 + ARCHIVE_OUTPUT_NAME vulkan) + endif() if(MSVC AND ENABLE_WIN10_ONECORE) target_link_libraries(vulkan OneCoreUAP.lib LIBCMT.LIB LIBCMTD.LIB LIBVCRUNTIME.LIB LIBUCRT.LIB) set_target_properties(vulkan PROPERTIES LINK_FLAGS "/NODEFAULTLIB") diff --git a/loader/vk_loader_platform.h b/loader/vk_loader_platform.h index 507a901..6b8fc48 100644 --- a/loader/vk_loader_platform.h +++ b/loader/vk_loader_platform.h @@ -77,7 +77,13 @@ #include "vk_layer_dispatch_table.h" #include "vk_loader_extensions.h" -#if defined(__GNUC__) && __GNUC__ >= 4 +#if defined(_WIN32) +# if defined (VK_BUILDING_DLL) +# define LOADER_EXPORT __declspec(dllexport) +# else +# define LOADER_EXPORT +# endif +#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/loader/vulkan-1.def b/loader/vulkan-1.def index 6a88b55..1d26b1f 100644 --- a/loader/vulkan-1.def +++ b/loader/vulkan-1.def @@ -22,7 +22,7 @@ ; ;;;; End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -LIBRARY vulkan-1.dll +LIBRARY libvulkan-1.dll EXPORTS vkCreateInstance vkDestroyInstance