685 Commits

Author SHA1 Message Date
John Bowler
d7d950e8bd [libpng16] chore: Clean up the leading blank lines from all source files
The leading blank lines are apparently an artefact of an older source
control system.  They are not required and they look like accidents,
because starting a source file with a blank line is not a regular habit
of software developers nowadays.

This is a cherry-pick of commit 37cc20add8fb5b83bb5299a26cd3b41e0f776017
from branch 'libpng18'.

Signed-off-by: John Bowler <jbowler@acm.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2024-10-11 11:51:04 +03:00
Cosmin Truta
642b5d81e3 [libpng16] build: Raise the minimum required CMake version to 3.14
Start using the features guaranteed to be available in CMake 3.14.
Specifically, use the ability of `find_package(ZLIB)` to pick up zlib
from the ZLIB_ROOT variable (if given).

This is a cherry-pick of commit 00343a761e41e56acaeb0517aec5325d3b951837
from branch 'libpng18'.
2024-10-06 21:54:21 +03:00
Cosmin Truta
ef153d5325 Bump version to 1.6.45.git 2024-09-14 11:46:34 +03:00
Cosmin Truta
f5e92d7697 Release libpng version 1.6.44 2024-09-12 23:44:44 +03:00
Green Sky
8cc22a8c15 cmake: Fix an error in the declaration of target include directories
Properly declare target include directories for generated includes.
Previously the non targeted `include_directories()` was used, which
had issue when using the `png_static` target in a submodule.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2024-09-10 23:50:55 +03:00
Cosmin Truta
843dbb7579 Revert "cmake: Fix an error in the declaration of target include directories"
This reverts commit 1d1cc9ae18f677201bf7e47928c30562df967756.

The verification has failed. (Oopsie!)
2024-09-10 22:41:03 +03:00
Green Sky
1d1cc9ae18 cmake: Fix an error in the declaration of target include directories
Properly declare target include directories for generated includes.
Previously the non targeted `include_directories()` was used, which
had issue when using the `png_static` target in a submodule.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2024-09-10 22:03:13 +03:00
Benjamin Buch
0e204b7364 build: Add a CMake config file compatible with the FindPNG module
Co-authored-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2024-09-08 21:57:37 +03:00
Cosmin Truta
33ef48b6d6 cmake: Fix the handling of PNG_HARDWARE_OPTIMIZATIONS on FreeBSD/amd64
Because of a missing "amd64" string (in lowercase) in a regex match,
the CMake build was unable to pick up the PNG_HARDWARE_OPTIMIZATIONS
flag on FreeBSD/amd64 (and possibly other amd64 systems as well).

Rename the target arch variable from TARGET_ARCH to a more idiomatic
PNG_TARGET_ARCHITECTURE, and set it to an always-lowercase string.
The follow-on checks are now simpler and easier to get right.
2024-09-04 18:32:03 +03:00
Ross Burton
9e538750d9 arm: Remove obsolete assembler implementation filter_neon.S
This file contains hand-coded assembler implementations of the filter
functions for 32-bit Arm platforms.  These are only used when the
compiler doesn't support neon intrinsics (added to GCC 4.3 in 2008) or
is exactly GCC 4.5.4 (released 2012), both of which are sufficiently
unlikely to be true that it's fair to say the assembler is no longer
used.

This commit deletes filter_neon.S and removes the now obsolete
preprocessor logic in pngpriv.h.

Signed-off-by: Bill Roberts <bill.roberts@arm.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2024-06-15 23:09:34 +03:00
John Bowler
ceed2a3cf6 SECURITY: disable build of filter_neon.S on arm
This fixes the bug https://github.com/pnggroup/libpng/issues/505
"libpng does not support PAC/BTI on aarch64 targets" which arises
because the build mechanisms (both cmake and configure) assemble
arm/filter_neon.S even though it ends up completely empty.  The empty
file effectively poisons the so that the PAC/BTI support gets disabled.

The fix is minimal; it simply removes arm/filter_neon.S from the list of
sources included in the 64-bit ARM builds build.  Note that this was
already done in cmake for MSVC - it's not clear whether this change was
a partial fix for the same issue.

This version of the fix ONLY affects aarch64 (arm64) builds; 32-bit ARM
systems can still invoke the assembler if required and, indeed, there
should be no change whatsover to those builds.

The assembler code could not be used on 64-bit systems in any case so
in practice there is no material change to 64-bit builds either.

TESTING: pull the changes then type "autoreconf" if using configure (not
required for cmake).

TESTS: cmake has not been tested because cross-builds with cmake
currently fail to find the zlib installation from the cmake system root
path.  The following has been tested with configure cross builds:

