[build] Revise visibility attributes usage in autotools and CMake.

* CMakeLists.txt: Set `C_VISIBILITY_PRESET` to hidden for non-Windows only.
  Windows handles exports with `DLL_EXPORT` defined, and old MinGW
  toolchains emit a lot of warnings about visibility attributes not being
  supported in this configuration.

* build/unix/configure.raw: Revise visibility attributes checks by compiling a
  better test program with `-Werror` in `CFLAGS` so that warnings correctly
  indicate unsupported configurations.
This commit is contained in:
Ozkan Sezer
2025-06-04 08:21:50 +03:00
committed by Werner Lemberg
parent 81f839a7d9
commit 5bc2081741
2 changed files with 22 additions and 10 deletions

View File

@@ -489,10 +489,6 @@ add_library(freetype
${BASE_SRCS}
)
set_target_properties(
freetype PROPERTIES
C_VISIBILITY_PRESET hidden)
target_compile_definitions(
freetype PRIVATE FT2_BUILD_LIBRARY)
@@ -503,6 +499,10 @@ if (WIN32)
target_compile_definitions(
freetype PRIVATE DLL_EXPORT)
endif ()
else ()
# Windows handles exports with DLL_EXPORT defined above.
set_target_properties(freetype PROPERTIES
C_VISIBILITY_PRESET hidden)
endif ()
if (BUILD_SHARED_LIBS)