Skip to content

Commit 88601b1

Browse files
klemens-morgensternvinniefalco
authored andcommitted
has shared link option
fix #93, close #98
1 parent 16b7aca commit 88601b1

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ project(
3434
#set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO ON CACHE STRING "")
3535

3636
option(MRDOX_BUILD_TESTS "Build tests" ON)
37+
option(MRDOX_BUILD_SHARED "Link shared" OFF)
38+
39+
if (MRDOX_BUILD_SHARED)
40+
set(MRDOX_LINK_MODE SHARED)
41+
set(MRDOX_LINK_MODE_DEFINITION -DMRDOX_SHARED_LINK)
42+
else()
43+
set(MRDOX_LINK_MODE_DEFINITION -DMRDOX_STATIC_LINK)
44+
endif()
45+
46+
3747

3848
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
3949
set(MRDOX_GCC ON)
@@ -84,7 +94,7 @@ file(GLOB_RECURSE LIB_SOURCES CONFIGURE_DEPENDS
8494
source/lib/*.cpp
8595
source/lib/*.natvis)
8696

87-
add_library(mrdox-api ${LIB_INCLUDES} ${LIB_SOURCES})
97+
add_library(mrdox-api ${MRDOX_LINK_MODE} ${LIB_INCLUDES} ${LIB_SOURCES})
8898
target_compile_features(mrdox-api PUBLIC cxx_std_20)
8999
target_include_directories(mrdox-api
90100
PUBLIC
@@ -95,7 +105,7 @@ target_include_directories(mrdox-api
95105
target_compile_definitions(
96106
mrdox-api
97107
PUBLIC
98-
-DMRDOX_STATIC_LINK
108+
${MRDOX_LINK_MODE_DEFINITION}
99109
PRIVATE
100110
-DMRDOX_LIB
101111
)

include/mrdox/Platform.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ namespace mrdox {
4141
# define MRDOX_VISIBLE
4242

4343
// (unknown)
44+
#elif defined(__GNUC__)
45+
# if defined(MRDOX_LIB) // building library
46+
# define MRDOX_DECL
47+
# else
48+
# define MRDOX_DECL __attribute__((visibility("default")))
49+
#endif
50+
# define MRDOX_VISIBLE __attribute__((visibility("default")))
4451
#else
4552
# error unknown platform for dynamic linking
4653
#endif

mrdox.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# See https://llvm.org/LICENSE.txt for license information.
44
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55
#
6-
# Copyright (c) 2023 Vinnie Falco ([email protected])
6+
# Copyright (c) 2023 Klemens Morgenstern ([email protected])
77
#
88
# Official repository: https://github.com/cppalliance/mrdox
99
#

0 commit comments

Comments
 (0)