@@ -68,14 +68,17 @@ set(PNG_DEBUG_POSTFIX "d"
6868set (DFA_XTRA ""
6969 CACHE FILEPATH "File containing extra configuration settings" )
7070
71- # Allow the users to configure the following build options.
72- option (PNG_SHARED "Build libpng as a shared lib" ON )
73- option (PNG_STATIC "Build libpng as a static lib" ON )
74- option (PNG_FRAMEWORK "Build libpng as a Mac OS X framework" OFF )
71+ # Allow the users to switch on/off various library build types.
72+ option (PNG_SHARED "Build libpng as a shared library" ON )
73+ option (PNG_STATIC "Build libpng as a static library" ON )
74+ if (APPLE )
75+ option (PNG_FRAMEWORK "Build libpng as a framework bundle" ON )
76+ endif ()
77+
78+ # Allow the users to switch on/off the auxiliary build and test artifacts.
79+ # NOTE: These artifacts are NOT part of libpng proper, and are subject to change at any time.
7580option (PNG_TESTS "Build the libpng tests" ON )
7681option (PNG_TOOLS "Build the libpng tools" ON )
77- option (PNG_DEBUG "Enable debug output" OFF )
78- option (PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" ON )
7982
8083# Maintain backwards compatibility with the deprecated option PNG_EXECUTABLES.
8184option (PNG_EXECUTABLES "[Deprecated; please use PNG_TOOLS]" ON )
@@ -88,6 +91,10 @@ if(NOT PNG_EXECUTABLES)
8891 endif ()
8992endif ()
9093
94+ # Allow the users to configure various compilation options.
95+ option (PNG_DEBUG "Enable debug output" OFF )
96+ option (PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" ON )
97+
9198# Allow the users to specify a location of zlib.
9299# Useful if zlib is being built alongside this as a sub-project.
93100option (PNG_BUILD_ZLIB "Custom zlib location, else find_package is used" OFF )
@@ -659,7 +666,11 @@ if(PNG_SHARED)
659666 LINK_FLAGS "-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR} /libpng.vers'" )
660667 endif ()
661668 endif ()
662- if (WIN32 )
669+ if (APPLE )
670+ # Avoid CMake's implicit compile definition "png_shared_EXPORTS".
671+ set_target_properties (png_shared PROPERTIES DEFINE_SYMBOL "" )
672+ elseif (WIN32 )
673+ # Use the explicit compile definition "PNG_BUILD_DLL" for Windows DLLs.
663674 set_target_properties (png_shared PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
664675 endif ()
665676 target_include_directories (png_shared
@@ -685,7 +696,7 @@ if(PNG_STATIC)
685696 target_link_libraries (png_static PUBLIC ZLIB::ZLIB ${M_LIBRARY} )
686697endif ()
687698
688- if (PNG_FRAMEWORK)
699+ if (PNG_FRAMEWORK AND APPLE )
689700 add_library (png_framework SHARED ${libpng_sources} )
690701 add_dependencies (png_framework png_genfiles)
691702 list (APPEND PNG_LIBRARY_TARGETS png_framework)
@@ -697,7 +708,10 @@ if(PNG_FRAMEWORK)
697708 MACOSX_FRAMEWORK_IDENTIFIER "org.libpng.libpng"
698709 XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
699710 PUBLIC_HEADER "${libpng_public_hdrs} "
700- OUTPUT_NAME "png" )
711+ OUTPUT_NAME "png"
712+ DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX} " )
713+ # Avoid CMake's implicit compile definition "-Dpng_framework_EXPORTS".
714+ set_target_properties (png_framework PROPERTIES DEFINE_SYMBOL "" )
701715 target_include_directories (png_framework
702716 PUBLIC
703717 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR} /libpng${PNGLIB_ABI_VERSION} >
0 commit comments