build: --as-needed doesn't work well for us with BUILD_SHARED_LIBS

This commit is contained in:
Marcus Holland-Moritz 2024-02-06 08:03:40 +01:00
parent 58a8fce885
commit 6d5f8dcab5

View File

@ -305,8 +305,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(MSVC_USE_STATIC_RUNTIME ON CACHE BOOL "static build")
else()
if(CMAKE_EXE_LINKER_FLAGS MATCHES "--as-needed")
message(FATAL_ERROR "DwarFS cannot be built with --as-needed")
if(BUILD_SHARED_LIBS AND CMAKE_EXE_LINKER_FLAGS MATCHES "--as-needed")
message(FATAL_ERROR "DwarFS cannot be built with `BUILD_SHARED_LIBS` and `--as-needed` enabled simultaneously.")
endif()
endif()