From 05d3fe3118549e9d3230a283afcf0c744c23d88a Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Mon, 21 Jan 2019 11:00:34 -0800 Subject: Fixed shared libaries on linux/mac/iOS --- Graphics/GraphicsEngineVulkan/CMakeLists.txt | 8 ++-- .../interface/RenderDeviceFactoryVk.h | 55 ++++++++++++---------- 2 files changed, 34 insertions(+), 29 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/CMakeLists.txt b/Graphics/GraphicsEngineVulkan/CMakeLists.txt index 40f4a22d..767b20d3 100644 --- a/Graphics/GraphicsEngineVulkan/CMakeLists.txt +++ b/Graphics/GraphicsEngineVulkan/CMakeLists.txt @@ -190,11 +190,13 @@ set(PUBLIC_DEPENDENCIES ) target_link_libraries(GraphicsEngineVk-static PRIVATE ${PRIVATE_DEPENDENCIES} PUBLIC ${PUBLIC_DEPENDENCIES}) -target_link_libraries(GraphicsEngineVk-shared PUBLIC GraphicsEngineVk-static) +target_link_libraries(GraphicsEngineVk-shared PRIVATE BuildSettings PUBLIC ${PUBLIC_DEPENDENCIES}) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") - set_target_properties(GraphicsEngineVk-shared PROPERTIES CXX_VISIBILITY_PRESET hidden) # -fvisibility=hidden + target_link_libraries(GraphicsEngineVk-shared PRIVATE -Wl,--whole-archive GraphicsEngineVk-static -Wl,--no-whole-archive) +else() + target_link_libraries(GraphicsEngineVk-shared PRIVATE GraphicsEngineVk-static) endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -221,8 +223,8 @@ if (${DILIGENT_NO_GLSLANG}) message("GLSLang is not being built. Vulkan backend will only be able to consume SPIRV byte code.") endif() -target_compile_definitions(GraphicsEngineVk-shared PRIVATE ${PRIVATE_COMPILE_DEFINITIONS} ENGINE_DLL=1) target_compile_definitions(GraphicsEngineVk-static PRIVATE ${PRIVATE_COMPILE_DEFINITIONS} NO_GLSLANG=$) +target_compile_definitions(GraphicsEngineVk-shared PRIVATE ${PRIVATE_COMPILE_DEFINITIONS} ENGINE_DLL=1) if(PLATFORM_WIN32) diff --git a/Graphics/GraphicsEngineVulkan/interface/RenderDeviceFactoryVk.h b/Graphics/GraphicsEngineVulkan/interface/RenderDeviceFactoryVk.h index add261d3..b5de2664 100644 --- a/Graphics/GraphicsEngineVulkan/interface/RenderDeviceFactoryVk.h +++ b/Graphics/GraphicsEngineVulkan/interface/RenderDeviceFactoryVk.h @@ -48,31 +48,33 @@ namespace Diligent { - class IEngineFactoryVk - { - public: - virtual void CreateDeviceAndContextsVk(const EngineVkAttribs& CreationAttribs, - IRenderDevice **ppDevice, - IDeviceContext **ppContexts, - Uint32 NumDeferredContexts) = 0; +class IEngineFactoryVk +{ +public: + virtual void CreateDeviceAndContextsVk(const EngineVkAttribs& CreationAttribs, + IRenderDevice **ppDevice, + IDeviceContext **ppContexts, + Uint32 NumDeferredContexts) = 0; - //virtual void AttachToVulkanDevice(void *pVkNativeDevice, - // class ICommandQueueVk *pCommandQueue, - // const EngineVkAttribs& EngineAttribs, - // IRenderDevice **ppDevice, - // IDeviceContext **ppContexts, - // Uint32 NumDeferredContexts) = 0; + //virtual void AttachToVulkanDevice(void *pVkNativeDevice, + // class ICommandQueueVk *pCommandQueue, + // const EngineVkAttribs& EngineAttribs, + // IRenderDevice **ppDevice, + // IDeviceContext **ppContexts, + // Uint32 NumDeferredContexts) = 0; - virtual void CreateSwapChainVk(IRenderDevice *pDevice, - IDeviceContext *pImmediateContext, - const SwapChainDesc& SwapChainDesc, - void* pNativeWndHandle, - ISwapChain **ppSwapChain) = 0; + virtual void CreateSwapChainVk(IRenderDevice *pDevice, + IDeviceContext *pImmediateContext, + const SwapChainDesc& SwapChainDesc, + void* pNativeWndHandle, + ISwapChain **ppSwapChain) = 0; - }; +}; -#if ENGINE_DLL && PLATFORM_WIN32 +#if ENGINE_DLL && PLATFORM_WIN32 && defined(_MSC_VER) + +# define EXPLICITLY_LOAD_ENGINE_VK_DLL 1 typedef IEngineFactoryVk* (*GetEngineFactoryVkType)(); @@ -81,17 +83,17 @@ namespace Diligent GetFactoryFunc = nullptr; std::string LibName = "GraphicsEngineVk_"; -#if _WIN64 +# if _WIN64 LibName += "64"; -#else +# else LibName += "32"; -#endif +# endif -#ifdef _DEBUG +# ifdef _DEBUG LibName += "d"; -#else +# else LibName += "r"; -#endif +# endif LibName += ".dll"; auto hModule = LoadLibraryA(LibName.c_str()); @@ -115,6 +117,7 @@ namespace Diligent return true; } + #else API_QUALIFIER -- cgit v1.2.3