diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 00a24c17..ab740249 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -103,6 +103,7 @@ jobs: -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBUILD_SHARED_LIBS=${{ matrix.shared }} + -DADM_DISABLE_MSVC_EXCEPTION_DLL_BOUNDARY_WARNINGS=ON - name: 'print ccache stats' run: ccache -s diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ec58f52..0010ef0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,8 @@ option(ADM_HIDE_INTERNAL_SYMBOLS "Hide symbols by default" TRUE) option(ADM_UNIT_TESTS "Build units tests" ${IS_ROOT_PROJECT}) option(ADM_EXAMPLES "Build examples" ${IS_ROOT_PROJECT}) option(ADM_PACKAGE_AND_INSTALL "Package and install libadm" ${IS_ROOT_PROJECT}) +option(ADM_DISABLE_MSVC_EXCEPTION_DLL_BOUNDARY_WARNINGS "Disable warnings C4275 and C4251 for exceptions derived + from std::exception in errors.hpp" OFF) include(GNUInstallDirs) set(ADM_INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries") set(ADM_INSTALL_BIN_DIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Installation directory for binaries") diff --git a/include/adm/errors.hpp b/include/adm/errors.hpp index 323481ba..8cf4c826 100644 --- a/include/adm/errors.hpp +++ b/include/adm/errors.hpp @@ -7,6 +7,10 @@ #include #include "adm/export.h" +#ifdef ADM_DISABLE_MSVC_EXCEPTION_DLL_BOUNDARY_WARNINGS +#pragma warning(disable : 4275 4251) +#endif + namespace adm { namespace error { @@ -103,3 +107,7 @@ namespace adm { } // namespace error } // namespace adm + +#ifdef ADM_DISABLE_MSVC_EXCEPTION_DLL_BOUNDARY_WARNINGS +#pragma warning(default : 4275 4251) +#endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 931a0dfb..d1f9025e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -84,6 +84,10 @@ target_include_directories(adm target_link_libraries(adm PUBLIC Boost::boost) target_link_libraries(adm PRIVATE $) +if(ADM_DISABLE_MSVC_EXCEPTION_DLL_BOUNDARY_WARNINGS) +target_compile_options(adm PUBLIC $<$:/DADM_DISABLE_MSVC_EXCEPTION_DLL_BOUNDARY_WARNINGS=1>) +endif() + if (UNIX) target_link_libraries(adm PUBLIC dl) endif()