Skip to content

Commit 592f987

Browse files
committed
fix: compilation with BUILD_SHARED_LIBS with MSVC
1 parent df29558 commit 592f987

21 files changed

+128
-36
lines changed

.github/workflows/ci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
apple-clang *
4141
standards: '20'
4242
latest-factors: |
43-
msvc Optimized-Debug
43+
msvc Optimized-Debug Shared
4444
gcc Coverage
4545
factors: ''
4646
runs-on: |
@@ -388,6 +388,7 @@ jobs:
388388
package-dir: packages
389389
package-generators: ${{ matrix.mrdocs-package-generators }}
390390
package-artifact: false
391+
shared: ${{ matrix.shared }}
391392

392393
- name: Check YAML schema
393394
run: |

CMakeLists.txt

+11-8
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,11 @@ if (WIN32)
300300
target_compile_options(
301301
mrdocs-core
302302
PUBLIC
303-
/permissive- # strict C++
304-
/W4 # enable all warnings
305-
/MP # multi-processor compilation
306-
/EHs # C++ Exception handling
307-
$<$<CONFIG:Debug>:/Oy-> # Disable frame pointer omission
303+
/permissive- # strict C++
304+
/W4 # enable all warnings
305+
$<$<CXX_COMPILER_ID:MSVC>:/MP> # multi-processor compilation
306+
/EHs # C++ Exception handling
307+
$<$<CONFIG:Debug>:/Oy-> # Disable frame pointer omission
308308
)
309309
endif()
310310
endif ()
@@ -334,7 +334,6 @@ list(APPEND TOOL_SOURCES
334334
${CMAKE_CURRENT_BINARY_DIR}/src/tool/PublicToolArgs.cpp)
335335

336336
add_executable(mrdocs ${TOOL_SOURCES})
337-
target_compile_definitions(mrdocs PRIVATE -DMRDOCS_TOOL)
338337

