feature: introduce DRANG_PLATFORM_BUILD_SHARED option for shared library builds
This commit is contained in:
parent
505539f1cd
commit
e857d1a896
4 changed files with 16 additions and 14 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
cmake_minimum_required(VERSION 3.21)
|
cmake_minimum_required(VERSION 3.21)
|
||||||
project(DrangPlatform VERSION 1.0.0 LANGUAGES C)
|
project(DrangPlatform VERSION 1.0.0 LANGUAGES C)
|
||||||
|
|
||||||
|
option(DRANG_PLATFORM_BUILD_SHARED "Build DrangPlatform as a shared library" OFF)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 17)
|
set(CMAKE_C_STANDARD 17)
|
||||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_C_EXTENSIONS OFF)
|
set(CMAKE_C_EXTENSIONS OFF)
|
||||||
|
|
@ -25,4 +27,5 @@ set(MI_BUILD_STATIC ON CACHE BOOL "" FORCE)
|
||||||
set(MI_USE_CXX OFF CACHE BOOL "" FORCE)
|
set(MI_USE_CXX OFF CACHE BOOL "" FORCE)
|
||||||
FetchContent_MakeAvailable(mimalloc)
|
FetchContent_MakeAvailable(mimalloc)
|
||||||
|
|
||||||
|
|
||||||
add_subdirectory(Source/DrangPlatform)
|
add_subdirectory(Source/DrangPlatform)
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
"displayName": "x64 Debug Shared",
|
"displayName": "x64 Debug Shared",
|
||||||
"inherits": "win64-debug",
|
"inherits": "win64-debug",
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"BUILD_SHARED_LIBS": "ON"
|
"DRANG_PLATFORM_BUILD_SHARED": "ON"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -70,7 +70,7 @@
|
||||||
"displayName": "x64 Release Shared",
|
"displayName": "x64 Release Shared",
|
||||||
"inherits": "win64-release",
|
"inherits": "win64-release",
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"BUILD_SHARED_LIBS": "ON"
|
"DRANG_PLATFORM_BUILD_SHARED": "ON"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -90,7 +90,7 @@
|
||||||
"displayName": "x64 Debug Shared",
|
"displayName": "x64 Debug Shared",
|
||||||
"inherits": "linux64-debug",
|
"inherits": "linux64-debug",
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"BUILD_SHARED_LIBS": "ON"
|
"DRANG_PLATFORM_BUILD_SHARED": "ON"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -110,7 +110,7 @@
|
||||||
"displayName": "x64 Release Shared",
|
"displayName": "x64 Release Shared",
|
||||||
"inherits": "linux64-release",
|
"inherits": "linux64-release",
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"BUILD_SHARED_LIBS": "ON"
|
"DRANG_PLATFORM_BUILD_SHARED": "ON"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -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")
|
collect_platform_sources(MODULE_PUBLIC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/Include")
|
||||||
set(MODULE_FILES ${MODULE_PRIVATE_FILES} ${MODULE_PUBLIC_FILES})
|
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})
|
add_library(${MODULE_NAME} SHARED ${MODULE_FILES})
|
||||||
target_compile_definitions(${MODULE_NAME} PRIVATE DRANG_PLATFORM_EXPORT=1)
|
target_compile_definitions(${MODULE_NAME} PRIVATE DRANG_PLATFORM_EXPORT=1)
|
||||||
else ()
|
else ()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# define DRANG_DLL_EXPORT __declspec(dllexport)
|
# define DRANG_DLL_EXPORT __declspec(dllexport)
|
||||||
# define DRANG_DLL_IMPORT __declspec(dllimport)
|
# define DRANG_DLL_IMPORT __declspec(dllimport)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue