Skip to content

Commit 1c5a4ad

Browse files
committed
Add option to disable warning on MSVC about symbol visibility for custom exceptions
1 parent 1f3e87d commit 1c5a4ad

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

.github/workflows/build.yml

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ jobs:
103103
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
104104
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
105105
-DBUILD_SHARED_LIBS=${{ matrix.shared }}
106+
-DADM_DISABLE_MSVC_EXCEPTION_DLL_BOUNDARY_WARNINGS=ON
106107
107108
- name: 'print ccache stats'
108109
run: ccache -s

CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ option(ADM_HIDE_INTERNAL_SYMBOLS "Hide symbols by default" TRUE)
3636
option(ADM_UNIT_TESTS "Build units tests" ${IS_ROOT_PROJECT})
3737
option(ADM_EXAMPLES "Build examples" ${IS_ROOT_PROJECT})
3838
option(ADM_PACKAGE_AND_INSTALL "Package and install libadm" ${IS_ROOT_PROJECT})
39+
option(ADM_DISABLE_MSVC_EXCEPTION_DLL_BOUNDARY_WARNINGS "Disable warnings C4275 and C4251 for exceptions derived
40+
from std::exception in errors.hpp" OFF)
3941
include(GNUInstallDirs)
4042
set(ADM_INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
4143
set(ADM_INSTALL_BIN_DIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Installation directory for binaries")

include/adm/errors.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
#include <adm/elements/audio_track_format_id.hpp>
88
#include "adm/export.h"
99

10+
#ifdef ADM_DISABLE_MSVC_EXCEPTION_DLL_BOUNDARY_WARNINGS
11+
#pragma warning(disable : 4275 4251)
12+
#endif
13+
1014
namespace adm {
1115
namespace error {
1216

@@ -103,3 +107,7 @@ namespace adm {
103107

104108
} // namespace error
105109
} // namespace adm
110+
111+
#ifdef ADM_DISABLE_MSVC_EXCEPTION_DLL_BOUNDARY_WARNINGS
112+
#pragma warning(default : 4275 4251)
113+
#endif

src/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ target_include_directories(adm
8484
target_link_libraries(adm PUBLIC Boost::boost)
8585
target_link_libraries(adm PRIVATE $<BUILD_INTERFACE:rapidxml>)
8686

87+
if(ADM_DISABLE_MSVC_EXCEPTION_DLL_BOUNDARY_WARNINGS)
88+
target_compile_options(adm PUBLIC $<$<CXX_COMPILER_ID:MSVC>:/DADM_DISABLE_MSVC_EXCEPTION_DLL_BOUNDARY_WARNINGS=1>)
89+
endif()
90+
8791
if (UNIX)
8892
target_link_libraries(adm PUBLIC dl)
8993
endif()

0 commit comments

Comments
 (0)