mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-25 23:06:10 +01:00
Allow building Catch2 as dynamic library
Also have a check that warns users if they try to combined dynamic library with hidden visibility, which we do not support. Closes #2397 Closes #2398
This commit is contained in:
parent
34d9724058
commit
bea58bf8bb
@ -285,9 +285,7 @@ set(REPORTER_SOURCES
|
|||||||
)
|
)
|
||||||
set(REPORTER_FILES ${REPORTER_HEADERS} ${REPORTER_SOURCES})
|
set(REPORTER_FILES ${REPORTER_HEADERS} ${REPORTER_SOURCES})
|
||||||
|
|
||||||
# Fixme: STATIC because for dynamic, we would need to handle visibility
|
add_library(Catch2
|
||||||
# and I don't want to do the annotations right now
|
|
||||||
add_library(Catch2 STATIC
|
|
||||||
${REPORTER_FILES}
|
${REPORTER_FILES}
|
||||||
${INTERNAL_FILES}
|
${INTERNAL_FILES}
|
||||||
${BENCHMARK_HEADERS}
|
${BENCHMARK_HEADERS}
|
||||||
@ -340,7 +338,7 @@ target_include_directories(Catch2
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
add_library(Catch2WithMain STATIC
|
add_library(Catch2WithMain
|
||||||
${SOURCES_DIR}/internal/catch_main.cpp
|
${SOURCES_DIR}/internal/catch_main.cpp
|
||||||
)
|
)
|
||||||
add_build_reproducibility_settings(Catch2WithMain)
|
add_build_reproducibility_settings(Catch2WithMain)
|
||||||
@ -431,3 +429,20 @@ endif()
|
|||||||
|
|
||||||
list(APPEND CATCH_WARNING_TARGETS Catch2 Catch2WithMain)
|
list(APPEND CATCH_WARNING_TARGETS Catch2 Catch2WithMain)
|
||||||
set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE)
|
set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE)
|
||||||
|
|
||||||
|
|
||||||
|
# We still do not support building dynamic library with hidden visibility
|
||||||
|
# so we want to check & warn users if they do this. However, we won't abort
|
||||||
|
# the configuration step so that we don't have to also provide an override.
|
||||||
|
if (BUILD_SHARED_LIBS)
|
||||||
|
get_target_property(_VisPreset Catch2 CXX_VISIBILITY_PRESET)
|
||||||
|
get_target_property(_ExportAll Catch2 WINDOWS_EXPORT_ALL_SYMBOLS)
|
||||||
|
if (MSVC AND NOT _ExportAll
|
||||||
|
OR _VisPreset STREQUAL "hidden")
|
||||||
|
|
||||||
|
message(WARNING
|
||||||
|
"Catch2 does not support being built as a dynamic library with hidden"
|
||||||
|
" visibility. You have to ensure that visibility is handled yourself."
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user