@@ -285,9 +285,7 @@ set(REPORTER_SOURCES
285285)
286286set (REPORTER_FILES ${REPORTER_HEADERS} ${REPORTER_SOURCES} )
287287
288- # Fixme: STATIC because for dynamic, we would need to handle visibility
289- # and I don't want to do the annotations right now
290- add_library (Catch2 STATIC
288+ add_library (Catch2
291289 ${REPORTER_FILES}
292290 ${INTERNAL_FILES}
293291 ${BENCHMARK_HEADERS}
@@ -340,7 +338,7 @@ target_include_directories(Catch2
340338)
341339
342340
343- add_library (Catch2WithMain STATIC
341+ add_library (Catch2WithMain
344342 ${SOURCES_DIR} /internal /catch_main.cpp
345343)
346344add_build_reproducibility_settings(Catch2WithMain)
@@ -431,3 +429,20 @@ endif()
431429
432430list (APPEND CATCH_WARNING_TARGETS Catch2 Catch2WithMain)
433431set (CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE)
432+
433+
434+ # We still do not support building dynamic library with hidden visibility
435+ # so we want to check & warn users if they do this. However, we won't abort
436+ # the configuration step so that we don't have to also provide an override.
437+ if (BUILD_SHARED_LIBS )
438+ get_target_property (_VisPreset Catch2 CXX_VISIBILITY_PRESET)
439+ get_target_property (_ExportAll Catch2 WINDOWS_EXPORT_ALL_SYMBOLS)
440+ if (MSVC AND NOT _ExportAll
441+ OR _VisPreset STREQUAL "hidden" )
442+
443+ message (WARNING
444+ "Catch2 does not support being built as a dynamic library with hidden"
445+ " visibility. You have to ensure that visibility is handled yourself."
446+ )
447+ endif ()
448+ endif ()
0 commit comments