feature: introduce DRANG_PLATFORM_BUILD_SHARED option for shared library builds

This commit is contained in:
MechSlayer 2025-09-05 17:03:27 +02:00
parent 505539f1cd
commit e857d1a896
4 changed files with 16 additions and 14 deletions

View file

@ -52,7 +52,7 @@ collect_platform_sources(MODULE_PRIVATE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/Sourc
collect_platform_sources(MODULE_PUBLIC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/Include")
set(MODULE_FILES ${MODULE_PRIVATE_FILES} ${MODULE_PUBLIC_FILES})
if (${BUILD_SHARED_LIBS})
if (${DRANG_PLATFORM_BUILD_SHARED})
add_library(${MODULE_NAME} SHARED ${MODULE_FILES})
target_compile_definitions(${MODULE_NAME} PRIVATE DRANG_PLATFORM_EXPORT=1)
else ()

View file

@ -1,21 +1,20 @@
#pragma once
#ifdef _WIN32
#define DRANG_DLL_EXPORT __declspec(dllexport)
#define DRANG_DLL_IMPORT __declspec(dllimport)
# define DRANG_DLL_EXPORT __declspec(dllexport)
# define DRANG_DLL_IMPORT __declspec(dllimport)
#elif defined(__linux__)
#define DRANG_DLL_EXPORT __attribute__((visibility("default")))
#define DRANG_DLL_IMPORT __attribute__((visibility("default")))
# define DRANG_DLL_EXPORT __attribute__((visibility("default")))
# define DRANG_DLL_IMPORT __attribute__((visibility("default")))
#else
#error "Unknown platform, please implement shared library export/import macros"
# error "Unknown platform, please implement shared library export/import macros"
#endif
#if !DRANG_PLATFORM_STATIC
# if DRANG_PLATFORM_EXPORT
#define DRANG_PLATFORM_API DRANG_DLL_EXPORT
#else
#define DRANG_PLATFORM_API DRANG_DLL_IMPORT
# define DRANG_PLATFORM_API DRANG_DLL_EXPORT
# else
# define DRANG_PLATFORM_API DRANG_DLL_IMPORT
# endif
#else
# define DRANG_PLATFORM_API