diff --git a/.cmake-format.yaml b/.cmake-format.yaml index 81a5e2643..67c53d2db 100644 --- a/.cmake-format.yaml +++ b/.cmake-format.yaml @@ -39,8 +39,8 @@ disabled_codes: [ # re-enable the "invalid variable name XXX" messages. "C0103", - # A custom command with one output doesn't really need a comment because - # the default "generating XXX" is a good message already. + # TODO: + # Add brief COMMENT arguments to the `add_custom_target` commands. "C0113", ] @@ -82,10 +82,10 @@ keyword_pattern: "[A-Z][0-9A-Z_]+" # before considering the loop a parser max_conditionals_custom_parser: 2 -# Require at least this many newlines between statements +# Require at least this many newlines between statements; +# require no more than this many newlines between statements; +# etc. min_statement_spacing: 1 - -# Require no more than this many newlines between statements max_statement_spacing: 2 max_returns: 6 max_branches: 12 diff --git a/CMakeLists.txt b/CMakeLists.txt index 805d0afe2..49bb64f14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,14 +34,16 @@ include(GNUInstallDirs) # Allow the users to specify an application-specific API prefix for libpng # vendoring purposes. A standard libpng build should have no such prefix. -set(PNG_PREFIX "" +set(PNG_PREFIX + "" CACHE STRING "Prefix to prepend to the API function names") # Allow the users to override the postfix appended to debug library file names. # Previously, we used to set CMAKE_DEBUG_POSTFIX globally. That variable should # not be cached, however, because doing so would affect all projects processed # after libpng, in unexpected and undesirable ways. -set(PNG_DEBUG_POSTFIX "d" +set(PNG_DEBUG_POSTFIX + "d" CACHE STRING "Postfix to append to library file names under the Debug configuration") # Allow the users to import their own extra configuration settings. @@ -50,18 +52,20 @@ set(PNG_DEBUG_POSTFIX "d" # header file form (such as "scripts/pnglibconf.h.prebuilt"), but not both. # For platforms such as Android or iOS, or in certain cross-platform build # scenarios, having a valid PNG_LIBCONF_HEADER is mandatory. -set(DFA_XTRA "" +set(DFA_XTRA + "" CACHE FILEPATH "DFA file containing customized build configuration settings for libpng") -set(PNG_LIBCONF_HEADER "" +set(PNG_LIBCONF_HEADER + "" CACHE FILEPATH "C header file containing customized build configuration settings for libpng") set(PNG_LIBCONF_HEADER_PREBUILT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt") if(ANDROID OR IOS) set(PNG_LIBCONF_HEADER "${PNG_LIBCONF_HEADER_PREBUILT}") endif() if((NOT DFA_XTRA STREQUAL "") AND (NOT PNG_LIBCONF_HEADER STREQUAL "")) - message(SEND_ERROR - "The options DFA_XTRA=\"${DFA_XTRA}\" and PNG_LIBCONF_HEADER=\"${PNG_LIBCONF_HEADER}\" " - "are mutually exclusive") + message(SEND_ERROR "The options DFA_XTRA=\"${DFA_XTRA}\" " + "and PNG_LIBCONF_HEADER=\"${PNG_LIBCONF_HEADER}\" " + "are mutually exclusive") endif() # Allow the users to switch on/off various library build types. @@ -95,8 +99,8 @@ option(PNG_EXECUTABLES "[Deprecated; please use PNG_TOOLS]" ON) if(NOT PNG_EXECUTABLES) message(DEPRECATION "The option PNG_EXECUTABLES has been deprecated in favour of PNG_TOOLS") if(PNG_TOOLS) - message(AUTHOR_WARNING - "Setting PNG_TOOLS to ${PNG_EXECUTABLES}, to stay compatible with PNG_EXECUTABLES") + message(AUTHOR_WARNING "Setting PNG_TOOLS to ${PNG_EXECUTABLES}, " + "to stay compatible with PNG_EXECUTABLES") set(PNG_TOOLS "${PNG_EXECUTABLES}") endif() endif() @@ -125,13 +129,11 @@ message(STATUS "Building for target architecture: ${PNG_TARGET_ARCHITECTURE}") option(PNG_BUILD_ZLIB "[Deprecated; please use ZLIB_ROOT]" OFF) if(PNG_BUILD_ZLIB) if("x${ZLIB_ROOT}" STREQUAL "x") - message(SEND_ERROR - "The option PNG_BUILD_ZLIB=${PNG_BUILD_ZLIB} is no longer supported; " - "please use ZLIB_ROOT instead") + message(SEND_ERROR "The option PNG_BUILD_ZLIB=${PNG_BUILD_ZLIB} is no longer supported; " + "please use ZLIB_ROOT instead") else() - message(SEND_ERROR - "The option PNG_BUILD_ZLIB=${PNG_BUILD_ZLIB} is no longer supported; " - "using ZLIB_ROOT=\"${ZLIB_ROOT}\"") + message(SEND_ERROR "The option PNG_BUILD_ZLIB=${PNG_BUILD_ZLIB} is no longer supported; " + "using ZLIB_ROOT=\"${ZLIB_ROOT}\"") endif() endif() @@ -157,15 +159,17 @@ if(PNG_HARDWARE_OPTIMIZATIONS) if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm|aarch)") if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm64|aarch64)") set(PNG_ARM_NEON_POSSIBLE_VALUES on off) - set(PNG_ARM_NEON "on" + set(PNG_ARM_NEON + "on" CACHE STRING "Enable ARM NEON optimizations: on|off; on is default") else() set(PNG_ARM_NEON_POSSIBLE_VALUES check on off) - set(PNG_ARM_NEON "off" + set(PNG_ARM_NEON + "off" CACHE STRING "Enable ARM NEON optimizations: check|on|off; off is default") endif() set_property(CACHE PNG_ARM_NEON - PROPERTY STRINGS ${PNG_ARM_NEON_POSSIBLE_VALUES}) + PROPERTY STRINGS ${PNG_ARM_NEON_POSSIBLE_VALUES}) list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index) if(index EQUAL -1) message(FATAL_ERROR "PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]") @@ -187,10 +191,11 @@ if(PNG_HARDWARE_OPTIMIZATIONS) # Set definitions and sources for PowerPC. if(PNG_TARGET_ARCHITECTURE MATCHES "^(powerpc|ppc64)") set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off) - set(PNG_POWERPC_VSX "on" + set(PNG_POWERPC_VSX + "on" CACHE STRING "Enable POWERPC VSX optimizations: on|off; on is default") set_property(CACHE PNG_POWERPC_VSX - PROPERTY STRINGS ${PNG_POWERPC_VSX_POSSIBLE_VALUES}) + PROPERTY STRINGS ${PNG_POWERPC_VSX_POSSIBLE_VALUES}) list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index) if(index EQUAL -1) message(FATAL_ERROR "PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]") @@ -209,10 +214,11 @@ if(PNG_HARDWARE_OPTIMIZATIONS) # Set definitions and sources for Intel. if(PNG_TARGET_ARCHITECTURE MATCHES "^(i[3-6]86|x86|amd64)") set(PNG_INTEL_SSE_POSSIBLE_VALUES on off) - set(PNG_INTEL_SSE "on" + set(PNG_INTEL_SSE + "on" CACHE STRING "Enable INTEL_SSE optimizations: on|off; on is default") set_property(CACHE PNG_INTEL_SSE - PROPERTY STRINGS ${PNG_INTEL_SSE_POSSIBLE_VALUES}) + PROPERTY STRINGS ${PNG_INTEL_SSE_POSSIBLE_VALUES}) list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index) if(index EQUAL -1) message(FATAL_ERROR "PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]") @@ -231,20 +237,22 @@ if(PNG_HARDWARE_OPTIMIZATIONS) # Set definitions and sources for MIPS. if(PNG_TARGET_ARCHITECTURE MATCHES "^(mipsel|mips64el)") set(PNG_MIPS_MSA_POSSIBLE_VALUES on off) - set(PNG_MIPS_MSA "on" + set(PNG_MIPS_MSA + "on" CACHE STRING "Enable MIPS_MSA optimizations: on|off; on is default") set_property(CACHE PNG_MIPS_MSA - PROPERTY STRINGS ${PNG_MIPS_MSA_POSSIBLE_VALUES}) + PROPERTY STRINGS ${PNG_MIPS_MSA_POSSIBLE_VALUES}) list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index_msa) if(index_msa EQUAL -1) message(FATAL_ERROR "PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]") endif() set(PNG_MIPS_MMI_POSSIBLE_VALUES on off) - set(PNG_MIPS_MMI "on" + set(PNG_MIPS_MMI + "on" CACHE STRING "Enable MIPS_MMI optimizations: on|off; on is default") set_property(CACHE PNG_MIPS_MMI - PROPERTY STRINGS ${PNG_MIPS_MMI_POSSIBLE_VALUES}) + PROPERTY STRINGS ${PNG_MIPS_MMI_POSSIBLE_VALUES}) list(FIND PNG_MIPS_MMI_POSSIBLE_VALUES ${PNG_MIPS_MMI} index_mmi) if(index_mmi EQUAL -1) message(FATAL_ERROR "PNG_MIPS_MMI must be one of [${PNG_MIPS_MMI_POSSIBLE_VALUES}]") @@ -279,25 +287,25 @@ if(PNG_HARDWARE_OPTIMIZATIONS) if(PNG_TARGET_ARCHITECTURE MATCHES "^(loongarch)") include(CheckCCompilerFlag) set(PNG_LOONGARCH_LSX_POSSIBLE_VALUES on off) - set(PNG_LOONGARCH_LSX "on" + set(PNG_LOONGARCH_LSX + "on" CACHE STRING "Enable LOONGARCH_LSX optimizations: on|off; on is default") set_property(CACHE PNG_LOONGARCH_LSX - PROPERTY STRINGS ${PNG_LOONGARCH_LSX_POSSIBLE_VALUES}) + PROPERTY STRINGS ${PNG_LOONGARCH_LSX_POSSIBLE_VALUES}) list(FIND PNG_LOONGARCH_LSX_POSSIBLE_VALUES ${PNG_LOONGARCH_LSX} index) if(index EQUAL -1) message(FATAL_ERROR "PNG_LOONGARCH_LSX must be one of [${PNG_LOONGARCH_LSX_POSSIBLE_VALUES}]") elseif(NOT PNG_LOONGARCH_LSX STREQUAL "off") - CHECK_C_COMPILER_FLAG("-mlsx" COMPILER_SUPPORTS_LSX) + check_c_compiler_flag("-mlsx" COMPILER_SUPPORTS_LSX) if(COMPILER_SUPPORTS_LSX) set(libpng_loongarch_sources loongarch/loongarch_lsx_init.c loongarch/filter_lsx_intrinsics.c) set_source_files_properties(${libpng_loongarch_sources} - PROPERTIES - COMPILE_FLAGS "-mlsx") + PROPERTIES COMPILE_FLAGS "-mlsx") add_definitions(-DPNG_LOONGARCH_LSX_OPT=1) else() - message(FATAL_ERROR "Compiler does not support -mlsx option") + message(FATAL_ERROR "This compiler does not support the -mlsx option") endif() else() add_definitions(-DPNG_LOONGARCH_LSX_OPT=0) @@ -346,7 +354,8 @@ VERS_2 { global: sym2; main; } VERS_1; # Solaris, because of an incompatibility with the Solaris link editor. list(APPEND CMAKE_REQUIRED_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS}) endif() - list(APPEND CMAKE_REQUIRED_FLAGS "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'") + list(APPEND CMAKE_REQUIRED_FLAGS + "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'") check_c_source_compiles(" void sym1(void) {} void sym2(void) {} @@ -399,8 +408,8 @@ elseif(NOT AWK) # Configure libpng with pnglibconf.h.prebuilt. png_check_libconf(HEADER "${PNG_LIBCONF_HEADER_PREBUILT}") configure_file("${PNG_LIBCONF_HEADER_PREBUILT}" - ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h - @ONLY) + ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h + @ONLY) add_custom_target(png_genfiles) else() png_check_libconf(DFA_XTRA "${DFA_XTRA}") @@ -457,14 +466,16 @@ else() # Generate pnglibconf.h generate_source(OUTPUT "pnglibconf.h" - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" pnglibconf_out + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" + pnglibconf_out ${PNGLIBCONF_H_EXTRA_DEPENDS}) add_custom_target(pnglibconf_h DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/intprefix.c" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out" - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" pnglibconf_h) + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" + pnglibconf_h) add_custom_target(png_scripts_intprefix_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out") @@ -472,7 +483,8 @@ else() OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" pnglibconf_out) + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" + pnglibconf_out) add_custom_target(png_scripts_prefix_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out") @@ -484,7 +496,8 @@ else() generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" pnglibconf_h) + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" + pnglibconf_h) add_custom_target(png_scripts_sym_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out") @@ -500,7 +513,8 @@ else() OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" pnglibconf_h) + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" + pnglibconf_h) add_custom_target(png_scripts_vers_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out") @@ -533,19 +547,32 @@ else() # A single target handles generation of all generated files. add_custom_target(png_genfiles - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym" png_gensym - "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers" png_genvers - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c" pnglibconf_c - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" pnglibconf_h - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" pnglibconf_out - "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h" pngprefix_h - "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out" png_scripts_intprefix_out - "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c" png_scripts_pnglibconf_c - "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" png_scripts_prefix_out - "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" png_scripts_sym_out - "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" png_scripts_symbols_chk - "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" png_scripts_symbols_out - "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" png_scripts_vers_out) + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym" + png_gensym + "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers" + png_genvers + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c" + pnglibconf_c + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" + pnglibconf_h + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" + pnglibconf_out + "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h" + pngprefix_h + "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out" + png_scripts_intprefix_out + "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c" + png_scripts_pnglibconf_c + "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" + png_scripts_prefix_out + "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" + png_scripts_sym_out + "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" + png_scripts_symbols_chk + "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" + png_scripts_symbols_out + "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" + png_scripts_vers_out) endif() # List the source code files. @@ -645,55 +672,60 @@ if(PNG_SHARED) add_library(png_shared SHARED ${libpng_sources}) add_dependencies(png_shared png_genfiles) list(APPEND PNG_LIBRARY_TARGETS png_shared) - set_target_properties(png_shared PROPERTIES - OUTPUT_NAME "${PNG_SHARED_OUTPUT_NAME}" - DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}" - VERSION "${PNGLIB_SHARED_VERSION}" - SOVERSION "${PNGLIB_ABI_VERSION}") + set_target_properties(png_shared + PROPERTIES OUTPUT_NAME "${PNG_SHARED_OUTPUT_NAME}" + DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}" + VERSION "${PNGLIB_SHARED_VERSION}" + SOVERSION "${PNGLIB_ABI_VERSION}") if(UNIX AND AWK) if(HAVE_LD_VERSION_SCRIPT) - set_target_properties(png_shared PROPERTIES - LINK_FLAGS "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'") + set_target_properties(png_shared + PROPERTIES LINK_FLAGS "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'") elseif(HAVE_SOLARIS_LD_VERSION_SCRIPT) - set_target_properties(png_shared PROPERTIES - LINK_FLAGS "-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'") + set_target_properties(png_shared + PROPERTIES LINK_FLAGS "-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'") endif() endif() if(APPLE) # Avoid CMake's implicit compile definition "png_shared_EXPORTS". - set_target_properties(png_shared PROPERTIES DEFINE_SYMBOL "") + set_target_properties(png_shared + PROPERTIES DEFINE_SYMBOL "") elseif(WIN32) # Use the explicit compile definition "PNG_BUILD_DLL" for Windows DLLs. - set_target_properties(png_shared PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL) + set_target_properties(png_shared + PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL) endif() target_include_directories(png_shared PUBLIC $) target_include_directories(png_shared PUBLIC $) - target_include_directories(png_shared SYSTEM + target_include_directories(png_shared + SYSTEM INTERFACE $) - target_link_libraries(png_shared PUBLIC ZLIB::ZLIB ${M_LIBRARY}) + target_link_libraries(png_shared + PUBLIC ZLIB::ZLIB ${M_LIBRARY}) endif() if(PNG_STATIC) add_library(png_static STATIC ${libpng_sources}) add_dependencies(png_static png_genfiles) list(APPEND PNG_LIBRARY_TARGETS png_static) - set_target_properties(png_static PROPERTIES - OUTPUT_NAME "${PNG_STATIC_OUTPUT_NAME}" - DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}") + set_target_properties(png_static + PROPERTIES OUTPUT_NAME "${PNG_STATIC_OUTPUT_NAME}" + DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}") target_include_directories(png_static PUBLIC $) target_include_directories(png_static PUBLIC $) - target_include_directories(png_static SYSTEM + target_include_directories(png_static + SYSTEM INTERFACE $) - target_link_libraries(png_static PUBLIC ZLIB::ZLIB ${M_LIBRARY}) + target_link_libraries(png_static + PUBLIC ZLIB::ZLIB ${M_LIBRARY}) endif() if(PNG_FRAMEWORK AND NOT APPLE) - message(AUTHOR_WARNING - "Setting PNG_FRAMEWORK to OFF, as it only applies to Apple systems") + message(AUTHOR_WARNING "Setting PNG_FRAMEWORK to OFF, as it only applies to Apple systems") set(PNG_FRAMEWORK OFF) endif() @@ -701,25 +733,28 @@ if(PNG_FRAMEWORK) add_library(png_framework SHARED ${libpng_sources}) add_dependencies(png_framework png_genfiles) list(APPEND PNG_LIBRARY_TARGETS png_framework) - set_target_properties(png_framework PROPERTIES - FRAMEWORK TRUE - FRAMEWORK_VERSION "${PNGLIB_VERSION}" - MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${PNGLIB_MAJOR}.${PNGLIB_MINOR}" - MACOSX_FRAMEWORK_BUNDLE_VERSION "${PNGLIB_VERSION}" - MACOSX_FRAMEWORK_IDENTIFIER "org.libpng.libpng" - XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" - PUBLIC_HEADER "${libpng_public_hdrs}" - OUTPUT_NAME "png" - DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}") + set_target_properties(png_framework + PROPERTIES FRAMEWORK TRUE + FRAMEWORK_VERSION "${PNGLIB_VERSION}" + MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${PNGLIB_MAJOR}.${PNGLIB_MINOR}" + MACOSX_FRAMEWORK_BUNDLE_VERSION "${PNGLIB_VERSION}" + MACOSX_FRAMEWORK_IDENTIFIER "org.libpng.libpng" + XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" + PUBLIC_HEADER "${libpng_public_hdrs}" + OUTPUT_NAME "png" + DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}") # Avoid CMake's implicit compile definition "-Dpng_framework_EXPORTS". - set_target_properties(png_framework PROPERTIES DEFINE_SYMBOL "") + set_target_properties(png_framework + PROPERTIES DEFINE_SYMBOL "") target_include_directories(png_framework PUBLIC $) target_include_directories(png_framework PUBLIC $) - target_include_directories(png_framework SYSTEM + target_include_directories(png_framework + SYSTEM INTERFACE $) - target_link_libraries(png_framework PUBLIC ZLIB::ZLIB ${M_LIBRARY}) + target_link_libraries(png_framework + PUBLIC ZLIB::ZLIB ${M_LIBRARY}) endif() if(NOT PNG_LIBRARY_TARGETS) @@ -746,7 +781,8 @@ if(PNG_TESTS AND PNG_SHARED) set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png") add_executable(pngtest ${pngtest_sources}) - target_link_libraries(pngtest PRIVATE png_shared) + target_link_libraries(pngtest + PRIVATE png_shared) png_add_test(NAME pngtest COMMAND pngtest @@ -757,7 +793,8 @@ if(PNG_TESTS AND PNG_SHARED) FILES "${TEST_PNG3_PNGS}") add_executable(pngvalid ${pngvalid_sources}) - target_link_libraries(pngvalid PRIVATE png_shared) + target_link_libraries(pngvalid + PRIVATE png_shared) png_add_test(NAME pngvalid-gamma-16-to-8 COMMAND pngvalid @@ -803,7 +840,8 @@ if(PNG_TESTS AND PNG_SHARED) OPTIONS --transform) add_executable(pngstest ${pngstest_sources}) - target_link_libraries(pngstest PRIVATE png_shared) + target_link_libraries(pngstest + PRIVATE png_shared) foreach(gamma_type 1.8 linear none sRGB) foreach(alpha_type none alpha) @@ -858,7 +896,8 @@ if(PNG_TESTS AND PNG_SHARED) endforeach() add_executable(pngunknown ${pngunknown_sources}) - target_link_libraries(pngunknown PRIVATE png_shared) + target_link_libraries(pngunknown + PRIVATE png_shared) png_add_test(NAME pngunknown-discard COMMAND pngunknown @@ -874,7 +913,8 @@ if(PNG_TESTS AND PNG_SHARED) FILES "${PNGTEST_PNG}") png_add_test(NAME pngunknown-sAPI COMMAND pngunknown - OPTIONS --strict bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save + OPTIONS --strict + bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save FILES "${PNGTEST_PNG}") png_add_test(NAME pngunknown-save COMMAND pngunknown @@ -890,7 +930,8 @@ if(PNG_TESTS AND PNG_SHARED) FILES "${PNGTEST_PNG}") add_executable(pngimage ${pngimage_sources}) - target_link_libraries(pngimage PRIVATE png_shared) + target_link_libraries(pngimage + PRIVATE png_shared) png_add_test(NAME pngimage-quick COMMAND pngimage @@ -904,11 +945,13 @@ endif() if(PNG_SHARED AND PNG_TOOLS) add_executable(pngfix ${pngfix_sources}) - target_link_libraries(pngfix PRIVATE png_shared) + target_link_libraries(pngfix + PRIVATE png_shared) set(PNG_BIN_TARGETS pngfix) add_executable(png-fix-itxt ${png_fix_itxt_sources}) - target_link_libraries(png-fix-itxt PRIVATE ZLIB::ZLIB ${M_LIBRARY}) + target_link_libraries(png-fix-itxt + PRIVATE ZLIB::ZLIB ${M_LIBRARY}) list(APPEND PNG_BIN_TARGETS png-fix-itxt) endif() @@ -922,12 +965,11 @@ function(create_symlink DEST_FILE) # CMake version 3.13. cmake_parse_arguments(_SYM "" "FILE;TARGET" "" ${ARGN}) if(NOT _SYM_FILE AND NOT _SYM_TARGET) - message(FATAL_ERROR "create_symlink: Missing FILE or TARGET argument") + message(FATAL_ERROR "create_symlink: Missing arguments: FILE or TARGET") endif() if(_SYM_FILE AND _SYM_TARGET) - message(FATAL_ERROR "create_symlink: " - "The arguments FILE (${_SYM_FILE}) and TARGET (${_SYM_TARGET}) " - "are mutually-exclusive") + message(FATAL_ERROR "create_symlink: Mutually-exlusive arguments:" + "FILE (${_SYM_FILE}) and TARGET (${_SYM_TARGET})") endif() if(_SYM_FILE) @@ -989,11 +1031,11 @@ endif() # Only do this on Windows for Cygwin - the files don't make much sense # outside of a UNIX look-alike. if(NOT WIN32 OR CYGWIN OR MINGW) - set(prefix ${CMAKE_INSTALL_PREFIX}) + set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix ${CMAKE_INSTALL_PREFIX}) - set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) - set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) - set(LIBS "-lz -lm") + set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) + set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) + set(LIBS "-lz -lm") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}.pc @ONLY)