diff --git a/cmake/sdlcompilers.cmake b/cmake/sdlcompilers.cmake index ac4db40c6b..9db746021b 100644 --- a/cmake/sdlcompilers.cmake +++ b/cmake/sdlcompilers.cmake @@ -29,6 +29,8 @@ endfunction() function(SDL_AddCommonCompilerFlags TARGET) option(SDL_WERROR "Enable -Werror" OFF) + get_property(TARGET_TYPE TARGET "${TARGET}" PROPERTY TYPE) + if(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QCC) if(MINGW) # See if GCC's -gdwarf-4 is supported @@ -128,6 +130,13 @@ function(SDL_AddCommonCompilerFlags TARGET) if(HAVE_WERROR) sdl_target_compile_option_all_languages(${TARGET} "-Werror") endif() + + if(TARGET_TYPE STREQUAL "SHARED_LIBRARY") + check_linker_flag(C "-Wl,--no-undefined-version" LINKER_SUPPORTS_NO_UNDEFINED_VERSION) + if(LINKER_SUPPORTS_NO_UNDEFINED_VERSION) + target_link_options(${TARGET} PRIVATE "-Wl,--no-undefined-version") + endif() + endif() endif() endif()