armv7-linux-gnueabi [no neon support]
armv7a-linux-gnueabi [no neon support]
armv7a-hardfloat-linux-gnueabi [neon support not enabled]
armv7a-hardfloat-linux-gnueabi -mfpu=neon [uses intrinics]
armv7a-hardfloat-linux-gnueabi -mfpu=neon
        -DPNG_ARM_NEON_IMPLEMENTATION=2 [uses assembler]
aarch64-linux-gnu [uses intrinsics]
aarch64-linux-gnu -DPNG_ARM_NEON_OPT=0 [neon support disabled]

Signed-off-by: John Bowler <jbowler@acm.org>
2024-05-31 10:18:28 -07:00
Cosmin Truta
f1848a3b56 Bump version to 1.6.44.git 2024-02-24 13:32:56 +02:00
Cosmin Truta
ed217e3e60 Release libpng version 1.6.43 2024-02-23 11:51:40 +02:00
Cosmin Truta
890231026d chore: Delete comments and config settings and stuff from here and there 2024-02-22 17:00:05 +02:00
Benjamin Buch
7b888092b9 build: Mark the installed libpng headers as system headers in CMake
Modern compilers can disable the warnings that originate from system
headers. This change allows them to do so with the libpng headers.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2024-02-21 23:26:07 +02:00
Cosmin Truta
d165a20ae4 build: Improve the search for an AWK processor in the CMake build
Add nawk to the list of AWK-processing programs that are known to work,
and show the search result in the CMake log.
2024-02-19 20:51:26 +02:00
Cosmin Truta
aa95dee697 build: Update the CMake build options PNG_TOOLS and PNG_FRAMEWORK
Update the PNG_TOOLS option: set it to OFF by default when the
target is an embedded system, yet still allow it to be overridden.

Update the PNG_FRAMEWORK option: force it back to OFF and print a
warning if the option was ON but the target is not an Apple system.
2024-02-19 14:25:55 +02:00
Dan Rosser
e7ba9c0dfc build: Fix a CMake build regression introduced in version 1.6.41
This fixes commit 4edbb4da81626a7342a22824d7a8f60a3ea71bd0.

