Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: compilation with BUILD_SHARED_LIBS with MSVC #776

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
apple-clang *
standards: '20'
latest-factors: |
msvc Optimized-Debug
msvc Optimized-Debug Shared
gcc Coverage
factors: ''
runs-on: |
Expand Down Expand Up @@ -388,6 +388,7 @@ jobs:
package-dir: packages
package-generators: ${{ matrix.mrdocs-package-generators }}
package-artifact: false
shared: ${{ matrix.shared }}

- name: Check YAML schema
run: |
Expand Down
19 changes: 11 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,11 @@ if (WIN32)
target_compile_options(
mrdocs-core
PUBLIC
/permissive- # strict C++
/W4 # enable all warnings
/MP # multi-processor compilation
/EHs # C++ Exception handling
$<$<CONFIG:Debug>:/Oy-> # Disable frame pointer omission
/permissive- # strict C++
/W4 # enable all warnings
$<$<CXX_COMPILER_ID:MSVC>:/MP> # multi-processor compilation
/EHs # C++ Exception handling
$<$<CONFIG:Debug>:/Oy-> # Disable frame pointer omission
)
endif()
endif ()
Expand Down Expand Up @@ -334,7 +334,6 @@ list(APPEND TOOL_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/src/tool/PublicToolArgs.cpp)

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

