Add -fvisibility=hidden flag in CMakeLists.
This way, only functions marked with WEBP_EXTERN get exposed by the library.
This flag is already set in other build configs: configure.ac, makefile.unix,
Android.mk
@@ -117,6 +117,8 @@ set(includedir "\$\{prefix\}/include")
set(PTHREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
set(INSTALLED_LIBRARIES)
+set(CMAKE_C_VISIBILITY_PRESET hidden)
+
# ##############################################################################
# Android only.
if(ANDROID)
@@ -614,6 +616,13 @@ if(WEBP_BUILD_EXTRAS)
parse_makefile_am(${EXTRAS_MAKEFILE} "WEBP_QUALITY_SRCS" "webp_quality")
parse_makefile_am(${EXTRAS_MAKEFILE} "VWEBP_SDL_SRCS" "vwebp_sdl")
+ # libextras
+ add_library(extras STATIC ${WEBP_EXTRAS_SRCS})
+ target_include_directories(extras
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/src)
+
# get_disto
add_executable(get_disto ${GET_DISTO_SRCS})
target_link_libraries(get_disto imagedec)
@@ -622,8 +631,8 @@ if(WEBP_BUILD_EXTRAS)
${CMAKE_CURRENT_BINARY_DIR}/src)
# webp_quality
- add_executable(webp_quality ${WEBP_QUALITY_SRCS} ${WEBP_EXTRAS_SRCS})
- target_link_libraries(webp_quality exampleutil imagedec)
+ add_executable(webp_quality ${WEBP_QUALITY_SRCS})
+ target_link_libraries(webp_quality exampleutil imagedec extras)
target_include_directories(webp_quality
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR})