During the move of CMake scripts to the scripts/cmake/ subdirectory,
some of the workflows have been broken.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2024-02-19 11:19:52 +02:00
Cosmin Truta
4191872d0d chore: Update the .editorconfig files and pacify editorconfig-checker 2024-02-15 18:29:26 +02:00
guxiwei
2aebfb4aa9 loongarch: Add cmake support 2024-02-01 21:17:37 +02:00
Cosmin Truta
4356cb0709 Bump version to 1.6.43.git 2024-01-31 11:32:51 +02:00
Cosmin Truta
ba980b8f0c Release libpng version 1.6.41 2024-01-24 18:59:00 +02:00
Cosmin Truta
4edbb4da81 build: Move scripts/*.cmake.in to scripts/cmake/; add cmake/AUTHORS.md
From the libpng licensing point of view, the build projects, the build
scripts, the test scripts, the CI verification scripts, et cetera, have
not traditionally been part of libpng proper, although some of these,
including the CMake-based build, have been released under the libpng
license.

Considering how the CMake build grew as a result of many contributions
from many contributing authors over a long time, one may argue that it
almost became an individual piece of software in its own right.

Moving on, everything CMake-related shall be placed in the subdirectory
scripts/cmake/ (except, of course, the main CMakeLists.txt). Moreover,
contributing authors shall be acknowledged in scripts/cmake/AUTHORS.md.

Please see scripts/cmake/README.md for more information.
2024-01-22 17:24:59 +02:00
gxw
ce4b632dd7 Optimize png16 with loongson mmi for 64-bit os 2024-01-17 22:46:16 +02:00
Cosmin Truta
85f866dea3 cmake: Enable policy CMP0074 for ZLIB_ROOT; deprecate PNG_BUILD_ZLIB
Although the minimum required CMake version is 3.6, this policy will
only have effect under CMake 3.12 or newer.

Reported-by: Jacob Harding <54728054+jacobharding@users.noreply.github.com>
2023-12-20 19:12:42 +02:00
Cosmin Truta
2fff013a69 cmake: Raise the minimum required version to 3.6 and use its features
Use the `CMAKE_HOST_SOLARIS` variable, introduced in CMake 3.6, and
raise `cmake_minimum_required` accordingly.
2023-12-13 20:24:33 +02:00
Cosmin Truta
acfd50ae0b cmake: Clean up functions, string operations, regular expressions, etc.
Remove the inclusion of the external module `CMakeParseArguments`.
Function argument parsing became a first-class feature in CMake 3.5.

Delete the function `find_symbol_prefix`. It is no longer used.

Use variables instead of strings in string operations where possible.
Prevent CMake from getting confused by string values that might be
accidentally identical to unrelated keywords.

Clean up spurious `.*` sequences in regex matching operations.

Rephrase a comment.
2023-12-11 20:51:06 +02:00
Cosmin Truta
8fc13a8704 cmake: Enable the libpng framework build by default on Apple systems
The PNG_FRAMEWORK option used to be off by default. It was possible to
turn it on, regardless of the underlying operating system, but doing so
outside of an Apple OS broke the libpng build.

PNG_FRAMEWORK is now on by default, conditionally defined on Apple
systems only, and it is ignored (without breaking the build) elsewhere.

Other minor changes have also been applied.
2023-12-08 23:22:39 +02:00
Timothy Lyanguzov
1460b3ce78 cmake: Use Zlib as a package
1. automatic linking of the library and add include directory
2. properly specify include directories

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-12-08 14:57:36 +02:00
Cosmin Truta
e1088f99d4 Redo "cmake: Fix CPU architecture regexes"
Co-authored-by: Clinton Ingram <clinton.ingram@outlook.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-12-07 23:17:56 +02:00
Cosmin Truta
d65b3ebf00 Revert "cmake: Fix CPU architecture regexes"
This reverts commit 9c1dc4d13dab823d6441d417546ebeee3994389b.

The new regex for Intel can match "x86_64", but it fails with "x86".
Moreover, the new regex for MIPS needs more testing on all MIPS ISAs.

Reported-by: Clinton Ingram <clinton.ingram@outlook.com>
2023-12-07 23:17:56 +02:00
Clinton Ingram
a3d1a35b98 cmake: Don't add Unix ASM file to the ARM-specific source list for MSVC
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-12-07 16:11:12 +02:00
Cosmin Truta
9c1dc4d13d cmake: Fix CPU architecture regexes
Co-authored-by: Clinton Ingram <clinton.ingram@outlook.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-12-07 16:11:12 +02:00
Timothy Lyanguzov
f2294569cf Use CMake 3.5 features
1. Set `cmake_minimum_required` to 3.5
   (see https://cmake.org/cmake/help/latest/release/3.27.html)
2. Specify the version of CMake project
3. Remove the redundant call to `cmake_policy`
4. Use `CMAKE_INSTALL_BINDIR` and `CMAKE_INSTALL_INCLUDEDIR`
5. Use private library linking for tools and test programs
6. Don't activate testing if it was not enabled

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-10-02 23:24:00 +03:00
Tyler Kropp
1547b335e4 cmake: Fix copying targets on Windows in multi-config build systems
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-10-02 00:00:03 +03:00
Cosmin Truta
b2ef6edbe8 cmake: Rename PNG_EXECUTABLES to PNG_TOOLS
For the sake of consistency with a recent addition to the configure
script, the option name PNG_EXECUTABLES (introduced in libpng-1.6.38)
shall become PNG_TOOLS.

PNG_EXECUTABLES is still maintained as a deprecated option, allowing
the applications that use it to be built without modification, but a
deprecation warning will be issued.
2023-08-03 21:08:29 +03:00
Cosmin Truta
d7f77bf271 Bump version to 1.6.41.git 2023-06-26 11:09:17 +03:00
Cosmin Truta
f135775ad4 Release libpng version 1.6.40 2023-06-21 22:06:40 +03:00
Cosmin Truta
afc6c595bf Fix a build regression on Solaris
Fix a regression introduced in commit aeb26da4cb64c0e75c8d.

On an Illumos test machine, running the GCC compiler and the Solaris
link editor, the CMake build failed with the following error:

    ld: fatal: unrecognized option '--version-script=/.../libpng.vers'

The fix consists in avoiding the use of CMAKE_SHARED_LIBRARY_C_FLAGS
in version script checks on Solaris.

Also clean up the surrounding code, as follows:
 * Rename CMAKE_REQUIRED_FLAGS_SAVE to _SAVED_CMAKE_REQUIRED_FLAGS.
   (The name of an internal variable should not begin with "CMAKE_".)
 * Reformat the version script to optimize the vertical space.
2023-06-21 21:08:40 +03:00
Cosmin Truta
e519af8b49 cmake: Allow overwriting the debug postfix of library filenames
Users may opt to change the debug suffix, e.g., from "d" to "_debug".

Rather than making CMAKE_DEBUG_POSTFIX a cache variable (which is
an antipattern in CMake), we introduce a new cache variable, named
PNG_DEBUG_POSTFIX.

Suggested-by: Diego Barrios Romero <eldruin@gmail.com>
2023-02-12 22:31:11 +02:00
Cosmin Truta
efc96c9d59 cmake: Redo the fix for Clang support on Windows
Redo commit 70fda1837d5de802ce5f7e04be239192b6a74d92, with a redesign.

Define the variables PNG_SHARED_OUTPUT_NAME and PNG_STATIC_OUTPUT_NAME
for the benefit of the OUTPUT_NAME target properties of, respectively,
the shared libpng build and the static libpng build. Fix and improve
not only Clang, but also other Windows toolchains, such as Embarcadero.

Rename the variable PNGLIB_SHARED_SOVERSION to PNG_ABI_VERSION.
The applicability of this variable, which is much wider than the old
name used to suggest, includes the definitions of PNG_*_OUTPUT_NAME.

Delete the confusingly-named variables PNGLIB_NAME and PNG_LIB_NAME,
and rename PNG_LIB_TARGETS to PNG_LIBRARY_TARGETS.

Set the macros _CRT_SECURE_NO_DEPRECATE and _CRT_NONSTDC_NO_DEPRECATE,
for all compilers that use MSVC run-time library headers. Currently,
these compilers are MSVC and Clang/Windows.

Add or improve the comments that accompany user-serviceable variables
and options.

Co-authored-by: B. Scott Michel <scooter.phd@gmail.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-02-12 17:22:08 +02:00
Cosmin Truta
aab24fa1b3 Clean up CMakeLists.txt
* Rename the target `png` to `png_shared`. The main targets are now
   named `png_shared`, `png_static` and `png_framework`.
 * Rename the function symbol_prefix() to find_symbol_prefix().
 * Rename the prefix `S` to `_SYM` in the function create_symlink().
 * Rewrite the precondition checks in the function create_symlink().
 * Add precondition checks to the function generate_copy().
 * Delete the vestigial property CLEAN_DIRECT_OUTPUT.
 * Delete the variables PNG_LIB_NAME_STATIC and PNG_LIB_NAME_FRAMEWORK.
 * Initialize and use PNG_LIB_TARGETS consistently as a list.
 * Move all include() commands to the top of the file.
 * Acknowledge a former contributor.
 * Reformat.
2023-02-08 19:44:31 +02:00
Jeremy Maitin-Shepard
efa9c2e920 cmake: Rename the custom targets to have the png_ prefix
This avoids taget namespace pollution when including libpng as a
sub-project.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-02-08 17:10:52 +02:00
Cosmin Truta
c22ef3b2e3 Revert "cmake: Fix the Clang support on Windows"
This reverts commit 70fda1837d5de802ce5f7e04be239192b6a74d92.

Fixing Clang on Windows is important. However, in the previous fix,
the name of the compiled libpng library file was changed, incorrectly,
on all platforms except Windows. A proper fix will follow up.
2023-02-07 17:49:06 +02:00
B. Scott Michel
70fda1837d cmake: Fix the Clang support on Windows
Fix a build error that occurs with the Ninja code generator and the
Clang compiler on Windows:

    ninja: error: build.ninja: multiple rules generate png16.lib

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-02-03 16:32:32 +02:00
Gunther Nikl
aeb26da4cb cmake: Use CMAKE_SHARED_LIBRARY_C_FLAGS in version script checks
Building the version script test executable may fail in the link step
with GNU ld as linker like this:

  ld: final link failed: Nonrepresentable section on output

Building the test excutable with CMAKE_SHARED_LIBRARY_C_FLAGS makes the
test succeed with GNU ld since this adds -fpic/-fPIC.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-01-31 22:25:23 +02:00
Jon Creighton
cd0ea2a7f5 Fix for universal binaries on macOS
Fix the issue of a
    clang: error: no such file or directory: 'x86_64'
error on building universal binaries on macOS.

It is also necessary to specify:
    -DCMAKE_C_FLAGS="-DPNG_ARM_NEON_OPT=0"

Example CMake command:
    cmake -S libpng \
          -B build_libpng \
          -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
          -DCMAKE_C_FLAGS="-DPNG_ARM_NEON_OPT=0"

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-01-09 19:55:04 +02:00
Cosmin Truta
3c761b5135 Bump version to 1.6.40.git 2022-11-27 13:10:35 +02:00
Cosmin Truta
07b8803110 Release libpng version 1.6.39 2022-11-20 23:53:23 +02:00
Martin Storsjö
e56f79c0c6 cmake: Default to PNG_ARM_NEON=off for arm targets
This matches the configure script - unless the user has requested
anything, no hardware optimizations are autoenabled.

Defaulting to "check" is brittle (that configuration is deprecated
and poorly supported) - and for configurations where it would
make sense (where NEON isn't universally enabled in the compiler)
it didn't end up setting ARM_NEON_OPT to 1 in pnglibconf.h anyway.

This fixes default builds with cmake for iOS and Windows on armv7,
where NEON is universally available (but there's no runtime check
implemented) - but actually using NEON on this architecture
requires explicitly opting in to it when configuring, just like
with the configure script.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2022-10-12 12:35:33 +03:00