target_include_directories(mrdocs
PUBLIC
Expand All @@ -346,7 +345,6 @@ target_include_directories(mrdocs
"${PROJECT_BINARY_DIR}/src"
)

target_compile_definitions(mrdocs PRIVATE -DMRDOCS_TOOL)
target_link_libraries(mrdocs PUBLIC mrdocs-core)
if (MRDOCS_CLANG)
target_compile_options(
Expand Down Expand Up @@ -537,9 +535,14 @@ if (MRDOCS_INSTALL)
#-------------------------------------------------
install(TARGETS mrdocs-core
EXPORT mrdocs-targets
RUNTIME_DEPENDENCIES
PRE_EXCLUDE_REGEXES "^api-ms-.*\\.dll$" "^ext-ms-.*\\.dll$"
POST_EXCLUDE_REGEXES ".*system32/.*\\.dll$"
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT development
COMPONENT development
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

install(EXPORT mrdocs-targets
Expand Down
4 changes: 1 addition & 3 deletions include/mrdocs/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class MRDOCS_DECL
public:
/** Settings values used to generate the Corpus and Docs
*/
struct Settings : public PublicSettings
struct MRDOCS_DECL Settings : public PublicSettings
{
/**
* @brief Loads the public configuration settings from the specified YAML file.
Expand Down Expand Up @@ -157,13 +157,11 @@ class MRDOCS_DECL

/** Destructor.
*/
MRDOCS_DECL
virtual
~Config() noexcept = 0;

/** Return a pool of threads for executing work.
*/
MRDOCS_DECL
virtual
ThreadPool&
threadPool() const noexcept = 0;
Expand Down
10 changes: 10 additions & 0 deletions include/mrdocs/Dom/Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,18 +269,21 @@ class MRDOCS_DECL
/** Compare two arrays for equality.
*/
friend
MRDOCS_DECL
bool
operator==(Array const&, Array const&) noexcept;

/** Compare two arrays for precedence.
*/
friend
MRDOCS_DECL
std::strong_ordering
operator<=>(Array const&, Array const&) noexcept;

/** Return a diagnostic string.
*/
friend
MRDOCS_DECL
std::string
toString(Array const&);

Expand Down Expand Up @@ -364,6 +367,13 @@ class MRDOCS_DECL
DefaultArrayImpl();
explicit DefaultArrayImpl(
storage_type elements) noexcept;

DefaultArrayImpl(const DefaultArrayImpl&);
DefaultArrayImpl(DefaultArrayImpl&&);
DefaultArrayImpl& operator=(const DefaultArrayImpl&);
DefaultArrayImpl& operator=(DefaultArrayImpl&&);
~DefaultArrayImpl();

size_type size() const override;
value_type get(size_type i) const override;
void set(size_type i, Value v) override;
Expand Down
8 changes: 7 additions & 1 deletion include/mrdocs/Dom/Object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ class MRDOCS_DECL
/** Compare two objects for equality.
*/
friend
MRDOCS_DECL
bool
operator==(Object const& a, Object const& b) noexcept;

Expand All @@ -318,7 +319,7 @@ class MRDOCS_DECL

/** Return a diagnostic string.
*/
friend std::string toString(Object const&);
friend MRDOCS_DECL std::string toString(Object const&);
};

//------------------------------------------------
Expand Down Expand Up @@ -402,6 +403,11 @@ class MRDOCS_DECL
{
public:
DefaultObjectImpl() noexcept;
DefaultObjectImpl(const DefaultObjectImpl&);
DefaultObjectImpl(DefaultObjectImpl&&);
DefaultObjectImpl& operator=(const DefaultObjectImpl&);
DefaultObjectImpl& operator=(DefaultObjectImpl&&);
~DefaultObjectImpl();

explicit DefaultObjectImpl(
storage_type entries) noexcept;
Expand Down
8 changes: 8 additions & 0 deletions include/mrdocs/Dom/Value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ namespace mrdocs {

@see https://handlebarsjs.com/api-reference/utilities.html#handlebars-safestring-string
*/
MRDOCS_DECL
dom::Value
safeString(std::string_view str);

MRDOCS_DECL
dom::Value
safeString(dom::Value const& str);

Expand Down Expand Up @@ -415,6 +417,7 @@ class MRDOCS_DECL
operator, which does not perform type conversions.
*/
friend
MRDOCS_DECL
bool
operator==(
Value const& lhs,
Expand All @@ -423,6 +426,7 @@ class MRDOCS_DECL
/** Compare two values for inequality.
*/
friend
MRDOCS_DECL
std::strong_ordering
operator<=>(
Value const& lhs,
Expand Down Expand Up @@ -453,6 +457,7 @@ class MRDOCS_DECL
/** Add or concatenate two values.
*/
friend
MRDOCS_DECL
dom::Value
operator+(Value const& lhs, Value const& rhs);

Expand All @@ -477,6 +482,7 @@ class MRDOCS_DECL
This function is equivalent to the JavaScript `||` operator.
*/
friend
MRDOCS_DECL
dom::Value
operator||(Value const& lhs, Value const& rhs);

Expand All @@ -501,6 +507,7 @@ class MRDOCS_DECL
This function is equivalent to the JavaScript `&&` operator.
*/
friend
MRDOCS_DECL
dom::Value
operator&&(Value const& lhs, Value const& rhs);

Expand All @@ -523,6 +530,7 @@ class MRDOCS_DECL
/** Return value as a string.
*/
friend
MRDOCS_DECL
std::string
toString(Value const& value);
};
Expand Down
12 changes: 11 additions & 1 deletion include/mrdocs/Metadata/Javadoc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@ struct Copied : Reference
struct MRDOCS_DECL
Block : Node
{
Block(const Block&) = delete;
Block(Block&&);
Block& operator=(const Block&) = delete;
Block& operator=(Block&&);
~Block();

List<Text> children;

bool isBlock() const noexcept final
Expand Down Expand Up @@ -961,7 +967,6 @@ struct MRDOCS_DECL

/** Constructor.
*/
MRDOCS_DECL
Javadoc() noexcept;

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

Javadoc(const Javadoc&) = delete;
Javadoc(Javadoc&&);
Javadoc& operator=(const Javadoc&) = delete;
Javadoc& operator=(Javadoc&&);

/** Return true if this is empty
*/
bool
Expand Down
3 changes: 2 additions & 1 deletion include/mrdocs/Platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#ifndef MRDOCS_API_PLATFORM_HPP
#define MRDOCS_API_PLATFORM_HPP

#include <mrdocs/Support/Assert.hpp>
#include <type_traits>

#if __cplusplus < 202002L
Expand Down Expand Up @@ -79,4 +78,6 @@ namespace mrdocs {
} // mrdocs
} // clang

#include <mrdocs/Support/Assert.hpp>

#endif
2 changes: 2 additions & 0 deletions include/mrdocs/Support/Assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifndef MRDOCS_API_SUPPORT_ASSERT_HPP
#define MRDOCS_API_SUPPORT_ASSERT_HPP

#include <mrdocs/Platform.hpp>
#include <cstdint>

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

MRDOCS_DECL
void
assert_failed(
const char* msg,
Expand Down
6 changes: 3 additions & 3 deletions include/mrdocs/Support/Glob.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace clang::mrdocs {

Nested brace expansions "{<glob>,"{<glob>,...}",...}" are not supported.
*/
class GlobPattern {
class MRDOCS_DECL GlobPattern {
struct Impl;
std::unique_ptr<Impl> impl_;
public:
Expand Down Expand Up @@ -120,7 +120,7 @@ class GlobPattern {
A glob pattern matcher where "*" does not match path separators.
The pattern "**" can be used to match any number of path separators.
*/
class PathGlobPattern {
class MRDOCS_DECL PathGlobPattern {
GlobPattern glob_;
public:
/** Constructs a PathGlobPattern with the given pattern.
Expand Down Expand Up @@ -224,7 +224,7 @@ class PathGlobPattern {
A glob pattern matcher where "*" does not match "::".
The pattern "**" can be used to match any number of "::".
*/
class SymbolGlobPattern {
class MRDOCS_DECL SymbolGlobPattern {
GlobPattern glob_;
public:
/** Constructs a SymbolGlobPattern with the given pattern.
Expand Down
2 changes: 1 addition & 1 deletion include/mrdocs/Support/Handlebars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ namespace detail {

@see https://handlebarsjs.com/
*/
class Handlebars {
class MRDOCS_DECL Handlebars {
using helpers_map = std::unordered_map<
std::string, dom::Function, detail::string_hash, std::equal_to<>>;

Expand Down
Loading
Loading