339338
target_include_directories(mrdocs
340339
PUBLIC
@@ -346,7 +345,6 @@ target_include_directories(mrdocs
346345
"${PROJECT_BINARY_DIR}/src"
347346
)
348347

349-
target_compile_definitions(mrdocs PRIVATE -DMRDOCS_TOOL)
350348
target_link_libraries(mrdocs PUBLIC mrdocs-core)
351349
if (MRDOCS_CLANG)
352350
target_compile_options(
@@ -537,9 +535,14 @@ if (MRDOCS_INSTALL)
537535
#-------------------------------------------------
538536
install(TARGETS mrdocs-core
539537
EXPORT mrdocs-targets
538+
RUNTIME_DEPENDENCIES
539+
PRE_EXCLUDE_REGEXES "^api-ms-.*\\.dll$" "^ext-ms-.*\\.dll$"
540+
POST_EXCLUDE_REGEXES ".*system32/.*\\.dll$"
540541
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
541542
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
542-
COMPONENT development
543+
COMPONENT development
544+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
545+
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}
543546
)
544547

545548
install(EXPORT mrdocs-targets

include/mrdocs/Config.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class MRDOCS_DECL
6060
public:
6161
/** Settings values used to generate the Corpus and Docs
6262
*/
63-
struct Settings : public PublicSettings
63+
struct MRDOCS_DECL Settings : public PublicSettings
6464
{
6565
/**
6666
* @brief Loads the public configuration settings from the specified YAML file.
@@ -157,13 +157,11 @@ class MRDOCS_DECL
157157

158158
/** Destructor.
159159
*/
160-
MRDOCS_DECL
161160
virtual
162161
~Config() noexcept = 0;
163162

164163
/** Return a pool of threads for executing work.
165164
*/
166-
MRDOCS_DECL
167165
virtual
168166
ThreadPool&
169167
threadPool() const noexcept = 0;

include/mrdocs/Dom/Array.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -269,18 +269,21 @@ class MRDOCS_DECL
269269
/** Compare two arrays for equality.
270270
*/
271271
friend
272+
MRDOCS_DECL
272273
bool
273274
operator==(Array const&, Array const&) noexcept;
274275

275276
/** Compare two arrays for precedence.
276277
*/
277278
friend
279+
MRDOCS_DECL
278280
std::strong_ordering
279281
operator<=>(Array const&, Array const&) noexcept;
280282

281283
/** Return a diagnostic string.
282284
*/
283285
friend
286+
MRDOCS_DECL
284287
std::string
285288
toString(Array const&);
286289

@@ -364,6 +367,13 @@ class MRDOCS_DECL
364367
DefaultArrayImpl();
365368
explicit DefaultArrayImpl(
366369
storage_type elements) noexcept;
370+
371+
DefaultArrayImpl(const DefaultArrayImpl&);
372+
DefaultArrayImpl(DefaultArrayImpl&&);
373+
DefaultArrayImpl& operator=(const DefaultArrayImpl&);
374+
DefaultArrayImpl& operator=(DefaultArrayImpl&&);
375+
~DefaultArrayImpl();
376+
367377
size_type size() const override;
368378
value_type get(size_type i) const override;
369379
void set(size_type i, Value v) override;

include/mrdocs/Dom/Object.hpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ class MRDOCS_DECL
298298
/** Compare two objects for equality.
299299
*/
300300
friend
301+
MRDOCS_DECL
301302
bool
302303
operator==(Object const& a, Object const& b) noexcept;
303304

@@ -318,7 +319,7 @@ class MRDOCS_DECL
318319

319320
/** Return a diagnostic string.
320321
*/
321-
friend std::string toString(Object const&);
322+
friend MRDOCS_DECL std::string toString(Object const&);
322323
};
323324

324325
//------------------------------------------------
@@ -402,6 +403,11 @@ class MRDOCS_DECL
402403
{
403404
public:
404405
DefaultObjectImpl() noexcept;
406+
DefaultObjectImpl(const DefaultObjectImpl&);
407+
DefaultObjectImpl(DefaultObjectImpl&&);
408+
DefaultObjectImpl& operator=(const DefaultObjectImpl&);
409+
DefaultObjectImpl& operator=(DefaultObjectImpl&&);
410+
~DefaultObjectImpl();
405411

406412
explicit DefaultObjectImpl(
407413
storage_type entries) noexcept;

include/mrdocs/Dom/Value.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ namespace mrdocs {
4646
4747
@see https://handlebarsjs.com/api-reference/utilities.html#handlebars-safestring-string
4848
*/
49+
MRDOCS_DECL
4950
dom::Value
5051
safeString(std::string_view str);
5152

53+
MRDOCS_DECL
5254
dom::Value
5355
safeString(dom::Value const& str);
5456

@@ -415,6 +417,7 @@ class MRDOCS_DECL
415417
operator, which does not perform type conversions.
416418
*/
417419
friend
420+
MRDOCS_DECL
418421
bool
419422
operator==(
420423
Value const& lhs,
@@ -423,6 +426,7 @@ class MRDOCS_DECL
423426
/** Compare two values for inequality.
424427
*/
425428
friend
429+
MRDOCS_DECL
426430
std::strong_ordering
427431
operator<=>(
428432
Value const& lhs,
@@ -453,6 +457,7 @@ class MRDOCS_DECL
453457
/** Add or concatenate two values.
454458
*/
455459
friend
460+
MRDOCS_DECL
456461
dom::Value
457462
operator+(Value const& lhs, Value const& rhs);
458463

@@ -477,6 +482,7 @@ class MRDOCS_DECL
477482
This function is equivalent to the JavaScript `||` operator.
478483
*/
479484
friend
485+
MRDOCS_DECL
480486
dom::Value
481487
operator||(Value const& lhs, Value const& rhs);
482488

@@ -501,6 +507,7 @@ class MRDOCS_DECL
501507
This function is equivalent to the JavaScript `&&` operator.
502508
*/
503509
friend
510+
MRDOCS_DECL
504511
dom::Value
505512
operator&&(Value const& lhs, Value const& rhs);
506513

@@ -523,6 +530,7 @@ class MRDOCS_DECL
523530
/** Return value as a string.
524531
*/
525532
friend
533+
MRDOCS_DECL
526534
std::string
527535
toString(Value const& value);
528536
};

include/mrdocs/Metadata/Javadoc.hpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,12 @@ struct Copied : Reference
380380
struct MRDOCS_DECL
381381
Block : Node
382382
{
383+
Block(const Block&) = delete;
384+
Block(Block&&);
385+
Block& operator=(const Block&) = delete;
386+
Block& operator=(Block&&);
387+
~Block();
388+
383389
List<Text> children;
384390

385391
bool isBlock() const noexcept final
@@ -961,7 +967,6 @@ struct MRDOCS_DECL
961967

962968
/** Constructor.
963969
*/
964-
MRDOCS_DECL
965970
Javadoc() noexcept;
966971

967972
/** Constructor
@@ -970,6 +975,11 @@ struct MRDOCS_DECL
970975
Javadoc(
971976
doc::List<doc::Block> blocks);
972977

978+
Javadoc(const Javadoc&) = delete;
979+
Javadoc(Javadoc&&);
980+
Javadoc& operator=(const Javadoc&) = delete;
981+
Javadoc& operator=(Javadoc&&);
982+
973983
/** Return true if this is empty
974984
*/
975985
bool

include/mrdocs/Platform.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#ifndef MRDOCS_API_PLATFORM_HPP
1212
#define MRDOCS_API_PLATFORM_HPP
1313

14-
#include <mrdocs/Support/Assert.hpp>
1514
#include <type_traits>
1615

1716
#if __cplusplus < 202002L
@@ -79,4 +78,6 @@ namespace mrdocs {
7978
} // mrdocs
8079
} // clang
8180

81+
#include <mrdocs/Support/Assert.hpp>
82+
8283
#endif

include/mrdocs/Support/Assert.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#ifndef MRDOCS_API_SUPPORT_ASSERT_HPP
1212
#define MRDOCS_API_SUPPORT_ASSERT_HPP
1313

14+
#include <mrdocs/Platform.hpp>
1415
#include <cstdint>
1516

1617
namespace clang {
@@ -30,6 +31,7 @@ namespace mrdocs {
3031
#define MRDOCS_UNREACHABLE() static_cast<void>(__debugbreak(), __assume(false))
3132
#endif
3233

34+
MRDOCS_DECL
3335
void
3436
assert_failed(
3537
const char* msg,

include/mrdocs/Support/Glob.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace clang::mrdocs {
3131
3232
Nested brace expansions "{<glob>,"{<glob>,...}",...}" are not supported.
3333
*/
34-
class GlobPattern {
34+
class MRDOCS_DECL GlobPattern {
3535
struct Impl;
3636
std::unique_ptr<Impl> impl_;
3737
public:
@@ -120,7 +120,7 @@ class GlobPattern {
120120
A glob pattern matcher where "*" does not match path separators.
121121
The pattern "**" can be used to match any number of path separators.
122122
*/
123-
class PathGlobPattern {
123+
class MRDOCS_DECL PathGlobPattern {
124124
GlobPattern glob_;
125125
public:
126126
/** Constructs a PathGlobPattern with the given pattern.
@@ -224,7 +224,7 @@ class PathGlobPattern {
224224
A glob pattern matcher where "*" does not match "::".
225225
The pattern "**" can be used to match any number of "::".
226226
*/
227-
class SymbolGlobPattern {
227+
class MRDOCS_DECL SymbolGlobPattern {
228228
GlobPattern glob_;
229229
public:
230230
/** Constructs a SymbolGlobPattern with the given pattern.

include/mrdocs/Support/Handlebars.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ namespace detail {
633633
634634
@see https://handlebarsjs.com/
635635
*/
636-
class Handlebars {
636+
class MRDOCS_DECL Handlebars {
637637
using helpers_map = std::unordered_map<
638638
std::string, dom::Function, detail::string_hash, std::equal_to<>>;
639639

0 commit comments

Comments
 (0)