From 3c761b51359abdb6b80a101f0f21e7579cedceef Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 27 Nov 2022 13:10:35 +0200 Subject: Bump version to 1.6.40.git --- ANNOUNCE | 8 ++++++++ CHANGES | 2 ++ CMakeLists.txt | 6 +++--- README | 4 ++-- configure | 24 ++++++++++++------------ configure.ac | 6 +++--- png.c | 4 ++-- png.h | 16 ++++++++-------- pngconf.h | 2 +- pngtest.c | 2 +- scripts/libpng-config-head.in | 2 +- scripts/libpng.pc.in | 2 +- scripts/pnglibconf.h.prebuilt | 2 +- 13 files changed, 45 insertions(+), 35 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 5675b973a..49b342a3c 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,3 +1,11 @@ +libpng 1.6.40.git +================= + +This is a development version, not intended to be a public release. +It will be replaced by a public release, or by another development +version, at a later time. + + libpng 1.6.39 - November 20, 2022 ================================= diff --git a/CHANGES b/CHANGES index 366e0f6a7..a5d897edf 100644 --- a/CHANGES +++ b/CHANGES @@ -6121,6 +6121,8 @@ Version 1.6.39 [November 20, 2022] removed the obsolete makefile.cegcc. Cleaned up the code and updated the internal documentation. +Version 1.6.40 [TODO] + Send comments/corrections/commendations to png-mng-implement at lists.sf.net. Subscription is required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement diff --git a/CMakeLists.txt b/CMakeLists.txt index 86e0affc4..24739fe1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,9 +33,9 @@ enable_testing() set(PNGLIB_MAJOR 1) set(PNGLIB_MINOR 6) -set(PNGLIB_REVISION 39) -set(PNGLIB_SUBREVISION 0) -#set(PNGLIB_SUBREVISION "git") +set(PNGLIB_REVISION 40) +#set(PNGLIB_SUBREVISION 0) +set(PNGLIB_SUBREVISION "git") set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_REVISION}) set(PNGLIB_SHARED_SOVERSION ${PNGLIB_MAJOR}${PNGLIB_MINOR}) diff --git a/README b/README index 097a3c218..0ef765487 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ -README for libpng version 1.6.39 -================================ +README for libpng version 1.6.40.git +==================================== See the note about version numbers near the top of png.h. See INSTALL for instructions on how to install libpng. diff --git a/configure b/configure index 8ad4092ca..ec68f7ca8 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71 for libpng 1.6.39. +# Generated by GNU Autoconf 2.71 for libpng 1.6.40.git. # # Report bugs to . # @@ -621,8 +621,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libpng' PACKAGE_TARNAME='libpng' -PACKAGE_VERSION='1.6.39' -PACKAGE_STRING='libpng 1.6.39' +PACKAGE_VERSION='1.6.40.git' +PACKAGE_STRING='libpng 1.6.40.git' PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net' PACKAGE_URL='' @@ -1411,7 +1411,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libpng 1.6.39 to adapt to many kinds of systems. +\`configure' configures libpng 1.6.40.git to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1482,7 +1482,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libpng 1.6.39:";; + short | recursive ) echo "Configuration of libpng 1.6.40.git:";; esac cat <<\_ACEOF @@ -1663,7 +1663,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libpng configure 1.6.39 +libpng configure 1.6.40.git generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. @@ -1919,7 +1919,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libpng $as_me 1.6.39, which was +It was created by libpng $as_me 1.6.40.git, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw @@ -3196,7 +3196,7 @@ fi # Define the identity of the package. PACKAGE='libpng' - VERSION='1.6.39' + VERSION='1.6.40.git' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -3328,10 +3328,10 @@ fi -PNGLIB_VERSION=1.6.39 +PNGLIB_VERSION=1.6.40.git PNGLIB_MAJOR=1 PNGLIB_MINOR=6 -PNGLIB_RELEASE=39 +PNGLIB_RELEASE=40 @@ -14894,7 +14894,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libpng $as_me 1.6.39, which was +This file was extended by libpng $as_me 1.6.40.git, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14962,7 +14962,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -libpng config.status 1.6.39 +libpng config.status 1.6.40.git configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 986c77470..75f145ef4 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ AC_PREREQ([2.68]) dnl Version number stuff here: -AC_INIT([libpng],[1.6.39],[png-mng-implement@lists.sourceforge.net]) +AC_INIT([libpng],[1.6.40.git],[png-mng-implement@lists.sourceforge.net]) AC_CONFIG_MACRO_DIR([scripts]) # libpng does not follow GNU file name conventions (hence 'foreign') @@ -46,10 +46,10 @@ dnl automake, so the following is not necessary (and is not defined anyway): dnl AM_PREREQ([1.11.2]) dnl stop configure from automagically running automake -PNGLIB_VERSION=1.6.39 +PNGLIB_VERSION=1.6.40.git PNGLIB_MAJOR=1 PNGLIB_MINOR=6 -PNGLIB_RELEASE=39 +PNGLIB_RELEASE=40 dnl End of version number stuff diff --git a/png.c b/png.c index 4f3e8bbd3..a0b82039a 100644 --- a/png.c +++ b/png.c @@ -14,7 +14,7 @@ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_39 Your_png_h_is_not_version_1_6_39; +typedef png_libpng_version_1_6_40_git Your_png_h_is_not_version_1_6_40_git; #ifdef __GNUC__ /* The version tests may need to be added to, but the problem warning has @@ -815,7 +815,7 @@ png_get_copyright(png_const_structrp png_ptr) return PNG_STRING_COPYRIGHT #else return PNG_STRING_NEWLINE \ - "libpng version 1.6.39" PNG_STRING_NEWLINE \ + "libpng version 1.6.40.git" PNG_STRING_NEWLINE \ "Copyright (c) 2018-2022 Cosmin Truta" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \ PNG_STRING_NEWLINE \ diff --git a/png.h b/png.h index f109cdf33..d85427b8d 100644 --- a/png.h +++ b/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.6.39 - November 20, 2022 + * libpng version 1.6.40.git * * Copyright (c) 2018-2022 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson @@ -278,8 +278,8 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.6.39" -#define PNG_HEADER_VERSION_STRING " libpng version 1.6.39 - November 20, 2022\n" +#define PNG_LIBPNG_VER_STRING "1.6.40.git" +#define PNG_HEADER_VERSION_STRING " libpng version 1.6.40.git\n" #define PNG_LIBPNG_VER_SONUM 16 #define PNG_LIBPNG_VER_DLLNUM 16 @@ -287,12 +287,12 @@ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 6 -#define PNG_LIBPNG_VER_RELEASE 39 +#define PNG_LIBPNG_VER_RELEASE 40 /* This should be zero for a public release, or non-zero for a * development version. [Deprecated] */ -#define PNG_LIBPNG_VER_BUILD 0 +#define PNG_LIBPNG_VER_BUILD 1 /* Release Status */ #define PNG_LIBPNG_BUILD_ALPHA 1 @@ -309,7 +309,7 @@ #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with PNG_LIBPNG_BUILD_PRIVATE */ -#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE +#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA /* Careful here. At one time, Guy wanted to use 082, but that * would be octal. We must not include leading zeros. @@ -318,7 +318,7 @@ * From version 1.0.1 it is: * XXYYZZ, where XX=major, YY=minor, ZZ=release */ -#define PNG_LIBPNG_VER 10639 /* 1.6.39 */ +#define PNG_LIBPNG_VER 10640 /* 1.6.40.git */ /* Library configuration: these options cannot be changed after * the library has been built. @@ -428,7 +428,7 @@ extern "C" { /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef char* png_libpng_version_1_6_39; +typedef char* png_libpng_version_1_6_40_git; /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. * diff --git a/pngconf.h b/pngconf.h index fcb4b4306..74bfe27ce 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine-configurable file for libpng * - * libpng version 1.6.39 + * libpng version 1.6.40.git * * Copyright (c) 2018-2022 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson diff --git a/pngtest.c b/pngtest.c index 542ee9593..2fec7f74c 100644 --- a/pngtest.c +++ b/pngtest.c @@ -2155,4 +2155,4 @@ main(void) #endif /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_39 Your_png_h_is_not_version_1_6_39; +typedef png_libpng_version_1_6_40_git Your_png_h_is_not_version_1_6_40_git; diff --git a/scripts/libpng-config-head.in b/scripts/libpng-config-head.in index 57874b7bc..bc24b7bc7 100644 --- a/scripts/libpng-config-head.in +++ b/scripts/libpng-config-head.in @@ -11,7 +11,7 @@ # Modeled after libxml-config. -version=1.6.39 +version=1.6.40.git prefix="" libdir="" libs="" diff --git a/scripts/libpng.pc.in b/scripts/libpng.pc.in index 2cb84475d..b6e30ebd7 100644 --- a/scripts/libpng.pc.in +++ b/scripts/libpng.pc.in @@ -5,6 +5,6 @@ includedir=@includedir@/libpng16 Name: libpng Description: Loads and saves PNG files -Version: 1.6.39 +Version: 1.6.40.git Libs: -L${libdir} -lpng16 Cflags: -I${includedir} diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt index e5948c8ce..7497e7ff4 100644 --- a/scripts/pnglibconf.h.prebuilt +++ b/scripts/pnglibconf.h.prebuilt @@ -1,6 +1,6 @@ /* pnglibconf.h - library build configuration */ -/* libpng version 1.6.39 */ +/* libpng version 1.6.40.git */ /* Copyright (c) 2018-2022 Cosmin Truta */ /* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */ -- cgit v1.2.3 From b126f8071012fd57938e30385194ae1f4424413e Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 27 Nov 2022 16:20:31 +0200 Subject: Reorganize and update the README file; add Markdown formatting --- README | 160 ++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 79 insertions(+), 81 deletions(-) diff --git a/README b/README index 0ef765487..0fdc9b784 100644 --- a/README +++ b/README @@ -1,110 +1,108 @@ README for libpng version 1.6.40.git ==================================== -See the note about version numbers near the top of png.h. -See INSTALL for instructions on how to install libpng. - -Libpng comes in several distribution formats. Get libpng-*.tar.gz or -libpng-*.tar.xz if you want UNIX-style line endings in the text files, -or lpng*.7z or lpng*.zip if you want DOS-style line endings. - -Version 0.89 was the first official release of libpng. Don't let the -fact that it's the first release fool you. The libpng library has been -in extensive use and testing since mid-1995. By late 1997 it had -finally gotten to the stage where there hadn't been significant -changes to the API in some time, and people have a bad feeling about -libraries with versions < 1.0. Version 1.0.0 was released in -March 1998. - -**** -Note that some of the changes to the png_info structure render this -version of the library binary incompatible with libpng-0.89 or -earlier versions if you are using a shared library. The type of the -"filler" parameter for png_set_filler() has changed from png_byte to -png_uint_32, which will affect shared-library applications that use -this function. +See the note about version numbers near the top of `png.h`. +See `INSTALL` for instructions on how to install libpng. -To avoid problems with changes to the internals of the png info_struct, -new APIs have been made available in 0.95 to avoid direct application -access to info_ptr. These functions are the png_set_ and -png_get_ functions. These functions should be used when -accessing/storing the info_struct data, rather than manipulating it -directly, to avoid such problems in the future. +Libpng comes in several distribution formats. Get `libpng-*.tar.gz` +or `libpng-*.tar.xz` if you want UNIX-style line endings in the text +files, or `lpng*.7z` or `lpng*.zip` if you want DOS-style line endings. -It is important to note that the APIs did not make current programs -that access the info struct directly incompatible with the new -library, through libpng-1.2.x. In libpng-1.4.x, which was meant to -be a transitional release, members of the png_struct and the -info_struct can still be accessed, but the compiler will issue a -warning about deprecated usage. Since libpng-1.5.0, direct access -to these structs is not allowed, and the definitions of the structs -reside in private pngstruct.h and pnginfo.h header files that are not -accessible to applications. It is strongly suggested that new -programs use the new APIs (as shown in example.c and pngtest.c), and -older programs be converted to the new format, to facilitate upgrades -in the future. -**** - -Additions since 0.90 include the ability to compile libpng as a -Windows DLL, and new APIs for accessing data in the info struct. -Experimental functions include the ability to set weighting and cost -factors for row filter selection, direct reads of integers from buffers -on big-endian processors that support misaligned data access, faster -methods of doing alpha composition, and more accurate 16->8 bit color -conversion. +For a detailed description on using libpng, read `libpng-manual.txt`. +For examples of libpng in a program, see `example.c` and `pngtest.c`. +For usage information and restrictions (what little they are) on libpng, +see `png.h`. For a description on using zlib (the compression library +used by libpng) and zlib's restrictions, see `zlib.h`. -The additions since 0.89 include the ability to read from a PNG stream -which has had some (or all) of the signature bytes read by the calling -application. This also allows the reading of embedded PNG streams that -do not have the PNG file signature. As well, it is now possible to set -the library action on the detection of chunk CRC errors. It is possible -to set different actions based on whether the CRC error occurred in a -critical or an ancillary chunk. - -For a detailed description on using libpng, read libpng-manual.txt. -For examples of libpng in a program, see example.c and pngtest.c. For -usage information and restrictions (what little they are) on libpng, -see png.h. For a description on using zlib (the compression library -used by libpng) and zlib's restrictions, see zlib.h - -I have included a general makefile, as well as several machine and -compiler specific ones, but you may have to modify one for your own -needs. - -You should use zlib 1.0.4 or later to run this, but it MAY work with +You should use zlib 1.0.4 or later to run this, but it _may_ work with versions as old as zlib 0.95. Even so, there are bugs in older zlib versions which can cause the output of invalid compression streams for some images. You should also note that zlib is a compression library that is useful for more things than just PNG files. You can use zlib as a drop-in -replacement for fread() and fwrite(), if you are so inclined. +replacement for `fread()` and `fwrite()`, if you are so inclined. zlib should be available at the same place that libpng is, or at -https://zlib.net. +https://zlib.net . You may also want a copy of the PNG specification. It is available as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find these at http://www.libpng.org/pub/png/pngdocs.html . -This code is currently being archived at libpng.sourceforge.io in the -[DOWNLOAD] area, and at http://libpng.download/src . +This code is currently being archived at https://libpng.sourceforge.io +in the download area, and at http://libpng.download/src . This release, based in a large way on Glenn's, Guy's and Andreas' earlier work, was created and will be supported by myself and the PNG development group. -Send comments/corrections/commendations to png-mng-implement at -lists.sourceforge.net (subscription required; visit +Send comments, corrections and commendations to `png-mng-implement` +at `lists.sourceforge.net`. (Subscription is required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe). +to subscribe.) + +Send general questions about the PNG specification to `png-mng-misc` +at `lists.sourceforge.net`. (Subscription is required; visit +https://lists.sourceforge.net/lists/listinfo/png-mng-misc +to subscribe.) + +Historical notes +---------------- -Send general questions about the PNG specification to png-mng-misc -at lists.sourceforge.net (subscription required; visit -https://lists.sourceforge.net/lists/listinfo/png-mng-misc to -subscribe). +The libpng library has been in extensive use and testing since mid-1995. +Version 0.89, published a year later, was the first official release. +By late 1997, it had finally gotten to the stage where there hadn't +been significant changes to the API in some time, and people have a bad +feeling about libraries with versions below 1.0. Version 1.0.0 was +released in March 1998. + +Note that some of the changes to the `png_info` structure render this +version of the library binary incompatible with libpng-0.89 or +earlier versions if you are using a shared library. The type of the +`filler` parameter for `png_set_filler()` has changed from `png_byte` +to `png_uint_32`, which will affect shared-library applications that +use this function. + +To avoid problems with changes to the internals of the `info_struct`, +new APIs have been made available in 0.95 to avoid direct application +access to `info_ptr`. These functions are the `png_set_` and +`png_get_` functions. These functions should be used when +accessing/storing the `info_struct` data, rather than manipulating it +directly, to avoid such problems in the future. + +It is important to note that the APIs did not make current programs +that access the info struct directly incompatible with the new +library, through libpng-1.2.x. In libpng-1.4.x, which was meant to +be a transitional release, members of the `png_struct` and the +`info_struct` can still be accessed, but the compiler will issue a +warning about deprecated usage. Since libpng-1.5.0, direct access +to these structs is not allowed, and the definitions of the structs +reside in private `pngstruct.h` and `pnginfo.h` header files that are +not accessible to applications. It is strongly suggested that new +programs use the new APIs (as shown in `example.c` and `pngtest.c`), +and older programs be converted to the new format, to facilitate +upgrades in the future. + +The additions since 0.89 include the ability to read from a PNG stream +which has had some (or all) of the signature bytes read by the calling +application. This also allows the reading of embedded PNG streams that +do not have the PNG file signature. As well, it is now possible to set +the library action on the detection of chunk CRC errors. It is possible +to set different actions based on whether the CRC error occurred in a +critical or an ancillary chunk. + +The additions since 0.90 include the ability to compile libpng as a +Windows DLL, and new APIs for accessing data in the `info_struct`. +Experimental functions included the ability to set weighting and cost +factors for row filter selection, direct reads of integers from buffers +on big-endian processors that support misaligned data access, faster +methods of doing alpha composition, and more accurate 16-to-8 bit color +conversion. Some of these experimental functions, such as the weighted +filter heuristics, have since been removed. -Files in this distribution: +Files included in this distribution +----------------------------------- ANNOUNCE => Announcement of this version, with recent changes AUTHORS => List of contributing authors @@ -153,7 +151,7 @@ Files in this distribution: arm-neon/ => Optimized code for the ARM-NEON platform mips-msa/ => Optimized code for the MIPS-MSA platform powerpc-vsx/ => Optimized code for the POWERPC-VSX platform - examples/ => Example programs + examples/ => Examples of libpng usage gregbook/ => Source code for PNG reading and writing, from "PNG: The Definitive Guide" by Greg Roelofs, O'Reilly, 1999 -- cgit v1.2.3 From 5a0b7e9c29ec23f87c601622cb2db01781a6cbba Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 27 Nov 2022 16:20:31 +0200 Subject: manuals: Remove references to libpngpf(3); update links From libpng-1.5.0 onwards, the private libpng functions are no longer accessible to the libpng users, and the content of libpngpf(3) is no longer relevant. Update links, introducing the new canonical location of the libpng source repository: https://github.com/pnggroup/libpng --- libpng.3 | 40 +++++++++++++++------------------------- png.5 | 31 +++---------------------------- 2 files changed, 18 insertions(+), 53 deletions(-) diff --git a/libpng.3 b/libpng.3 index 2ea6af3b4..04ae7db83 100644 --- a/libpng.3 +++ b/libpng.3 @@ -5995,35 +5995,25 @@ letter, until version 1.0.6j; from then on they were given the upcoming public release number plus "betaNN" or "rcNN". .SH "SEE ALSO" -.IR libpngpf(3) ", " png(5) -.LP -.IR libpng : +.BR "png"(5) .IP -https://libpng.sourceforge.io/ (follow the [DOWNLOAD] link) -http://www.libpng.org/pub/png - +The PNG (Portable Network Graphics) format specification. .LP -.IR zlib : +.B libpng .IP -(generally) at the same location as -.I libpng -or at +http://www.libpng.org/pub/png/libpng.html (canonical home page) .br -https://zlib.net/ - +https://github.com/pnggroup/libpng (canonical Git repository) +.br +https://libpng.sourceforge.io (downloadable archives) .LP -.IR PNG specification: RFC 2083 +.B zlib .IP -(generally) at the same location as -.I libpng -or at +https://zlib.net (canonical home page) .br -https://www.ietf.org/rfc/rfc2083.txt +https://github.com/madler/zlib (canonical Git repository) .br -or (as a W3C Recommendation) at -.br -https://www.w3.org/TR/REC-png.html - +A copy of zlib may also be found at the same location as libpng. .LP In the case of any inconsistency between the PNG specification and this library, the specification takes precedence. @@ -6043,10 +6033,10 @@ Libpng: Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Maintained by Cosmin Truta. -Supported by the PNG development group +Supported by the PNG development group. .br -png-mng-implement at lists.sourceforge.net (subscription required; visit -https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe). +png-mng-implement at lists.sourceforge.net. (Subscription is required; +visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement +to subscribe.) .\" end of man page diff --git a/png.5 b/png.5 index 20e6aa70a..9b36f0a0b 100644 --- a/png.5 +++ b/png.5 @@ -18,7 +18,7 @@ Also, PNG can store gamma and chromaticity data for improved color matching on heterogeneous platforms. .SH "SEE ALSO" -.BR "libpng"(3), " libpngpf"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5) +.BR "libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5) .LP PNG Specification (Second Edition), November 2003: .IP @@ -51,34 +51,9 @@ Portable Network Graphics (PNG): Functional specification. ISO/IEC 15948:2003 (E) (November 10, 2003): David Duce and others. .LP Portable Network Graphics (PNG) Specification Version 1.2 (July 8, 1999): -Glenn Randers-Pehrson and others (png-list). +Glenn Randers-Pehrson and others. .LP Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996): -Thomas Boutell and others (png-list). +Thomas Boutell and others. -.SH COPYRIGHT -.LP -This man page is -.br -Copyright (c) 2018 Cosmin Truta. -.br -Copyright (c) 1998-2006 Glenn Randers-Pehrson. -.br -See png.h for conditions of use and distribution. -.LP -The PNG Specification (Second Edition) is -.br -Copyright (c) 2003 W3C. (MIT, ERCIM, Keio), All Rights Reserved. -.LP -The PNG-1.2 Specification is -.br -Copyright (c) 1999 Glenn Randers-Pehrson. -.br -See the specification for conditions of use and distribution. -.LP -The PNG-1.0 Specification is -.br -Copyright (c) 1996 Massachusetts Institute of Technology. -.br -See the specification for conditions of use and distribution. .\" end of man page -- cgit v1.2.3 From 3c152a8ef76535744b4e3926693645d28f1b1969 Mon Sep 17 00:00:00 2001 From: musvaage Date: Tue, 20 Sep 2022 17:15:49 -0500 Subject: Fix typos Signed-off-by: Cosmin Truta --- CHANGES | 10 +++++----- autogen.sh | 2 +- contrib/libtests/makepng.c | 2 +- contrib/libtests/pngstest.c | 2 +- contrib/libtests/pngvalid.c | 4 ++-- contrib/libtests/tarith.c | 2 +- contrib/pngminus/LICENSE.txt | 2 +- contrib/tools/pngfix.c | 2 +- contrib/visupng/VisualPng.c | 2 +- pngpriv.h | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CHANGES b/CHANGES index a5d897edf..6018ea0f7 100644 --- a/CHANGES +++ b/CHANGES @@ -204,7 +204,7 @@ Version 0.97 [January, 1998] Added simple sRGB support (Glenn R-P) Easier conditional compiling, e.g., define PNG_READ/WRITE_NOT_FULLY_SUPPORTED; - all configurable options can be selected from command-line instead + all configurable options can be selected from command line instead of having to edit pngconf.h (Glenn R-P) Fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P) Added more conditions for png_do_background, to avoid changing @@ -942,7 +942,7 @@ Version 1.0.8 [July 24, 2000] Version 1.0.9beta1 [November 10, 2000] Fixed typo in scripts/makefile.hpux Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser) - Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser) + Fixed sequence-point bug in contrib/pngminus/png2pnm (Martin Zinser) Changed "cdrom.com" in documentation to "libpng.org" Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg). Changed type of "params" from voidp to png_voidp in png_read|write_png(). @@ -2295,7 +2295,7 @@ Version 1.4.0beta58 [May 14, 2009] Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri) Version 1.4.0beta59 [May 15, 2009] - Reformated sources in libpng style (3-space indentation, comment format) + Reformatted sources in libpng style (3-space indentation, comment format) Fixed typo in libpng docs (PNG_FILTER_AVE should be PNG_FILTER_AVG) Added sections about the git repository and our coding style to the documentation @@ -2661,7 +2661,7 @@ Version 1.4.1beta06 [January 28, 2010] Version 1.4.1beta07 [February 6, 2010] Folded some long lines in the source files. - Added defineable PNG_USER_CHUNK_CACHE_MAX, PNG_USER_CHUNK_MALLOC_MAX, + Added definable PNG_USER_CHUNK_CACHE_MAX, PNG_USER_CHUNK_MALLOC_MAX, and a PNG_USER_LIMITS_SUPPORTED flag. Eliminated use of png_ptr->irowbytes and reused the slot in png_ptr as png_ptr->png_user_chunk_malloc_max. @@ -3919,7 +3919,7 @@ Version 1.6.0beta08 [February 1, 2012] version checking to configure.ac Improved pngstest speed by not doing redundant tests and add const to the background parameter of png_image_finish_read. The --background - option is now done automagically only when required, so that commandline + option is now done automagically only when required, so that command-line option no longer exists. Cleaned up pngpriv.h to consistently declare all functions and data. Also eliminated PNG_CONST_DATA, which is apparently not needed but we diff --git a/autogen.sh b/autogen.sh index a46daf65a..9c8830a6e 100755 --- a/autogen.sh +++ b/autogen.sh @@ -77,7 +77,7 @@ libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in config.sub configure depcomp install-sh ltmain.sh missing\ test-driver" # -# Files generated by versions of configue >2.68 or automake >1.13 (i.e. later +# Files generated by versions of autoconf >2.68 or automake >1.13 (i.e. later # versions than those required by configure.ac): libpng_autotools_extra="compile config.h.in~" # diff --git a/contrib/libtests/makepng.c b/contrib/libtests/makepng.c index e911c06e1..a866fc1d1 100644 --- a/contrib/libtests/makepng.c +++ b/contrib/libtests/makepng.c @@ -496,7 +496,7 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type, case 32: case 48: case 64: - /* The rows are filled by an alogorithm similar to the above, in the + /* The rows are filled by an algorithm similar to the above, in the * first row pixel bytes are all equal, increasing from 0 by 1 for * each pixel. In the second row the bytes within a pixel are * incremented 1,3,5,7,... from the previous row byte. Using an odd diff --git a/contrib/libtests/pngstest.c b/contrib/libtests/pngstest.c index cd4f3cd2d..973e60f52 100644 --- a/contrib/libtests/pngstest.c +++ b/contrib/libtests/pngstest.c @@ -1151,7 +1151,7 @@ get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb) * * 2) Remove color by mapping to grayscale. (Grayscale to color is a no-op.) * - * 3) Convert between 8-bit and 16-bit components. (Both directtions are + * 3) Convert between 8-bit and 16-bit components. (Both directions are * relevant.) * * This gives the following base format conversion matrix: diff --git a/contrib/libtests/pngvalid.c b/contrib/libtests/pngvalid.c index 49eed5c29..6a7422e88 100644 --- a/contrib/libtests/pngvalid.c +++ b/contrib/libtests/pngvalid.c @@ -6719,7 +6719,7 @@ transform_range_check(png_const_structp pp, unsigned int r, unsigned int g, unsigned int out, png_byte sample_depth, double err, double limit, const char *name, double digitization_error) { - /* Compare the scaled, digitzed, values of our local calculation (in+-err) + /* Compare the scaled, digitized, values of our local calculation (in+-err) * with the digitized values libpng produced; 'sample_depth' is the actual * digitization depth of the libpng output colors (the bit depth except for * palette images where it is always 8.) The check on 'err' is to detect @@ -9065,7 +9065,7 @@ image_transform_reset_count(void) static int image_transform_test_counter(png_uint_32 counter, unsigned int max) { - /* Test the list to see if there is any point contining, given a current + /* Test the list to see if there is any point continuing, given a current * counter and a 'max' value. */ image_transform *next = image_transform_first; diff --git a/contrib/libtests/tarith.c b/contrib/libtests/tarith.c index ead77e9a5..e35b7ab26 100644 --- a/contrib/libtests/tarith.c +++ b/contrib/libtests/tarith.c @@ -952,7 +952,7 @@ int validation_gamma(int argc, char **argv) /**************************** VALIDATION TESTS ********************************/ /* Various validation routines are included herein, they require some - * definition for png_warning and png_error, seetings of VALIDATION: + * definition for png_warning and png_error, settings of VALIDATION: * * 1: validates the ASCII to floating point conversions * 2: validates png_muldiv diff --git a/contrib/pngminus/LICENSE.txt b/contrib/pngminus/LICENSE.txt index 00878a9a6..a8d413728 100644 --- a/contrib/pngminus/LICENSE.txt +++ b/contrib/pngminus/LICENSE.txt @@ -16,7 +16,7 @@ copies or substantial portions of the Software. The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the -authors or copyight holders be liable for any claim, damages or other +authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. diff --git a/contrib/tools/pngfix.c b/contrib/tools/pngfix.c index 54a467daf..cdf3f1cb4 100644 --- a/contrib/tools/pngfix.c +++ b/contrib/tools/pngfix.c @@ -867,7 +867,7 @@ struct file * signature (in length,type). * * When a chunk control structure is instantiated these values are copied - * into the structure and can then be overritten with the data for the next + * into the structure and can then be overwritten with the data for the next * chunk. */ fpos_t data_pos; /* Position of first byte of chunk data */ diff --git a/contrib/visupng/VisualPng.c b/contrib/visupng/VisualPng.c index 6baa3b663..6f7b1dfe5 100644 --- a/contrib/visupng/VisualPng.c +++ b/contrib/visupng/VisualPng.c @@ -103,7 +103,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, return 0; } - /* if filename given on commandline, store it */ + /* if filename given on command line, store it */ if ((szCmdLine != NULL) && (*szCmdLine != '\0')) if (szCmdLine[0] == '"') strncpy (szCmdFileName, szCmdLine + 1, strlen(szCmdLine) - 2); diff --git a/pngpriv.h b/pngpriv.h index b8a73b685..75411d967 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -1910,7 +1910,7 @@ PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr, */ #define PNG_FP_INVALID 512 /* Available for callers as a distinct value */ -/* Result codes for the parser (boolean - true meants ok, false means +/* Result codes for the parser (boolean - true means ok, false means * not ok yet.) */ #define PNG_FP_MAYBE 0 /* The number may be valid in the future */ -- cgit v1.2.3 From b445aade83e55bb62095e7efdcfd38b540609750 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 27 Nov 2022 21:05:42 +0200 Subject: ci: Rename the ci_* scripts Give the CI scripts new names that better reflect what they do, and make room for activities such as linting or dependency installation: * Rename ci_autotools.sh to ci_verify_configure.sh. * Rename ci_cmake.sh to ci_verify_cmake.sh. * Rename ci_legacy.sh to ci_verify_makefiles.sh. Also rename CI_LEGACY_MAKEFILES to CI_MAKEFILES. Update the config files for Travis CI and AppVeyor CI accordingly. --- .appveyor.yml | 18 ++--- .travis.yml | 14 ++-- ci/ci_autotools.sh | 117 -------------------------------- ci/ci_cmake.sh | 169 ---------------------------------------------- ci/ci_legacy.sh | 147 ---------------------------------------- ci/ci_verify_cmake.sh | 169 ++++++++++++++++++++++++++++++++++++++++++++++ ci/ci_verify_configure.sh | 117 ++++++++++++++++++++++++++++++++ ci/ci_verify_makefiles.sh | 147 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 449 insertions(+), 449 deletions(-) delete mode 100755 ci/ci_autotools.sh delete mode 100755 ci/ci_cmake.sh delete mode 100755 ci/ci_legacy.sh create mode 100755 ci/ci_verify_cmake.sh create mode 100755 ci/ci_verify_configure.sh create mode 100755 ci/ci_verify_makefiles.sh diff --git a/.appveyor.yml b/.appveyor.yml index 88dc11ef3..f447877fe 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -28,16 +28,16 @@ environment: AUTOMATION: cmake ARCH: x86_64 - TOOLCHAIN: msys2 - AUTOMATION: autotools + AUTOMATION: configure ARCH: i686 - TOOLCHAIN: msys2 - AUTOMATION: autotools + AUTOMATION: configure ARCH: x86_64 - TOOLCHAIN: msys2 - AUTOMATION: legacy + AUTOMATION: makefiles ARCH: i686 - TOOLCHAIN: msys2 - AUTOMATION: legacy + AUTOMATION: makefiles ARCH: x86_64 install: @@ -57,13 +57,13 @@ before_build: - 'set CI_CMAKE_BUILD_FLAGS=--parallel 2' - 'set CI_CTEST_FLAGS=--parallel 2' - 'set CI_MAKE_FLAGS=-j2' - - 'set CI_LEGACY_MAKEFILES=scripts/makefile.gcc scripts/makefile.msys scripts/makefile.std' + - 'set CI_MAKEFILES=scripts/makefile.gcc scripts/makefile.msys scripts/makefile.std' build_script: - - 'if "%TOOLCHAIN%"=="vstudio" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_cmake.sh"' - - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="cmake" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_cmake.sh"' - - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="autotools" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_autotools.sh"' - - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="legacy" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_legacy.sh"' + - 'if "%TOOLCHAIN%"=="vstudio" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_cmake.sh"' + - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="cmake" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_cmake.sh"' + - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="configure" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_configure.sh"' + - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="makefiles" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_makefiles.sh"' cache: - C:\tools\vcpkg\installed diff --git a/.travis.yml b/.travis.yml index 70457cd39..c48df0876 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,11 +17,11 @@ env: - AUTOMATION=cmake CI_NO_TEST=1 - AUTOMATION=cmake CI_CMAKE_VARS="-DPNG_HARDWARE_OPTIMIZATIONS=ON" CI_SANITIZERS="address,undefined" - AUTOMATION=cmake CI_CMAKE_VARS="-DPNG_HARDWARE_OPTIMIZATIONS=OFF" CI_SANITIZERS="address,undefined" - - AUTOMATION=autotools CI_NO_TEST=1 - - AUTOMATION=autotools CI_CONFIGURE_FLAGS="--enable-hardware-optimizations" - - AUTOMATION=autotools CI_CONFIGURE_FLAGS="--disable-hardware-optimizations" - - AUTOMATION=legacy CI_NO_TEST=1 - - AUTOMATION=legacy CI_SANITIZERS="address,undefined" + - AUTOMATION=configure CI_NO_TEST=1 + - AUTOMATION=configure CI_CONFIGURE_FLAGS="--enable-hardware-optimizations" + - AUTOMATION=configure CI_CONFIGURE_FLAGS="--disable-hardware-optimizations" + - AUTOMATION=makefiles CI_NO_TEST=1 + - AUTOMATION=makefiles CI_SANITIZERS="address,undefined" matrix: include: @@ -39,7 +39,7 @@ before_script: - 'export CI_CTEST_FLAGS="--parallel 2"' - 'export CI_MAKE_FLAGS=-j2' - 'export CI_CC=$TRAVIS_COMPILER' - - 'export CI_LEGACY_MAKEFILES="scripts/makefile.$TRAVIS_COMPILER scripts/makefile.std"' + - 'export CI_MAKEFILES="scripts/makefile.$TRAVIS_COMPILER scripts/makefile.std"' script: - - './ci/ci_$AUTOMATION.sh' + - './ci/ci_verify_$AUTOMATION.sh' diff --git a/ci/ci_autotools.sh b/ci/ci_autotools.sh deleted file mode 100755 index 0728540bd..000000000 --- a/ci/ci_autotools.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env bash -set -e - -# ci_autotools.sh -# Continuously integrate libpng using the GNU Autotools. -# -# Copyright (c) 2019-2022 Cosmin Truta. -# -# This software is released under the libpng license. -# For conditions of distribution and use, see the disclaimer -# and license in png.h. - -CI_SCRIPTNAME="$(basename "$0")" -CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" -CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" -CI_BUILDDIR="$CI_SRCDIR/out/autotools.build" -CI_INSTALLDIR="$CI_SRCDIR/out/autotools.install" - -function ci_info { - printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*" -} - -function ci_err { - printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*" - exit 2 -} - -function ci_spawn { - printf >&2 "%s: executing:" "$CI_SCRIPTNAME" - printf >&2 " %q" "$@" - printf >&2 "\\n" - "$@" -} - -function ci_init_autotools { - CI_SYSTEM_NAME="$(uname -s)" - CI_MACHINE_NAME="$(uname -m)" - CI_MAKE="${CI_MAKE:-make}" - # Set CI_CC to cc by default, if the cc command is available. - # The configure script defaults CC to gcc, which is not always a good idea. - [[ -x $(command -v cc) ]] && CI_CC="${CI_CC:-cc}" - # Ensure that the CI_ variables that cannot be customized reliably are not initialized. - [[ ! $CI_CONFIGURE_VARS ]] || ci_err "unexpected: \$CI_CONFIGURE_VARS='$CI_CONFIGURE_VARS'" - [[ ! $CI_MAKE_VARS ]] || ci_err "unexpected: \$CI_MAKE_VARS='$CI_MAKE_VARS'" -} - -function ci_trace_autotools { - ci_info "## START OF CONFIGURATION ##" - ci_info "system name: $CI_SYSTEM_NAME" - ci_info "machine hardware name: $CI_MACHINE_NAME" - ci_info "source directory: $CI_SRCDIR" - ci_info "build directory: $CI_BUILDDIR" - ci_info "install directory: $CI_INSTALLDIR" - ci_info "environment option: \$CI_CONFIGURE_FLAGS: '$CI_CONFIGURE_FLAGS'" - ci_info "environment option: \$CI_MAKE: '$CI_MAKE'" - ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'" - ci_info "environment option: \$CI_CC: '$CI_CC'" - ci_info "environment option: \$CI_CC_FLAGS: '$CI_CC_FLAGS'" - ci_info "environment option: \$CI_CPP: '$CI_CPP'" - ci_info "environment option: \$CI_CPP_FLAGS: '$CI_CPP_FLAGS'" - ci_info "environment option: \$CI_AR: '$CI_AR'" - ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'" - ci_info "environment option: \$CI_LD: '$CI_LD'" - ci_info "environment option: \$CI_LD_FLAGS: '$CI_LD_FLAGS'" - ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'" - ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'" - ci_info "environment option: \$CI_NO_INSTALL: '$CI_NO_INSTALL'" - ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'" - ci_info "executable: \$CI_MAKE: $(command -V "$CI_MAKE")" - [[ $CI_CC ]] && - ci_info "executable: \$CI_CC: $(command -V "$CI_CC")" - [[ $CI_CPP ]] && - ci_info "executable: \$CI_CPP: $(command -V "$CI_CPP")" - [[ $CI_AR ]] && - ci_info "executable: \$CI_AR: $(command -V "$CI_AR")" - [[ $CI_RANLIB ]] && - ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")" - [[ $CI_LD ]] && - ci_info "executable: \$CI_LD: $(command -V "$CI_LD")" - ci_info "## END OF CONFIGURATION ##" -} - -function ci_build_autotools { - ci_info "## START OF BUILD ##" - # Export the configure build environment. - [[ $CI_CC ]] && ci_spawn export CC="$CI_CC" - [[ $CI_CC_FLAGS ]] && ci_spawn export CFLAGS="$CI_CC_FLAGS" - [[ $CI_CPP ]] && ci_spawn export CPP="$CI_CPP" - [[ $CI_CPP_FLAGS ]] && ci_spawn export CPPFLAGS="$CI_CPP_FLAGS" - [[ $CI_AR ]] && ci_spawn export AR="$CI_AR" - [[ $CI_RANLIB ]] && ci_spawn export RANLIB="$CI_RANLIB" - [[ $CI_LD ]] && ci_spawn export CPP="$CI_LD" - [[ $CI_LD_FLAGS ]] && ci_spawn export LDFLAGS="$CI_LD_FLAGS" - [[ $CI_SANITIZERS ]] && { - ci_spawn export CFLAGS="-fsanitize=$CI_SANITIZERS ${CFLAGS:-"-O2"}" - ci_spawn export LDFLAGS="-fsanitize=$CI_SANITIZERS $LDFLAGS" - } - # Build and install. - ci_spawn rm -fr "$CI_BUILDDIR" "$CI_INSTALLDIR" - ci_spawn mkdir -p "$CI_BUILDDIR" - ci_spawn cd "$CI_BUILDDIR" - ci_spawn "$CI_SRCDIR/configure" --prefix="$CI_INSTALLDIR" $CI_CONFIGURE_FLAGS - ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS - [[ $CI_NO_TEST ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS test - [[ $CI_NO_INSTALL ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS install - [[ $CI_NO_CLEAN ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS clean - [[ $CI_NO_CLEAN ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS distclean - ci_info "## END OF BUILD ##" -} - -ci_init_autotools -ci_trace_autotools -[[ $# -eq 0 ]] || { - ci_info "note: this program accepts environment options only" - ci_err "unexpected command arguments: '$*'" -} -ci_build_autotools diff --git a/ci/ci_cmake.sh b/ci/ci_cmake.sh deleted file mode 100755 index 71af270da..000000000 --- a/ci/ci_cmake.sh +++ /dev/null @@ -1,169 +0,0 @@ -#!/usr/bin/env bash -set -e - -# ci_cmake.sh -# Continuously integrate libpng using CMake. -# -# Copyright (c) 2019-2022 Cosmin Truta. -# -# This software is released under the libpng license. -# For conditions of distribution and use, see the disclaimer -# and license in png.h. - -CI_SCRIPTNAME="$(basename "$0")" -CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" -CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" -CI_BUILDDIR="$CI_SRCDIR/out/cmake.build" -CI_INSTALLDIR="$CI_SRCDIR/out/cmake.install" - -function ci_info { - printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*" -} - -function ci_err { - printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*" - exit 2 -} - -function ci_spawn { - printf >&2 "%s: executing:" "$CI_SCRIPTNAME" - printf >&2 " %q" "$@" - printf >&2 "\\n" - "$@" -} - -function ci_init_cmake { - CI_SYSTEM_NAME="$(uname -s)" - CI_MACHINE_NAME="$(uname -m)" - CI_CMAKE="${CI_CMAKE:-cmake}" - CI_CTEST="${CI_CTEST:-ctest}" - CI_CMAKE_BUILD_TYPE="${CI_CMAKE_BUILD_TYPE:-Release}" - [[ -x $(command -v ninja) ]] && CI_CMAKE_GENERATOR="${CI_CMAKE_GENERATOR:-Ninja}" - if [[ $CI_CMAKE_GENERATOR == "Visual Studio"* ]] - then - # Initialize the CI_...DIR_NATIVE variables, for the benefit of - # the native Windows build tools. The regular CI_...DIR variables - # can only be used inside Bash-on-Windows. - mkdir -p "$CI_BUILDDIR" - mkdir -p "$CI_INSTALLDIR" - if [[ -x $CYGPATH ]] - then - CI_SRCDIR_NATIVE="$("$CYGPATH" -w "$CI_SRCDIR")" - CI_BUILDDIR_NATIVE="$("$CYGPATH" -w "$CI_BUILDDIR")" - CI_INSTALLDIR_NATIVE="$("$CYGPATH" -w "$CI_INSTALLDIR")" - else - CI_SRCDIR_NATIVE="$(cd "$CI_SRCDIR" ; pwd -W || pwd -P)" - CI_BUILDDIR_NATIVE="$(cd "$CI_BUILDDIR" ; pwd -W || pwd -P)" - CI_INSTALLDIR_NATIVE="$(cd "$CI_INSTALLDIR" ; pwd -W || pwd -P)" - fi - # Clean up incidental mixtures of Windows and Bash-on-Windows - # environment variables, to avoid confusing MSBuild. - [[ $TEMP && ( $Temp || $temp ) ]] && unset TEMP - [[ $TMP && ( $Tmp || $tmp ) ]] && unset TMP - # Ensure that CI_CMAKE_GENERATOR_PLATFORM is initialized for this generator. - [[ $CI_CMAKE_GENERATOR_PLATFORM ]] || ci_err "missing: \$CI_CMAKE_GENERATOR_PLATFORM" - fi -} - -function ci_trace_cmake { - ci_info "## START OF CONFIGURATION ##" - ci_info "system name: $CI_SYSTEM_NAME" - ci_info "machine hardware name: $CI_MACHINE_NAME" - ci_info "source directory: $CI_SRCDIR" - [[ $CI_SRCDIR_NATIVE ]] && - ci_info "source directory (native): $CI_SRCDIR_NATIVE" - ci_info "build directory: $CI_BUILDDIR" - [[ $CI_BUILDDIR_NATIVE ]] && - ci_info "build directory (native): $CI_BUILDDIR_NATIVE" - ci_info "install directory: $CI_INSTALLDIR" - [[ $CI_INSTALLDIR_NATIVE ]] && - ci_info "install directory (native): $CI_INSTALLDIR_NATIVE" - ci_info "environment option: \$CI_CMAKE: '$CI_CMAKE'" - ci_info "environment option: \$CI_CMAKE_GENERATOR: '$CI_CMAKE_GENERATOR'" - ci_info "environment option: \$CI_CMAKE_GENERATOR_PLATFORM: '$CI_CMAKE_GENERATOR_PLATFORM'" - ci_info "environment option: \$CI_CMAKE_BUILD_TYPE: '$CI_CMAKE_BUILD_TYPE'" - ci_info "environment option: \$CI_CMAKE_BUILD_FLAGS: '$CI_CMAKE_BUILD_FLAGS'" - ci_info "environment option: \$CI_CMAKE_VARS: '$CI_CMAKE_VARS'" - ci_info "environment option: \$CI_CTEST: '$CI_CTEST'" - ci_info "environment option: \$CI_CTEST_FLAGS: '$CI_CTEST_FLAGS'" - ci_info "environment option: \$CI_CC: '$CI_CC'" - ci_info "environment option: \$CI_CC_FLAGS: '$CI_CC_FLAGS'" - ci_info "environment option: \$CI_AR: '$CI_AR'" - ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'" - ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'" - ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'" - ci_info "environment option: \$CI_NO_INSTALL: '$CI_NO_INSTALL'" - ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'" - ci_info "executable: \$CI_CMAKE: $(command -V "$CI_CMAKE")" - ci_info "executable: \$CI_CTEST: $(command -V "$CI_CTEST")" - [[ $CI_CMAKE_GENERATOR == *"Ninja"* ]] && - ci_info "executable: $(command -V ninja)" - [[ $CI_CC ]] && - ci_info "executable: \$CI_CC: $(command -V "$CI_CC")" - [[ $CI_AR ]] && - ci_info "executable: \$CI_AR: $(command -V "$CI_AR")" - [[ $CI_RANLIB ]] && - ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")" - ci_info "## END OF CONFIGURATION ##" -} - -function ci_build_cmake { - ci_info "## START OF BUILD ##" - ci_spawn "$(command -v "$CI_CMAKE")" --version - ci_spawn "$(command -v "$CI_CTEST")" --version - # Initialize ALL_CC_FLAGS as a string. - local ALL_CC_FLAGS="$CI_CC_FLAGS" - [[ $CI_SANITIZERS ]] && ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_CC_FLAGS" - # Initialize ALL_CMAKE_VARS, ALL_CMAKE_BUILD_FLAGS and ALL_CTEST_FLAGS as arrays. - local -a ALL_CMAKE_VARS=() - [[ $CI_CC ]] && ALL_CMAKE_VARS+=(-DCMAKE_C_COMPILER="$CI_CC") - [[ $ALL_CC_FLAGS ]] && ALL_CMAKE_VARS+=(-DCMAKE_C_FLAGS="$ALL_CC_FLAGS") - [[ $CI_AR ]] && ALL_CMAKE_VARS+=(-DCMAKE_AR="$CI_AR") - [[ $CI_RANLIB ]] && ALL_CMAKE_VARS+=(-DCMAKE_RANLIB="$CI_RANLIB") - ALL_CMAKE_VARS+=(-DCMAKE_BUILD_TYPE="$CI_CMAKE_BUILD_TYPE") - ALL_CMAKE_VARS+=(-DCMAKE_VERBOSE_MAKEFILE=ON) - [[ $CI_NO_TEST ]] && ALL_CMAKE_VARS+=(-DPNG_TESTS=OFF) - ALL_CMAKE_VARS+=($CI_CMAKE_VARS) - local -a ALL_CMAKE_BUILD_FLAGS=($CI_CMAKE_BUILD_FLAGS) - local -a ALL_CTEST_FLAGS=($CI_CTEST_FLAGS) - # Initialize SRCDIR_NATIVE and INSTALLDIR_NATIVE. - local SRCDIR_NATIVE="${CI_SRCDIR_NATIVE:-"$CI_SRCDIR"}" - local INSTALLDIR_NATIVE="${CI_INSTALLDIR_NATIVE:-"$CI_INSTALLDIR"}" - # Export the CMake environment variables. - [[ $CI_CMAKE_GENERATOR ]] && - ci_spawn export CMAKE_GENERATOR="$CI_CMAKE_GENERATOR" - [[ $CI_CMAKE_GENERATOR_PLATFORM ]] && - ci_spawn export CMAKE_GENERATOR_PLATFORM="$CI_CMAKE_GENERATOR_PLATFORM" - # Build and install. - ci_spawn rm -fr "$CI_BUILDDIR" "$CI_INSTALLDIR" - ci_spawn mkdir -p "$CI_BUILDDIR" - ci_spawn cd "$CI_BUILDDIR" - ci_spawn "$CI_CMAKE" "${ALL_CMAKE_VARS[@]}" \ - -DCMAKE_INSTALL_PREFIX="$INSTALLDIR_NATIVE" \ - "$SRCDIR_NATIVE" - ci_spawn "$CI_CMAKE" --build . \ - --config "$CI_CMAKE_BUILD_TYPE" \ - "${ALL_CMAKE_BUILD_FLAGS[@]}" - [[ $CI_NO_TEST ]] || - ci_spawn "$CI_CTEST" --build-config "$CI_CMAKE_BUILD_TYPE" \ - "${ALL_CTEST_FLAGS[@]}" - [[ $CI_NO_INSTALL ]] || - ci_spawn "$CI_CMAKE" --build . \ - --config "$CI_CMAKE_BUILD_TYPE" \ - --target install \ - "${ALL_CMAKE_BUILD_FLAGS[@]}" - [[ $CI_NO_CLEAN ]] || - ci_spawn "$CI_CMAKE" --build . \ - --config "$CI_CMAKE_BUILD_TYPE" \ - --target clean \ - "${ALL_CMAKE_BUILD_FLAGS[@]}" - ci_info "## END OF BUILD ##" -} - -ci_init_cmake -ci_trace_cmake -[[ $# -eq 0 ]] || { - ci_info "note: this program accepts environment options only" - ci_err "unexpected command arguments: '$*'" -} -ci_build_cmake diff --git a/ci/ci_legacy.sh b/ci/ci_legacy.sh deleted file mode 100755 index cfe1f53a3..000000000 --- a/ci/ci_legacy.sh +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env bash -set -e - -# ci_legacy.sh -# Continuously integrate libpng using the legacy makefiles. -# -# Copyright (c) 2019-2022 Cosmin Truta. -# -# This software is released under the libpng license. -# For conditions of distribution and use, see the disclaimer -# and license in png.h. - -CI_SCRIPTNAME="$(basename "$0")" -CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" -CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" -CI_BUILDDIR="$CI_SRCDIR" - -function ci_info { - printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*" -} - -function ci_err { - printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*" - exit 2 -} - -function ci_spawn { - printf >&2 "%s: executing:" "$CI_SCRIPTNAME" - printf >&2 " %q" "$@" - printf >&2 "\\n" - "$@" -} - -function ci_init_legacy { - CI_SYSTEM_NAME="$(uname -s)" - CI_MACHINE_NAME="$(uname -m)" - CI_MAKE="${CI_MAKE:-make}" - case "$CI_SYSTEM_NAME" in - ( Darwin | *BSD | DragonFly ) - [[ -x $(command -v clang) ]] && CI_CC="${CI_CC:-clang}" ;; - ( * ) - [[ -x $(command -v gcc) ]] && CI_CC="${CI_CC:-gcc}" ;; - esac - CI_CC="${CI_CC:-cc}" - case "$CI_CC" in - ( *clang* ) - CI_LEGACY_MAKEFILES="${CI_LEGACY_MAKEFILES:-"scripts/makefile.clang"}" ;; - ( *gcc* ) - CI_LEGACY_MAKEFILES="${CI_LEGACY_MAKEFILES:-"scripts/makefile.gcc"}" ;; - ( cc | c89 | c99 ) - CI_LEGACY_MAKEFILES="${CI_LEGACY_MAKEFILES:-"scripts/makefile.std"}" ;; - esac - CI_LD="${CI_LD:-"$CI_CC"}" - CI_LIBS="${CI_LIBS:-"-lz -lm"}" -} - -function ci_trace_legacy { - ci_info "## START OF CONFIGURATION ##" - ci_info "system name: $CI_SYSTEM_NAME" - ci_info "machine hardware name: $CI_MACHINE_NAME" - ci_info "source directory: $CI_SRCDIR" - ci_info "build directory: $CI_BUILDDIR" - ci_info "environment option: \$CI_LEGACY_MAKEFILES: '$CI_LEGACY_MAKEFILES'" - ci_info "environment option: \$CI_MAKE: '$CI_MAKE'" - ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'" - ci_info "environment option: \$CI_MAKE_VARS: '$CI_MAKE_VARS'" - ci_info "environment option: \$CI_CC: '$CI_CC'" - ci_info "environment option: \$CI_CC_FLAGS: '$CI_CC_FLAGS'" - ci_info "environment option: \$CI_CPP: '$CI_CPP'" - ci_info "environment option: \$CI_CPP_FLAGS: '$CI_CPP_FLAGS'" - ci_info "environment option: \$CI_AR: '$CI_AR'" - ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'" - ci_info "environment option: \$CI_LD: '$CI_LD'" - ci_info "environment option: \$CI_LD_FLAGS: '$CI_LD_FLAGS'" - ci_info "environment option: \$CI_LIBS: '$CI_LIBS'" - ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'" - ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'" - ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'" - ci_info "executable: \$CI_MAKE: $(command -V "$CI_MAKE")" - [[ $CI_CC ]] && - ci_info "executable: \$CI_CC: $(command -V "$CI_CC")" - [[ $CI_CPP ]] && - ci_info "executable: \$CI_CPP: $(command -V "$CI_CPP")" - [[ $CI_AR ]] && - ci_info "executable: \$CI_AR: $(command -V "$CI_AR")" - [[ $CI_RANLIB ]] && - ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")" - [[ $CI_LD ]] && - ci_info "executable: \$CI_LD: $(command -V "$CI_LD")" - ci_info "## END OF CONFIGURATION ##" -} - -function ci_build_legacy { - ci_info "## START OF BUILD ##" - # Initialize ALL_CC_FLAGS and ALL_LD_FLAGS as strings. - local ALL_CC_FLAGS="$CI_CC_FLAGS" - local ALL_LD_FLAGS="$CI_LD_FLAGS" - [[ $CI_SANITIZERS ]] && { - ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS ${ALL_CC_FLAGS:-"-O2"}" - ALL_LD_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_LD_FLAGS" - } - # Initialize ALL_MAKE_FLAGS and ALL_MAKE_VARS as arrays. - local -a ALL_MAKE_FLAGS=($CI_MAKE_FLAGS) - local -a ALL_MAKE_VARS=() - [[ $CI_CC ]] && ALL_MAKE_VARS+=(CC="$CI_CC") - [[ $ALL_CC_FLAGS ]] && ALL_MAKE_VARS+=(CFLAGS="$ALL_CC_FLAGS") - [[ $CI_CPP ]] && ALL_MAKE_VARS+=(CPP="$CI_CPP") - [[ $CI_CPP_FLAGS ]] && ALL_MAKE_VARS+=(CPPFLAGS="$CI_CPP_FLAGS") - [[ $CI_AR ]] && ALL_MAKE_VARS+=( - AR="${CI_AR:-ar}" - AR_RC="${CI_AR:-ar} rc" - ) - [[ $CI_RANLIB ]] && ALL_MAKE_VARS+=(RANLIB="$CI_RANLIB") - [[ $CI_LD ]] && ALL_MAKE_VARS+=(LD="$CI_LD") - [[ $ALL_LD_FLAGS ]] && ALL_MAKE_VARS+=(LDFLAGS="$ALL_LD_FLAGS") - ALL_MAKE_VARS+=(LIBS="$CI_LIBS") - ALL_MAKE_VARS+=($CI_MAKE_VARS) - # Build! - ci_spawn cd "$CI_SRCDIR" - local MY_MAKEFILE - for MY_MAKEFILE in $CI_LEGACY_MAKEFILES - do - ci_info "using makefile: $MY_MAKEFILE" - ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \ - "${ALL_MAKE_FLAGS[@]}" \ - "${ALL_MAKE_VARS[@]}" - [[ $CI_NO_TEST ]] || - ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \ - "${ALL_MAKE_FLAGS[@]}" \ - "${ALL_MAKE_VARS[@]}" \ - test - [[ $CI_NO_CLEAN ]] || - ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \ - "${ALL_MAKE_FLAGS[@]}" \ - "${ALL_MAKE_VARS[@]}" \ - clean - done - ci_info "## END OF BUILD ##" -} - -ci_init_legacy -ci_trace_legacy -[[ $# -eq 0 ]] || { - ci_info "note: this program accepts environment options only" - ci_err "unexpected command arguments: '$*'" -} -ci_build_legacy diff --git a/ci/ci_verify_cmake.sh b/ci/ci_verify_cmake.sh new file mode 100755 index 000000000..a92e62899 --- /dev/null +++ b/ci/ci_verify_cmake.sh @@ -0,0 +1,169 @@ +#!/usr/bin/env bash +set -e + +# ci_verify_cmake.sh +# Continuously integrate libpng using CMake. +# +# Copyright (c) 2019-2022 Cosmin Truta. +# +# This software is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h. + +CI_SCRIPTNAME="$(basename "$0")" +CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" +CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" +CI_BUILDDIR="$CI_SRCDIR/out/cmake.build" +CI_INSTALLDIR="$CI_SRCDIR/out/cmake.install" + +function ci_info { + printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*" +} + +function ci_err { + printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*" + exit 2 +} + +function ci_spawn { + printf >&2 "%s: executing:" "$CI_SCRIPTNAME" + printf >&2 " %q" "$@" + printf >&2 "\\n" + "$@" +} + +function ci_init_cmake { + CI_SYSTEM_NAME="$(uname -s)" + CI_MACHINE_NAME="$(uname -m)" + CI_CMAKE="${CI_CMAKE:-cmake}" + CI_CTEST="${CI_CTEST:-ctest}" + CI_CMAKE_BUILD_TYPE="${CI_CMAKE_BUILD_TYPE:-Release}" + [[ -x $(command -v ninja) ]] && CI_CMAKE_GENERATOR="${CI_CMAKE_GENERATOR:-Ninja}" + if [[ $CI_CMAKE_GENERATOR == "Visual Studio"* ]] + then + # Initialize the CI_...DIR_NATIVE variables, for the benefit of + # the native Windows build tools. The regular CI_...DIR variables + # can only be used inside Bash-on-Windows. + mkdir -p "$CI_BUILDDIR" + mkdir -p "$CI_INSTALLDIR" + if [[ -x $CYGPATH ]] + then + CI_SRCDIR_NATIVE="$("$CYGPATH" -w "$CI_SRCDIR")" + CI_BUILDDIR_NATIVE="$("$CYGPATH" -w "$CI_BUILDDIR")" + CI_INSTALLDIR_NATIVE="$("$CYGPATH" -w "$CI_INSTALLDIR")" + else + CI_SRCDIR_NATIVE="$(cd "$CI_SRCDIR" ; pwd -W || pwd -P)" + CI_BUILDDIR_NATIVE="$(cd "$CI_BUILDDIR" ; pwd -W || pwd -P)" + CI_INSTALLDIR_NATIVE="$(cd "$CI_INSTALLDIR" ; pwd -W || pwd -P)" + fi + # Clean up incidental mixtures of Windows and Bash-on-Windows + # environment variables, to avoid confusing MSBuild. + [[ $TEMP && ( $Temp || $temp ) ]] && unset TEMP + [[ $TMP && ( $Tmp || $tmp ) ]] && unset TMP + # Ensure that CI_CMAKE_GENERATOR_PLATFORM is initialized for this generator. + [[ $CI_CMAKE_GENERATOR_PLATFORM ]] || ci_err "missing: \$CI_CMAKE_GENERATOR_PLATFORM" + fi +} + +function ci_trace_cmake { + ci_info "## START OF CONFIGURATION ##" + ci_info "system name: $CI_SYSTEM_NAME" + ci_info "machine hardware name: $CI_MACHINE_NAME" + ci_info "source directory: $CI_SRCDIR" + [[ $CI_SRCDIR_NATIVE ]] && + ci_info "source directory (native): $CI_SRCDIR_NATIVE" + ci_info "build directory: $CI_BUILDDIR" + [[ $CI_BUILDDIR_NATIVE ]] && + ci_info "build directory (native): $CI_BUILDDIR_NATIVE" + ci_info "install directory: $CI_INSTALLDIR" + [[ $CI_INSTALLDIR_NATIVE ]] && + ci_info "install directory (native): $CI_INSTALLDIR_NATIVE" + ci_info "environment option: \$CI_CMAKE: '$CI_CMAKE'" + ci_info "environment option: \$CI_CMAKE_GENERATOR: '$CI_CMAKE_GENERATOR'" + ci_info "environment option: \$CI_CMAKE_GENERATOR_PLATFORM: '$CI_CMAKE_GENERATOR_PLATFORM'" + ci_info "environment option: \$CI_CMAKE_BUILD_TYPE: '$CI_CMAKE_BUILD_TYPE'" + ci_info "environment option: \$CI_CMAKE_BUILD_FLAGS: '$CI_CMAKE_BUILD_FLAGS'" + ci_info "environment option: \$CI_CMAKE_VARS: '$CI_CMAKE_VARS'" + ci_info "environment option: \$CI_CTEST: '$CI_CTEST'" + ci_info "environment option: \$CI_CTEST_FLAGS: '$CI_CTEST_FLAGS'" + ci_info "environment option: \$CI_CC: '$CI_CC'" + ci_info "environment option: \$CI_CC_FLAGS: '$CI_CC_FLAGS'" + ci_info "environment option: \$CI_AR: '$CI_AR'" + ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'" + ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'" + ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'" + ci_info "environment option: \$CI_NO_INSTALL: '$CI_NO_INSTALL'" + ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'" + ci_info "executable: \$CI_CMAKE: $(command -V "$CI_CMAKE")" + ci_info "executable: \$CI_CTEST: $(command -V "$CI_CTEST")" + [[ $CI_CMAKE_GENERATOR == *"Ninja"* ]] && + ci_info "executable: $(command -V ninja)" + [[ $CI_CC ]] && + ci_info "executable: \$CI_CC: $(command -V "$CI_CC")" + [[ $CI_AR ]] && + ci_info "executable: \$CI_AR: $(command -V "$CI_AR")" + [[ $CI_RANLIB ]] && + ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")" + ci_info "## END OF CONFIGURATION ##" +} + +function ci_build_cmake { + ci_info "## START OF BUILD ##" + ci_spawn "$(command -v "$CI_CMAKE")" --version + ci_spawn "$(command -v "$CI_CTEST")" --version + # Initialize ALL_CC_FLAGS as a string. + local ALL_CC_FLAGS="$CI_CC_FLAGS" + [[ $CI_SANITIZERS ]] && ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_CC_FLAGS" + # Initialize ALL_CMAKE_VARS, ALL_CMAKE_BUILD_FLAGS and ALL_CTEST_FLAGS as arrays. + local -a ALL_CMAKE_VARS=() + [[ $CI_CC ]] && ALL_CMAKE_VARS+=(-DCMAKE_C_COMPILER="$CI_CC") + [[ $ALL_CC_FLAGS ]] && ALL_CMAKE_VARS+=(-DCMAKE_C_FLAGS="$ALL_CC_FLAGS") + [[ $CI_AR ]] && ALL_CMAKE_VARS+=(-DCMAKE_AR="$CI_AR") + [[ $CI_RANLIB ]] && ALL_CMAKE_VARS+=(-DCMAKE_RANLIB="$CI_RANLIB") + ALL_CMAKE_VARS+=(-DCMAKE_BUILD_TYPE="$CI_CMAKE_BUILD_TYPE") + ALL_CMAKE_VARS+=(-DCMAKE_VERBOSE_MAKEFILE=ON) + [[ $CI_NO_TEST ]] && ALL_CMAKE_VARS+=(-DPNG_TESTS=OFF) + ALL_CMAKE_VARS+=($CI_CMAKE_VARS) + local -a ALL_CMAKE_BUILD_FLAGS=($CI_CMAKE_BUILD_FLAGS) + local -a ALL_CTEST_FLAGS=($CI_CTEST_FLAGS) + # Initialize SRCDIR_NATIVE and INSTALLDIR_NATIVE. + local SRCDIR_NATIVE="${CI_SRCDIR_NATIVE:-"$CI_SRCDIR"}" + local INSTALLDIR_NATIVE="${CI_INSTALLDIR_NATIVE:-"$CI_INSTALLDIR"}" + # Export the CMake environment variables. + [[ $CI_CMAKE_GENERATOR ]] && + ci_spawn export CMAKE_GENERATOR="$CI_CMAKE_GENERATOR" + [[ $CI_CMAKE_GENERATOR_PLATFORM ]] && + ci_spawn export CMAKE_GENERATOR_PLATFORM="$CI_CMAKE_GENERATOR_PLATFORM" + # Build and install. + ci_spawn rm -fr "$CI_BUILDDIR" "$CI_INSTALLDIR" + ci_spawn mkdir -p "$CI_BUILDDIR" + ci_spawn cd "$CI_BUILDDIR" + ci_spawn "$CI_CMAKE" "${ALL_CMAKE_VARS[@]}" \ + -DCMAKE_INSTALL_PREFIX="$INSTALLDIR_NATIVE" \ + "$SRCDIR_NATIVE" + ci_spawn "$CI_CMAKE" --build . \ + --config "$CI_CMAKE_BUILD_TYPE" \ + "${ALL_CMAKE_BUILD_FLAGS[@]}" + [[ $CI_NO_TEST ]] || + ci_spawn "$CI_CTEST" --build-config "$CI_CMAKE_BUILD_TYPE" \ + "${ALL_CTEST_FLAGS[@]}" + [[ $CI_NO_INSTALL ]] || + ci_spawn "$CI_CMAKE" --build . \ + --config "$CI_CMAKE_BUILD_TYPE" \ + --target install \ + "${ALL_CMAKE_BUILD_FLAGS[@]}" + [[ $CI_NO_CLEAN ]] || + ci_spawn "$CI_CMAKE" --build . \ + --config "$CI_CMAKE_BUILD_TYPE" \ + --target clean \ + "${ALL_CMAKE_BUILD_FLAGS[@]}" + ci_info "## END OF BUILD ##" +} + +ci_init_cmake +ci_trace_cmake +[[ $# -eq 0 ]] || { + ci_info "note: this program accepts environment options only" + ci_err "unexpected command arguments: '$*'" +} +ci_build_cmake diff --git a/ci/ci_verify_configure.sh b/ci/ci_verify_configure.sh new file mode 100755 index 000000000..df822061a --- /dev/null +++ b/ci/ci_verify_configure.sh @@ -0,0 +1,117 @@ +#!/usr/bin/env bash +set -e + +# ci_verify_configure.sh +# Continuously integrate libpng using the configure script. +# +# Copyright (c) 2019-2022 Cosmin Truta. +# +# This software is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h. + +CI_SCRIPTNAME="$(basename "$0")" +CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" +CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" +CI_BUILDDIR="$CI_SRCDIR/out/configure.build" +CI_INSTALLDIR="$CI_SRCDIR/out/configure.install" + +function ci_info { + printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*" +} + +function ci_err { + printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*" + exit 2 +} + +function ci_spawn { + printf >&2 "%s: executing:" "$CI_SCRIPTNAME" + printf >&2 " %q" "$@" + printf >&2 "\\n" + "$@" +} + +function ci_init_configure { + CI_SYSTEM_NAME="$(uname -s)" + CI_MACHINE_NAME="$(uname -m)" + CI_MAKE="${CI_MAKE:-make}" + # Set CI_CC to cc by default, if the cc command is available. + # The configure script defaults CC to gcc, which is not always a good idea. + [[ -x $(command -v cc) ]] && CI_CC="${CI_CC:-cc}" + # Ensure that the CI_ variables that cannot be customized reliably are not initialized. + [[ ! $CI_CONFIGURE_VARS ]] || ci_err "unexpected: \$CI_CONFIGURE_VARS='$CI_CONFIGURE_VARS'" + [[ ! $CI_MAKE_VARS ]] || ci_err "unexpected: \$CI_MAKE_VARS='$CI_MAKE_VARS'" +} + +function ci_trace_configure { + ci_info "## START OF CONFIGURATION ##" + ci_info "system name: $CI_SYSTEM_NAME" + ci_info "machine hardware name: $CI_MACHINE_NAME" + ci_info "source directory: $CI_SRCDIR" + ci_info "build directory: $CI_BUILDDIR" + ci_info "install directory: $CI_INSTALLDIR" + ci_info "environment option: \$CI_CONFIGURE_FLAGS: '$CI_CONFIGURE_FLAGS'" + ci_info "environment option: \$CI_MAKE: '$CI_MAKE'" + ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'" + ci_info "environment option: \$CI_CC: '$CI_CC'" + ci_info "environment option: \$CI_CC_FLAGS: '$CI_CC_FLAGS'" + ci_info "environment option: \$CI_CPP: '$CI_CPP'" + ci_info "environment option: \$CI_CPP_FLAGS: '$CI_CPP_FLAGS'" + ci_info "environment option: \$CI_AR: '$CI_AR'" + ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'" + ci_info "environment option: \$CI_LD: '$CI_LD'" + ci_info "environment option: \$CI_LD_FLAGS: '$CI_LD_FLAGS'" + ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'" + ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'" + ci_info "environment option: \$CI_NO_INSTALL: '$CI_NO_INSTALL'" + ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'" + ci_info "executable: \$CI_MAKE: $(command -V "$CI_MAKE")" + [[ $CI_CC ]] && + ci_info "executable: \$CI_CC: $(command -V "$CI_CC")" + [[ $CI_CPP ]] && + ci_info "executable: \$CI_CPP: $(command -V "$CI_CPP")" + [[ $CI_AR ]] && + ci_info "executable: \$CI_AR: $(command -V "$CI_AR")" + [[ $CI_RANLIB ]] && + ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")" + [[ $CI_LD ]] && + ci_info "executable: \$CI_LD: $(command -V "$CI_LD")" + ci_info "## END OF CONFIGURATION ##" +} + +function ci_build_configure { + ci_info "## START OF BUILD ##" + # Export the configure build environment. + [[ $CI_CC ]] && ci_spawn export CC="$CI_CC" + [[ $CI_CC_FLAGS ]] && ci_spawn export CFLAGS="$CI_CC_FLAGS" + [[ $CI_CPP ]] && ci_spawn export CPP="$CI_CPP" + [[ $CI_CPP_FLAGS ]] && ci_spawn export CPPFLAGS="$CI_CPP_FLAGS" + [[ $CI_AR ]] && ci_spawn export AR="$CI_AR" + [[ $CI_RANLIB ]] && ci_spawn export RANLIB="$CI_RANLIB" + [[ $CI_LD ]] && ci_spawn export CPP="$CI_LD" + [[ $CI_LD_FLAGS ]] && ci_spawn export LDFLAGS="$CI_LD_FLAGS" + [[ $CI_SANITIZERS ]] && { + ci_spawn export CFLAGS="-fsanitize=$CI_SANITIZERS ${CFLAGS:-"-O2"}" + ci_spawn export LDFLAGS="-fsanitize=$CI_SANITIZERS $LDFLAGS" + } + # Build and install. + ci_spawn rm -fr "$CI_BUILDDIR" "$CI_INSTALLDIR" + ci_spawn mkdir -p "$CI_BUILDDIR" + ci_spawn cd "$CI_BUILDDIR" + ci_spawn "$CI_SRCDIR/configure" --prefix="$CI_INSTALLDIR" $CI_CONFIGURE_FLAGS + ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS + [[ $CI_NO_TEST ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS test + [[ $CI_NO_INSTALL ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS install + [[ $CI_NO_CLEAN ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS clean + [[ $CI_NO_CLEAN ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS distclean + ci_info "## END OF BUILD ##" +} + +ci_init_configure +ci_trace_configure +[[ $# -eq 0 ]] || { + ci_info "note: this program accepts environment options only" + ci_err "unexpected command arguments: '$*'" +} +ci_build_configure diff --git a/ci/ci_verify_makefiles.sh b/ci/ci_verify_makefiles.sh new file mode 100755 index 000000000..17658f711 --- /dev/null +++ b/ci/ci_verify_makefiles.sh @@ -0,0 +1,147 @@ +#!/usr/bin/env bash +set -e + +# ci_verify_makefiles.sh +# Continuously integrate libpng using the legacy makefiles. +# +# Copyright (c) 2019-2022 Cosmin Truta. +# +# This software is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h. + +CI_SCRIPTNAME="$(basename "$0")" +CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" +CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" +CI_BUILDDIR="$CI_SRCDIR" + +function ci_info { + printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*" +} + +function ci_err { + printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*" + exit 2 +} + +function ci_spawn { + printf >&2 "%s: executing:" "$CI_SCRIPTNAME" + printf >&2 " %q" "$@" + printf >&2 "\\n" + "$@" +} + +function ci_init_makefiles { + CI_SYSTEM_NAME="$(uname -s)" + CI_MACHINE_NAME="$(uname -m)" + CI_MAKE="${CI_MAKE:-make}" + case "$CI_SYSTEM_NAME" in + ( Darwin | *BSD | DragonFly ) + [[ -x $(command -v clang) ]] && CI_CC="${CI_CC:-clang}" ;; + ( * ) + [[ -x $(command -v gcc) ]] && CI_CC="${CI_CC:-gcc}" ;; + esac + CI_CC="${CI_CC:-cc}" + case "$CI_CC" in + ( *clang* ) + CI_MAKEFILES="${CI_MAKEFILES:-"scripts/makefile.clang"}" ;; + ( *gcc* ) + CI_MAKEFILES="${CI_MAKEFILES:-"scripts/makefile.gcc"}" ;; + ( cc | c89 | c99 ) + CI_MAKEFILES="${CI_MAKEFILES:-"scripts/makefile.std"}" ;; + esac + CI_LD="${CI_LD:-"$CI_CC"}" + CI_LIBS="${CI_LIBS:-"-lz -lm"}" +} + +function ci_trace_makefiles { + ci_info "## START OF CONFIGURATION ##" + ci_info "system name: $CI_SYSTEM_NAME" + ci_info "machine hardware name: $CI_MACHINE_NAME" + ci_info "source directory: $CI_SRCDIR" + ci_info "build directory: $CI_BUILDDIR" + ci_info "environment option: \$CI_MAKEFILES: '$CI_MAKEFILES'" + ci_info "environment option: \$CI_MAKE: '$CI_MAKE'" + ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'" + ci_info "environment option: \$CI_MAKE_VARS: '$CI_MAKE_VARS'" + ci_info "environment option: \$CI_CC: '$CI_CC'" + ci_info "environment option: \$CI_CC_FLAGS: '$CI_CC_FLAGS'" + ci_info "environment option: \$CI_CPP: '$CI_CPP'" + ci_info "environment option: \$CI_CPP_FLAGS: '$CI_CPP_FLAGS'" + ci_info "environment option: \$CI_AR: '$CI_AR'" + ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'" + ci_info "environment option: \$CI_LD: '$CI_LD'" + ci_info "environment option: \$CI_LD_FLAGS: '$CI_LD_FLAGS'" + ci_info "environment option: \$CI_LIBS: '$CI_LIBS'" + ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'" + ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'" + ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'" + ci_info "executable: \$CI_MAKE: $(command -V "$CI_MAKE")" + [[ $CI_CC ]] && + ci_info "executable: \$CI_CC: $(command -V "$CI_CC")" + [[ $CI_CPP ]] && + ci_info "executable: \$CI_CPP: $(command -V "$CI_CPP")" + [[ $CI_AR ]] && + ci_info "executable: \$CI_AR: $(command -V "$CI_AR")" + [[ $CI_RANLIB ]] && + ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")" + [[ $CI_LD ]] && + ci_info "executable: \$CI_LD: $(command -V "$CI_LD")" + ci_info "## END OF CONFIGURATION ##" +} + +function ci_build_makefiles { + ci_info "## START OF BUILD ##" + # Initialize ALL_CC_FLAGS and ALL_LD_FLAGS as strings. + local ALL_CC_FLAGS="$CI_CC_FLAGS" + local ALL_LD_FLAGS="$CI_LD_FLAGS" + [[ $CI_SANITIZERS ]] && { + ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS ${ALL_CC_FLAGS:-"-O2"}" + ALL_LD_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_LD_FLAGS" + } + # Initialize ALL_MAKE_FLAGS and ALL_MAKE_VARS as arrays. + local -a ALL_MAKE_FLAGS=($CI_MAKE_FLAGS) + local -a ALL_MAKE_VARS=() + [[ $CI_CC ]] && ALL_MAKE_VARS+=(CC="$CI_CC") + [[ $ALL_CC_FLAGS ]] && ALL_MAKE_VARS+=(CFLAGS="$ALL_CC_FLAGS") + [[ $CI_CPP ]] && ALL_MAKE_VARS+=(CPP="$CI_CPP") + [[ $CI_CPP_FLAGS ]] && ALL_MAKE_VARS+=(CPPFLAGS="$CI_CPP_FLAGS") + [[ $CI_AR ]] && ALL_MAKE_VARS+=( + AR="${CI_AR:-ar}" + AR_RC="${CI_AR:-ar} rc" + ) + [[ $CI_RANLIB ]] && ALL_MAKE_VARS+=(RANLIB="$CI_RANLIB") + [[ $CI_LD ]] && ALL_MAKE_VARS+=(LD="$CI_LD") + [[ $ALL_LD_FLAGS ]] && ALL_MAKE_VARS+=(LDFLAGS="$ALL_LD_FLAGS") + ALL_MAKE_VARS+=(LIBS="$CI_LIBS") + ALL_MAKE_VARS+=($CI_MAKE_VARS) + # Build! + ci_spawn cd "$CI_SRCDIR" + local MY_MAKEFILE + for MY_MAKEFILE in $CI_MAKEFILES + do + ci_info "using makefile: $MY_MAKEFILE" + ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \ + "${ALL_MAKE_FLAGS[@]}" \ + "${ALL_MAKE_VARS[@]}" + [[ $CI_NO_TEST ]] || + ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \ + "${ALL_MAKE_FLAGS[@]}" \ + "${ALL_MAKE_VARS[@]}" \ + test + [[ $CI_NO_CLEAN ]] || + ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \ + "${ALL_MAKE_FLAGS[@]}" \ + "${ALL_MAKE_VARS[@]}" \ + clean + done + ci_info "## END OF BUILD ##" +} + +ci_init_makefiles +ci_trace_makefiles +[[ $# -eq 0 ]] || { + ci_info "note: this program accepts environment options only" + ci_err "unexpected command arguments: '$*'" +} +ci_build_makefiles -- cgit v1.2.3 From 9db8cff6ef9b213f27263865a145a4c0e7ef08fc Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 27 Nov 2022 21:58:07 +0200 Subject: ci: Fix verification under Cygwin Bash + CMake + Visual Studio; update Fix autodetection and use of the cygpath executable on Windows. Add a new variable CI_CMAKE_TOOLCHAIN_FILE to ci_verify_cmake.sh. This should help in future cross-platform testing. Remove the implicit initialization of CI_CC, CI_LD and CI_LIBS from ci_verify_makefiles.sh. This should help the testing of default values of their respective make variables (CC, LD and LIBS). --- ci/ci_verify_cmake.sh | 35 +++++++++++++++++++++++------------ ci/ci_verify_makefiles.sh | 13 ++----------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/ci/ci_verify_cmake.sh b/ci/ci_verify_cmake.sh index a92e62899..7cf992154 100755 --- a/ci/ci_verify_cmake.sh +++ b/ci/ci_verify_cmake.sh @@ -38,7 +38,8 @@ function ci_init_cmake { CI_CMAKE="${CI_CMAKE:-cmake}" CI_CTEST="${CI_CTEST:-ctest}" CI_CMAKE_BUILD_TYPE="${CI_CMAKE_BUILD_TYPE:-Release}" - [[ -x $(command -v ninja) ]] && CI_CMAKE_GENERATOR="${CI_CMAKE_GENERATOR:-Ninja}" + [[ -x $(command -v ninja) ]] && + CI_CMAKE_GENERATOR="${CI_CMAKE_GENERATOR:-Ninja}" if [[ $CI_CMAKE_GENERATOR == "Visual Studio"* ]] then # Initialize the CI_...DIR_NATIVE variables, for the benefit of @@ -46,11 +47,11 @@ function ci_init_cmake { # can only be used inside Bash-on-Windows. mkdir -p "$CI_BUILDDIR" mkdir -p "$CI_INSTALLDIR" - if [[ -x $CYGPATH ]] + if [[ -x $(command -v cygpath) ]] then - CI_SRCDIR_NATIVE="$("$CYGPATH" -w "$CI_SRCDIR")" - CI_BUILDDIR_NATIVE="$("$CYGPATH" -w "$CI_BUILDDIR")" - CI_INSTALLDIR_NATIVE="$("$CYGPATH" -w "$CI_INSTALLDIR")" + CI_SRCDIR_NATIVE="$(cygpath -w "$CI_SRCDIR")" + CI_BUILDDIR_NATIVE="$(cygpath -w "$CI_BUILDDIR")" + CI_INSTALLDIR_NATIVE="$(cygpath -w "$CI_INSTALLDIR")" else CI_SRCDIR_NATIVE="$(cd "$CI_SRCDIR" ; pwd -W || pwd -P)" CI_BUILDDIR_NATIVE="$(cd "$CI_BUILDDIR" ; pwd -W || pwd -P)" @@ -61,7 +62,8 @@ function ci_init_cmake { [[ $TEMP && ( $Temp || $temp ) ]] && unset TEMP [[ $TMP && ( $Tmp || $tmp ) ]] && unset TMP # Ensure that CI_CMAKE_GENERATOR_PLATFORM is initialized for this generator. - [[ $CI_CMAKE_GENERATOR_PLATFORM ]] || ci_err "missing: \$CI_CMAKE_GENERATOR_PLATFORM" + [[ $CI_CMAKE_GENERATOR_PLATFORM ]] || + ci_err "missing: \$CI_CMAKE_GENERATOR_PLATFORM" fi } @@ -83,6 +85,7 @@ function ci_trace_cmake { ci_info "environment option: \$CI_CMAKE_GENERATOR_PLATFORM: '$CI_CMAKE_GENERATOR_PLATFORM'" ci_info "environment option: \$CI_CMAKE_BUILD_TYPE: '$CI_CMAKE_BUILD_TYPE'" ci_info "environment option: \$CI_CMAKE_BUILD_FLAGS: '$CI_CMAKE_BUILD_FLAGS'" + ci_info "environment option: \$CI_CMAKE_TOOLCHAIN_FILE: '$CI_CMAKE_TOOLCHAIN_FILE'" ci_info "environment option: \$CI_CMAKE_VARS: '$CI_CMAKE_VARS'" ci_info "environment option: \$CI_CTEST: '$CI_CTEST'" ci_info "environment option: \$CI_CTEST_FLAGS: '$CI_CTEST_FLAGS'" @@ -113,16 +116,24 @@ function ci_build_cmake { ci_spawn "$(command -v "$CI_CTEST")" --version # Initialize ALL_CC_FLAGS as a string. local ALL_CC_FLAGS="$CI_CC_FLAGS" - [[ $CI_SANITIZERS ]] && ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_CC_FLAGS" + [[ $CI_SANITIZERS ]] && + ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_CC_FLAGS" # Initialize ALL_CMAKE_VARS, ALL_CMAKE_BUILD_FLAGS and ALL_CTEST_FLAGS as arrays. local -a ALL_CMAKE_VARS=() - [[ $CI_CC ]] && ALL_CMAKE_VARS+=(-DCMAKE_C_COMPILER="$CI_CC") - [[ $ALL_CC_FLAGS ]] && ALL_CMAKE_VARS+=(-DCMAKE_C_FLAGS="$ALL_CC_FLAGS") - [[ $CI_AR ]] && ALL_CMAKE_VARS+=(-DCMAKE_AR="$CI_AR") - [[ $CI_RANLIB ]] && ALL_CMAKE_VARS+=(-DCMAKE_RANLIB="$CI_RANLIB") + [[ $CI_CMAKE_TOOLCHAIN_FILE ]] && + ALL_CMAKE_VARS+=(-DCMAKE_TOOLCHAIN_FILE="$CI_CMAKE_TOOLCHAIN_FILE") + [[ $CI_CC ]] && + ALL_CMAKE_VARS+=(-DCMAKE_C_COMPILER="$CI_CC") + [[ $ALL_CC_FLAGS ]] && + ALL_CMAKE_VARS+=(-DCMAKE_C_FLAGS="$ALL_CC_FLAGS") + [[ $CI_AR ]] && + ALL_CMAKE_VARS+=(-DCMAKE_AR="$CI_AR") + [[ $CI_RANLIB ]] && + ALL_CMAKE_VARS+=(-DCMAKE_RANLIB="$CI_RANLIB") ALL_CMAKE_VARS+=(-DCMAKE_BUILD_TYPE="$CI_CMAKE_BUILD_TYPE") ALL_CMAKE_VARS+=(-DCMAKE_VERBOSE_MAKEFILE=ON) - [[ $CI_NO_TEST ]] && ALL_CMAKE_VARS+=(-DPNG_TESTS=OFF) + [[ $CI_NO_TEST ]] && + ALL_CMAKE_VARS+=(-DPNG_TESTS=OFF) ALL_CMAKE_VARS+=($CI_CMAKE_VARS) local -a ALL_CMAKE_BUILD_FLAGS=($CI_CMAKE_BUILD_FLAGS) local -a ALL_CTEST_FLAGS=($CI_CTEST_FLAGS) diff --git a/ci/ci_verify_makefiles.sh b/ci/ci_verify_makefiles.sh index 17658f711..9f65ec021 100755 --- a/ci/ci_verify_makefiles.sh +++ b/ci/ci_verify_makefiles.sh @@ -35,23 +35,14 @@ function ci_init_makefiles { CI_SYSTEM_NAME="$(uname -s)" CI_MACHINE_NAME="$(uname -m)" CI_MAKE="${CI_MAKE:-make}" - case "$CI_SYSTEM_NAME" in - ( Darwin | *BSD | DragonFly ) - [[ -x $(command -v clang) ]] && CI_CC="${CI_CC:-clang}" ;; - ( * ) - [[ -x $(command -v gcc) ]] && CI_CC="${CI_CC:-gcc}" ;; - esac - CI_CC="${CI_CC:-cc}" case "$CI_CC" in ( *clang* ) CI_MAKEFILES="${CI_MAKEFILES:-"scripts/makefile.clang"}" ;; ( *gcc* ) CI_MAKEFILES="${CI_MAKEFILES:-"scripts/makefile.gcc"}" ;; - ( cc | c89 | c99 ) + ( * ) CI_MAKEFILES="${CI_MAKEFILES:-"scripts/makefile.std"}" ;; esac - CI_LD="${CI_LD:-"$CI_CC"}" - CI_LIBS="${CI_LIBS:-"-lz -lm"}" } function ci_trace_makefiles { @@ -113,7 +104,7 @@ function ci_build_makefiles { [[ $CI_RANLIB ]] && ALL_MAKE_VARS+=(RANLIB="$CI_RANLIB") [[ $CI_LD ]] && ALL_MAKE_VARS+=(LD="$CI_LD") [[ $ALL_LD_FLAGS ]] && ALL_MAKE_VARS+=(LDFLAGS="$ALL_LD_FLAGS") - ALL_MAKE_VARS+=(LIBS="$CI_LIBS") + [[ $CI_LIBS ]] && ALL_MAKE_VARS+=(LIBS="$CI_LIBS") ALL_MAKE_VARS+=($CI_MAKE_VARS) # Build! ci_spawn cd "$CI_SRCDIR" -- cgit v1.2.3 From 61bfdb0cb02a6f3a62c929dbc9e832894c0a8df2 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Tue, 29 Nov 2022 12:38:45 +0200 Subject: Update the configuration for Travis CI and AppVeyor CI Simplify the test matrix on Travis CI to reduce the testing time. Use CI_CMAKE_TOOLCHAIN_FILE on AppVeyor CI. --- .appveyor.yml | 2 +- .travis.yml | 16 +++------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index f447877fe..af232d923 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -45,8 +45,8 @@ install: - 'if "%TOOLCHAIN%"=="vstudio" C:\tools\vcpkg\vcpkg.exe integrate install' before_build: - - 'if "%TOOLCHAIN%"=="vstudio" set CI_CMAKE_VARS=-DCMAKE_TOOLCHAIN_FILE=C:\tools\vcpkg\scripts\buildsystems\vcpkg.cmake' - 'if "%TOOLCHAIN%"=="vstudio" set CI_CMAKE_GENERATOR=Visual Studio 17 2022' + - 'if "%TOOLCHAIN%"=="vstudio" set CI_CMAKE_TOOLCHAIN_FILE=C:\tools\vcpkg\scripts\buildsystems\vcpkg.cmake' - 'if "%TOOLCHAIN%"=="vstudio" if "%ARCH%"=="x86" set CI_CMAKE_GENERATOR_PLATFORM=Win32' - 'if "%TOOLCHAIN%"=="vstudio" if "%ARCH%"=="x64" set CI_CMAKE_GENERATOR_PLATFORM=x64' - 'if "%TOOLCHAIN%"=="vstudio" if "%ARCH%"=="arm64" set CI_CMAKE_GENERATOR_PLATFORM=ARM64' diff --git a/.travis.yml b/.travis.yml index c48df0876..dfbefa790 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,6 @@ os: - linux - osx -compiler: - - clang - - gcc - env: - AUTOMATION=cmake CI_NO_TEST=1 - AUTOMATION=cmake CI_CMAKE_VARS="-DPNG_HARDWARE_OPTIMIZATIONS=ON" CI_SANITIZERS="address,undefined" @@ -26,20 +22,14 @@ env: matrix: include: - os: osx - compiler: cc env: AUTOMATION=cmake CI_CMAKE_GENERATOR=Xcode - exclude: - - os: freebsd - compiler: gcc - - os: osx - compiler: gcc before_script: + - 'if test "$TRAVIS_OS_NAME" = "linux"; then COMPILER="gcc"; else COMPILER="clang"; fi' + - 'export CI_MAKEFILES="scripts/makefile.std scripts/makefile.$COMPILER"' + - 'export CI_MAKE_FLAGS="-j2"' - 'export CI_CMAKE_BUILD_FLAGS="--parallel 2"' - 'export CI_CTEST_FLAGS="--parallel 2"' - - 'export CI_MAKE_FLAGS=-j2' - - 'export CI_CC=$TRAVIS_COMPILER' - - 'export CI_MAKEFILES="scripts/makefile.$TRAVIS_COMPILER scripts/makefile.std"' script: - './ci/ci_verify_$AUTOMATION.sh' -- cgit v1.2.3 From 9923515ff441b4c07ce3f8c9985a547fe582c4da Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Mon, 9 Jan 2023 19:50:00 +0200 Subject: Update the copyright year --- LICENSE | 4 ++-- png.c | 4 ++-- png.h | 6 +++--- scripts/pnglibconf.dfa | 2 +- scripts/pnglibconf.h.prebuilt | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/LICENSE b/LICENSE index c8ad24eec..086d1c2fd 100644 --- a/LICENSE +++ b/LICENSE @@ -4,8 +4,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE PNG Reference Library License version 2 --------------------------------------- - * Copyright (c) 1995-2022 The PNG Reference Library Authors. - * Copyright (c) 2018-2022 Cosmin Truta. + * Copyright (c) 1995-2023 The PNG Reference Library Authors. + * Copyright (c) 2018-2023 Cosmin Truta. * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. * Copyright (c) 1996-1997 Andreas Dilger. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. diff --git a/png.c b/png.c index a0b82039a..b4614c9ca 100644 --- a/png.c +++ b/png.c @@ -1,7 +1,7 @@ /* png.c - location for general purpose libpng functions * - * Copyright (c) 2018-2022 Cosmin Truta + * Copyright (c) 2018-2023 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -816,7 +816,7 @@ png_get_copyright(png_const_structrp png_ptr) #else return PNG_STRING_NEWLINE \ "libpng version 1.6.40.git" PNG_STRING_NEWLINE \ - "Copyright (c) 2018-2022 Cosmin Truta" PNG_STRING_NEWLINE \ + "Copyright (c) 2018-2023 Cosmin Truta" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \ PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ diff --git a/png.h b/png.h index d85427b8d..a477a2000 100644 --- a/png.h +++ b/png.h @@ -3,7 +3,7 @@ * * libpng version 1.6.40.git * - * Copyright (c) 2018-2022 Cosmin Truta + * Copyright (c) 2018-2023 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -27,8 +27,8 @@ * PNG Reference Library License version 2 * --------------------------------------- * - * * Copyright (c) 1995-2022 The PNG Reference Library Authors. - * * Copyright (c) 2018-2022 Cosmin Truta. + * * Copyright (c) 1995-2023 The PNG Reference Library Authors. + * * Copyright (c) 2018-2023 Cosmin Truta. * * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. * * Copyright (c) 1996-1997 Andreas Dilger. * * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. diff --git a/scripts/pnglibconf.dfa b/scripts/pnglibconf.dfa index 0ada967b9..261954e47 100644 --- a/scripts/pnglibconf.dfa +++ b/scripts/pnglibconf.dfa @@ -8,7 +8,7 @@ com pnglibconf.h - library build configuration com version com -com Copyright (c) 2018-2022 Cosmin Truta +com Copyright (c) 2018-2023 Cosmin Truta com Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson com com This code is released under the libpng license. diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt index 7497e7ff4..4334151ec 100644 --- a/scripts/pnglibconf.h.prebuilt +++ b/scripts/pnglibconf.h.prebuilt @@ -2,7 +2,7 @@ /* libpng version 1.6.40.git */ -/* Copyright (c) 2018-2022 Cosmin Truta */ +/* Copyright (c) 2018-2023 Cosmin Truta */ /* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */ /* This code is released under the libpng license. */ -- cgit v1.2.3 From cd0ea2a7f53b603d3d9b5b891c779c430047b39a Mon Sep 17 00:00:00 2001 From: Jon Creighton Date: Mon, 9 Jan 2023 13:17:31 +0000 Subject: 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 --- CMakeLists.txt | 3 ++- scripts/genout.cmake.in | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24739fe1a..f7ceb640c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # CMakeLists.txt -# Copyright (c) 2018-2022 Cosmin Truta +# Copyright (c) 2018-2023 Cosmin Truta # Copyright (c) 2007,2009-2018 Glenn Randers-Pehrson # Written by Christian Ehrlicher, 2007 # Revised by Roger Lowman, 2009-2010 @@ -20,6 +20,7 @@ # Revised by Gleb Mazovetskiy, 2021 # Revised by Christopher Sean Morrison, 2022 # Revised by Martin Storsjo, 2022 +# Revised by Jon Creighton, 2023 # This code is released under the libpng license. # For conditions of distribution and use, see the disclaimer diff --git a/scripts/genout.cmake.in b/scripts/genout.cmake.in index 91d3bd48a..ec685d900 100644 --- a/scripts/genout.cmake.in +++ b/scripts/genout.cmake.in @@ -24,10 +24,10 @@ set(ZLIBINCDIR "@ZLIB_INCLUDE_DIRS@") set(PLATFORM_C_FLAGS) if(APPLE) - set(CMAKE_OSX_ARCHITECTURES "@CMAKE_OSX_ARCHITECTURES@") + set(CMAKE_OSX_INTERNAL_ARCHITECTURES "@CMAKE_OSX_INTERNAL_ARCHITECTURES@") set(CMAKE_OSX_SYSROOT "@CMAKE_OSX_SYSROOT@") - if(CMAKE_OSX_ARCHITECTURES) - set(PLATFORM_C_FLAGS ${PLATFORM_C_FLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}) + if(CMAKE_OSX_INTERNAL_ARCHITECTURES) + set(PLATFORM_C_FLAGS ${PLATFORM_C_FLAGS} -arch ${CMAKE_OSX_INTERNAL_ARCHITECTURES}) endif() if(CMAKE_OSX_SYSROOT) set(PLATFORM_C_FLAGS ${PLATFORM_C_FLAGS} -isysroot ${CMAKE_OSX_SYSROOT}) -- cgit v1.2.3 From aeb26da4cb64c0e75c8dbc9d59402820e2470667 Mon Sep 17 00:00:00 2001 From: Gunther Nikl Date: Tue, 31 Jan 2023 18:19:46 +0100 Subject: 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 --- CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f7ceb640c..6d4952524 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ # Revised by Christopher Sean Morrison, 2022 # Revised by Martin Storsjo, 2022 # Revised by Jon Creighton, 2023 +# Revised by Gunther Nikl, 2023 # This code is released under the libpng license. # For conditions of distribution and use, see the disclaimer @@ -243,13 +244,19 @@ VERS_2 { } VERS_1; ") set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) - set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'") + set(CMAKE_REQUIRED_FLAGS + ${CMAKE_REQUIRED_FLAGS} + ${CMAKE_SHARED_LIBRARY_C_FLAGS} + "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'") check_c_source_compiles("void sym(void) {} void sym2(void) {} int main(void) {return 0;} " HAVE_LD_VERSION_SCRIPT) if(NOT HAVE_LD_VERSION_SCRIPT) - set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map") + set(CMAKE_REQUIRED_FLAGS + ${CMAKE_REQUIRED_FLAGS_SAVE} + ${CMAKE_SHARED_LIBRARY_C_FLAGS} + "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map") check_c_source_compiles("void sym(void) {} void sym2(void) {} int main(void) {return 0;} -- cgit v1.2.3 From 70fda1837d5de802ce5f7e04be239192b6a74d92 Mon Sep 17 00:00:00 2001 From: "B. Scott Michel" Date: Tue, 23 Aug 2022 14:23:51 -0700 Subject: 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 --- CMakeLists.txt | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d4952524..6c9f37abc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ # Revised by Owen Rudge, 2020 # Revised by Gleb Mazovetskiy, 2021 # Revised by Christopher Sean Morrison, 2022 +# Revised by B. Scott Michel, 2022 # Revised by Martin Storsjo, 2022 # Revised by Jon Creighton, 2023 # Revised by Gunther Nikl, 2023 @@ -228,6 +229,18 @@ set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR}) # Distinguish between debug and release builds. set(CMAKE_DEBUG_POSTFIX "d") +# Win32 and Clang (MinGW gcc is not affected by naming issues) +set(PNG_PREPEND_LIB_NAME "") +set(PNG_LIB_NAME_STATIC "${PNG_LIB_NAME}") +if(MSVC OR (WIN32 AND CMAKE_C_COMPILER_ID MATCHES ".*Clang")) + # MSVC and Clang do not prepend 'lib'. Establish a consistent naming convention. + set(PNG_PREPEND_LIB_NAME "lib") + # Change the name of the static library. + set(PNG_LIB_NAME_STATIC png_static) + # Tamp down on the deprecated/potentially insecure warnings about fopen() and ilk. + add_definitions(-D_CRT_SECURE_NO_WARNINGS) +endif() + include(CheckCSourceCompiles) option(ld-version-script "Enable linker version script" ON) if(ld-version-script AND NOT ANDROID AND NOT APPLE) @@ -597,11 +610,8 @@ if(PNG_SHARED) set(PNG_LIB_TARGETS png) set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME}) add_dependencies(png genfiles) - if(MSVC) - # MVC does not append 'lib'. Do it here, to have consistent name. - set_target_properties(png PROPERTIES PREFIX "lib") - set_target_properties(png PROPERTIES IMPORT_PREFIX "lib") - endif() + set_target_properties(png PROPERTIES PREFIX "${PNG_PREPEND_LIB_NAME}") + set_target_properties(png PROPERTIES IMPORT_PREFIX "${PNG_PREPEND_LIB_NAME}") target_link_libraries(png ${ZLIB_LIBRARIES} ${M_LIBRARY}) if(UNIX AND AWK) @@ -617,26 +627,16 @@ endif() if(PNG_STATIC) # does not work without changing name - set(PNG_LIB_NAME_STATIC png_static) add_library(png_static STATIC ${libpng_sources}) add_dependencies(png_static genfiles) # MSVC doesn't use a different file extension for shared vs. static # libs. We are able to change OUTPUT_NAME to remove the _static # for all other platforms. - if(NOT MSVC) - set_target_properties(png_static PROPERTIES - OUTPUT_NAME "${PNG_LIB_NAME}" - CLEAN_DIRECT_OUTPUT 1) - else() - set_target_properties(png_static PROPERTIES - OUTPUT_NAME "${PNG_LIB_NAME}_static" - CLEAN_DIRECT_OUTPUT 1) - endif() + set_target_properties(png_static PROPERTIES + OUTPUT_NAME "${PNG_LIB_NAME_STATIC}" + CLEAN_DIRECT_OUTPUT 1) list(APPEND PNG_LIB_TARGETS png_static) - if(MSVC) - # MSVC does not append 'lib'. Do it here, to have consistent name. - set_target_properties(png_static PROPERTIES PREFIX "lib") - endif() + set_target_properties(png_static PROPERTIES PREFIX "${PNG_PREPEND_LIB_NAME}") target_link_libraries(png_static ${ZLIB_LIBRARIES} ${M_LIBRARY}) endif() -- cgit v1.2.3 From 59fa76e1647422d63c9f01a9d7c66b5a540ae69d Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sat, 4 Feb 2023 20:33:23 +0200 Subject: ci: Add CMake+Ninja+Clang to the AppVeyor CI matrix --- .appveyor.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index af232d923..b850d02f0 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -21,6 +21,9 @@ environment: AUTOMATION: cmake ARCH: arm64 CI_NO_TEST: 1 + - TOOLCHAIN: llvm + AUTOMATION: cmake + ARCH: x64 - TOOLCHAIN: msys2 AUTOMATION: cmake ARCH: i686 @@ -43,6 +46,8 @@ environment: install: - 'if "%TOOLCHAIN%"=="vstudio" C:\tools\vcpkg\vcpkg.exe install zlib:%ARCH%-windows' - 'if "%TOOLCHAIN%"=="vstudio" C:\tools\vcpkg\vcpkg.exe integrate install' + - 'if "%TOOLCHAIN%"=="llvm" C:\tools\vcpkg\vcpkg.exe install zlib:%ARCH%-windows' + - 'if "%TOOLCHAIN%"=="llvm" C:\tools\vcpkg\vcpkg.exe integrate install' before_build: - 'if "%TOOLCHAIN%"=="vstudio" set CI_CMAKE_GENERATOR=Visual Studio 17 2022' @@ -50,10 +55,13 @@ before_build: - 'if "%TOOLCHAIN%"=="vstudio" if "%ARCH%"=="x86" set CI_CMAKE_GENERATOR_PLATFORM=Win32' - 'if "%TOOLCHAIN%"=="vstudio" if "%ARCH%"=="x64" set CI_CMAKE_GENERATOR_PLATFORM=x64' - 'if "%TOOLCHAIN%"=="vstudio" if "%ARCH%"=="arm64" set CI_CMAKE_GENERATOR_PLATFORM=ARM64' + - 'if "%TOOLCHAIN%"=="llvm" set CI_CMAKE_GENERATOR=Ninja' + - 'if "%TOOLCHAIN%"=="llvm" set CI_CMAKE_TOOLCHAIN_FILE=C:\tools\vcpkg\scripts\buildsystems\vcpkg.cmake' + - 'if "%TOOLCHAIN%"=="llvm" set CI_CC=clang.exe' - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="cmake" set CI_CMAKE_GENERATOR=Unix Makefiles' - 'if "%TOOLCHAIN%"=="msys2" if "%ARCH%"=="i686" set PATH=C:\msys64\mingw32\bin;%PATH%' - 'if "%TOOLCHAIN%"=="msys2" if "%ARCH%"=="x86_64" set PATH=C:\msys64\mingw64\bin;%PATH%' - - 'if "%TOOLCHAIN%"=="msys2" set CI_CC=%ARCH%-w64-mingw32-gcc' + - 'if "%TOOLCHAIN%"=="msys2" set CI_CC=%ARCH%-w64-mingw32-gcc.exe' - 'set CI_CMAKE_BUILD_FLAGS=--parallel 2' - 'set CI_CTEST_FLAGS=--parallel 2' - 'set CI_MAKE_FLAGS=-j2' @@ -61,6 +69,7 @@ before_build: build_script: - 'if "%TOOLCHAIN%"=="vstudio" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_cmake.sh"' + - 'if "%TOOLCHAIN%"=="llvm" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_cmake.sh"' - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="cmake" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_cmake.sh"' - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="configure" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_configure.sh"' - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="makefiles" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_makefiles.sh"' -- cgit v1.2.3 From 66fede80d24e03b527ebf0b830b559cf4e5300aa Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 5 Feb 2023 17:09:00 +0200 Subject: ci: Update the CI scripts Apply the following changes: * Update CI_BUILDDIR and CI_INSTALLDIR to reflect the new script names. * Introduce CI_SRCDIR_FROM_BUILDDIR and CI_INSTALLDIR_FROM_BUILDDIR to the cmake build, to ensure that the Windows tools can handle native Windows paths correctly when executed via Bash-on-Windows. * Stop guessing and using CI_SRCDIR_NATIVE and CI_INSTALLDIR_NATIVE in the cmake build, since we now have a better solution. * Show the ninja program version in ninja-based cmake builds. * Move the cleanup of previous builds into separate functions, and do it in a cleaner manner. No pun intended. --- ci/ci_verify_cmake.sh | 88 +++++++++++++++++++++++------------------------ ci/ci_verify_configure.sh | 35 ++++++++++++------- ci/ci_verify_makefiles.sh | 44 ++++++++++++++++-------- 3 files changed, 97 insertions(+), 70 deletions(-) diff --git a/ci/ci_verify_cmake.sh b/ci/ci_verify_cmake.sh index 7cf992154..4e11addfb 100755 --- a/ci/ci_verify_cmake.sh +++ b/ci/ci_verify_cmake.sh @@ -4,7 +4,7 @@ set -e # ci_verify_cmake.sh # Continuously integrate libpng using CMake. # -# Copyright (c) 2019-2022 Cosmin Truta. +# Copyright (c) 2019-2023 Cosmin Truta. # # This software is released under the libpng license. # For conditions of distribution and use, see the disclaimer @@ -13,8 +13,14 @@ set -e CI_SCRIPTNAME="$(basename "$0")" CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" -CI_BUILDDIR="$CI_SRCDIR/out/cmake.build" -CI_INSTALLDIR="$CI_SRCDIR/out/cmake.install" +CI_BUILDDIR="$CI_SRCDIR/out/ci_verify_cmake.build" +CI_INSTALLDIR="$CI_SRCDIR/out/ci_verify_cmake.install" + +# Keep the following relative paths in sync with the absolute paths. +# We use them for the benefit of native Windows tools that might be +# otherwise confused by the path encoding used by Bash-on-Windows. +CI_SRCDIR_FROM_BUILDDIR="../.." +CI_INSTALLDIR_FROM_BUILDDIR="../ci_verify_cmake.install" function ci_info { printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*" @@ -32,7 +38,7 @@ function ci_spawn { "$@" } -function ci_init_cmake { +function ci_init_cmake_build { CI_SYSTEM_NAME="$(uname -s)" CI_MACHINE_NAME="$(uname -m)" CI_CMAKE="${CI_CMAKE:-cmake}" @@ -42,21 +48,6 @@ function ci_init_cmake { CI_CMAKE_GENERATOR="${CI_CMAKE_GENERATOR:-Ninja}" if [[ $CI_CMAKE_GENERATOR == "Visual Studio"* ]] then - # Initialize the CI_...DIR_NATIVE variables, for the benefit of - # the native Windows build tools. The regular CI_...DIR variables - # can only be used inside Bash-on-Windows. - mkdir -p "$CI_BUILDDIR" - mkdir -p "$CI_INSTALLDIR" - if [[ -x $(command -v cygpath) ]] - then - CI_SRCDIR_NATIVE="$(cygpath -w "$CI_SRCDIR")" - CI_BUILDDIR_NATIVE="$(cygpath -w "$CI_BUILDDIR")" - CI_INSTALLDIR_NATIVE="$(cygpath -w "$CI_INSTALLDIR")" - else - CI_SRCDIR_NATIVE="$(cd "$CI_SRCDIR" ; pwd -W || pwd -P)" - CI_BUILDDIR_NATIVE="$(cd "$CI_BUILDDIR" ; pwd -W || pwd -P)" - CI_INSTALLDIR_NATIVE="$(cd "$CI_INSTALLDIR" ; pwd -W || pwd -P)" - fi # Clean up incidental mixtures of Windows and Bash-on-Windows # environment variables, to avoid confusing MSBuild. [[ $TEMP && ( $Temp || $temp ) ]] && unset TEMP @@ -67,19 +58,13 @@ function ci_init_cmake { fi } -function ci_trace_cmake { +function ci_trace_cmake_build { ci_info "## START OF CONFIGURATION ##" ci_info "system name: $CI_SYSTEM_NAME" ci_info "machine hardware name: $CI_MACHINE_NAME" ci_info "source directory: $CI_SRCDIR" - [[ $CI_SRCDIR_NATIVE ]] && - ci_info "source directory (native): $CI_SRCDIR_NATIVE" ci_info "build directory: $CI_BUILDDIR" - [[ $CI_BUILDDIR_NATIVE ]] && - ci_info "build directory (native): $CI_BUILDDIR_NATIVE" ci_info "install directory: $CI_INSTALLDIR" - [[ $CI_INSTALLDIR_NATIVE ]] && - ci_info "install directory (native): $CI_INSTALLDIR_NATIVE" ci_info "environment option: \$CI_CMAKE: '$CI_CMAKE'" ci_info "environment option: \$CI_CMAKE_GENERATOR: '$CI_CMAKE_GENERATOR'" ci_info "environment option: \$CI_CMAKE_GENERATOR_PLATFORM: '$CI_CMAKE_GENERATOR_PLATFORM'" @@ -99,8 +84,6 @@ function ci_trace_cmake { ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'" ci_info "executable: \$CI_CMAKE: $(command -V "$CI_CMAKE")" ci_info "executable: \$CI_CTEST: $(command -V "$CI_CTEST")" - [[ $CI_CMAKE_GENERATOR == *"Ninja"* ]] && - ci_info "executable: $(command -V ninja)" [[ $CI_CC ]] && ci_info "executable: \$CI_CC: $(command -V "$CI_CC")" [[ $CI_AR ]] && @@ -110,16 +93,25 @@ function ci_trace_cmake { ci_info "## END OF CONFIGURATION ##" } +function ci_cleanup_old_cmake_build { + [[ ! -e $CI_BUILDDIR ]] || + ci_spawn rm -fr "$CI_BUILDDIR" + [[ ! -e $CI_INSTALLDIR ]] || + ci_spawn rm -fr "$CI_INSTALLDIR" +} + function ci_build_cmake { ci_info "## START OF BUILD ##" ci_spawn "$(command -v "$CI_CMAKE")" --version ci_spawn "$(command -v "$CI_CTEST")" --version + [[ $CI_CMAKE_GENERATOR == *"Ninja"* ]] && + ci_spawn "$(command -v ninja)" --version # Initialize ALL_CC_FLAGS as a string. local ALL_CC_FLAGS="$CI_CC_FLAGS" [[ $CI_SANITIZERS ]] && ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_CC_FLAGS" # Initialize ALL_CMAKE_VARS, ALL_CMAKE_BUILD_FLAGS and ALL_CTEST_FLAGS as arrays. - local -a ALL_CMAKE_VARS=() + local ALL_CMAKE_VARS=() [[ $CI_CMAKE_TOOLCHAIN_FILE ]] && ALL_CMAKE_VARS+=(-DCMAKE_TOOLCHAIN_FILE="$CI_CMAKE_TOOLCHAIN_FILE") [[ $CI_CC ]] && @@ -135,23 +127,26 @@ function ci_build_cmake { [[ $CI_NO_TEST ]] && ALL_CMAKE_VARS+=(-DPNG_TESTS=OFF) ALL_CMAKE_VARS+=($CI_CMAKE_VARS) - local -a ALL_CMAKE_BUILD_FLAGS=($CI_CMAKE_BUILD_FLAGS) - local -a ALL_CTEST_FLAGS=($CI_CTEST_FLAGS) - # Initialize SRCDIR_NATIVE and INSTALLDIR_NATIVE. - local SRCDIR_NATIVE="${CI_SRCDIR_NATIVE:-"$CI_SRCDIR"}" - local INSTALLDIR_NATIVE="${CI_INSTALLDIR_NATIVE:-"$CI_INSTALLDIR"}" + local ALL_CMAKE_BUILD_FLAGS=($CI_CMAKE_BUILD_FLAGS) + local ALL_CTEST_FLAGS=($CI_CTEST_FLAGS) # Export the CMake environment variables. [[ $CI_CMAKE_GENERATOR ]] && ci_spawn export CMAKE_GENERATOR="$CI_CMAKE_GENERATOR" [[ $CI_CMAKE_GENERATOR_PLATFORM ]] && ci_spawn export CMAKE_GENERATOR_PLATFORM="$CI_CMAKE_GENERATOR_PLATFORM" # Build and install. - ci_spawn rm -fr "$CI_BUILDDIR" "$CI_INSTALLDIR" + # Use $CI_SRCDIR_FROM_BUILDDIR and $CI_INSTALLDIR_FROM_BUILDDIR + # instead of $CI_SRCDIR and $CI_INSTALLDIR from this point onwards. ci_spawn mkdir -p "$CI_BUILDDIR" ci_spawn cd "$CI_BUILDDIR" - ci_spawn "$CI_CMAKE" "${ALL_CMAKE_VARS[@]}" \ - -DCMAKE_INSTALL_PREFIX="$INSTALLDIR_NATIVE" \ - "$SRCDIR_NATIVE" + [[ $CI_SRCDIR -ef $CI_SRCDIR_FROM_BUILDDIR ]] || + ci_err "assertion failed: testing: '$CI_SRCDIR' -ef '$CI_SRCDIR_FROM_BUILDDIR'" + ci_spawn mkdir -p "$CI_INSTALLDIR" + [[ $CI_INSTALLDIR -ef $CI_INSTALLDIR_FROM_BUILDDIR ]] || + ci_err "assertion failed: testing: '$CI_INSTALLDIR' -ef '$CI_INSTALLDIR_FROM_BUILDDIR'" + ci_spawn "$CI_CMAKE" -DCMAKE_INSTALL_PREFIX="$CI_INSTALLDIR_FROM_BUILDDIR" \ + "${ALL_CMAKE_VARS[@]}" \ + "$CI_SRCDIR_FROM_BUILDDIR" ci_spawn "$CI_CMAKE" --build . \ --config "$CI_CMAKE_BUILD_TYPE" \ "${ALL_CMAKE_BUILD_FLAGS[@]}" @@ -171,10 +166,15 @@ function ci_build_cmake { ci_info "## END OF BUILD ##" } -ci_init_cmake -ci_trace_cmake -[[ $# -eq 0 ]] || { - ci_info "note: this program accepts environment options only" - ci_err "unexpected command arguments: '$*'" +function main { + [[ $# -eq 0 ]] || { + ci_info "note: this program accepts environment options only" + ci_err "unexpected command arguments: '$*'" + } + ci_init_cmake_build + ci_trace_cmake_build + ci_cleanup_old_cmake_build + ci_build_cmake } -ci_build_cmake + +main "$@" diff --git a/ci/ci_verify_configure.sh b/ci/ci_verify_configure.sh index df822061a..a8e88787a 100755 --- a/ci/ci_verify_configure.sh +++ b/ci/ci_verify_configure.sh @@ -4,7 +4,7 @@ set -e # ci_verify_configure.sh # Continuously integrate libpng using the configure script. # -# Copyright (c) 2019-2022 Cosmin Truta. +# Copyright (c) 2019-2023 Cosmin Truta. # # This software is released under the libpng license. # For conditions of distribution and use, see the disclaimer @@ -13,8 +13,8 @@ set -e CI_SCRIPTNAME="$(basename "$0")" CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" -CI_BUILDDIR="$CI_SRCDIR/out/configure.build" -CI_INSTALLDIR="$CI_SRCDIR/out/configure.install" +CI_BUILDDIR="$CI_SRCDIR/out/ci_verify_configure.build" +CI_INSTALLDIR="$CI_SRCDIR/out/ci_verify_configure.install" function ci_info { printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*" @@ -32,7 +32,7 @@ function ci_spawn { "$@" } -function ci_init_configure { +function ci_init_configure_build { CI_SYSTEM_NAME="$(uname -s)" CI_MACHINE_NAME="$(uname -m)" CI_MAKE="${CI_MAKE:-make}" @@ -44,7 +44,7 @@ function ci_init_configure { [[ ! $CI_MAKE_VARS ]] || ci_err "unexpected: \$CI_MAKE_VARS='$CI_MAKE_VARS'" } -function ci_trace_configure { +function ci_trace_configure_build { ci_info "## START OF CONFIGURATION ##" ci_info "system name: $CI_SYSTEM_NAME" ci_info "machine hardware name: $CI_MACHINE_NAME" @@ -80,6 +80,13 @@ function ci_trace_configure { ci_info "## END OF CONFIGURATION ##" } +function ci_cleanup_old_configure_build { + [[ ! -e $CI_BUILDDIR ]] || + ci_spawn rm -fr "$CI_BUILDDIR" + [[ ! -e $CI_INSTALLDIR ]] || + ci_spawn rm -fr "$CI_INSTALLDIR" +} + function ci_build_configure { ci_info "## START OF BUILD ##" # Export the configure build environment. @@ -96,7 +103,6 @@ function ci_build_configure { ci_spawn export LDFLAGS="-fsanitize=$CI_SANITIZERS $LDFLAGS" } # Build and install. - ci_spawn rm -fr "$CI_BUILDDIR" "$CI_INSTALLDIR" ci_spawn mkdir -p "$CI_BUILDDIR" ci_spawn cd "$CI_BUILDDIR" ci_spawn "$CI_SRCDIR/configure" --prefix="$CI_INSTALLDIR" $CI_CONFIGURE_FLAGS @@ -108,10 +114,15 @@ function ci_build_configure { ci_info "## END OF BUILD ##" } -ci_init_configure -ci_trace_configure -[[ $# -eq 0 ]] || { - ci_info "note: this program accepts environment options only" - ci_err "unexpected command arguments: '$*'" +function main { + [[ $# -eq 0 ]] || { + ci_info "note: this program accepts environment options only" + ci_err "unexpected command arguments: '$*'" + } + ci_init_configure_build + ci_trace_configure_build + ci_cleanup_old_configure_build + ci_build_configure } -ci_build_configure + +main "$@" diff --git a/ci/ci_verify_makefiles.sh b/ci/ci_verify_makefiles.sh index 9f65ec021..78e7469d7 100755 --- a/ci/ci_verify_makefiles.sh +++ b/ci/ci_verify_makefiles.sh @@ -4,7 +4,7 @@ set -e # ci_verify_makefiles.sh # Continuously integrate libpng using the legacy makefiles. # -# Copyright (c) 2019-2022 Cosmin Truta. +# Copyright (c) 2019-2023 Cosmin Truta. # # This software is released under the libpng license. # For conditions of distribution and use, see the disclaimer @@ -13,7 +13,6 @@ set -e CI_SCRIPTNAME="$(basename "$0")" CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" -CI_BUILDDIR="$CI_SRCDIR" function ci_info { printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*" @@ -31,7 +30,7 @@ function ci_spawn { "$@" } -function ci_init_makefiles { +function ci_init_makefiles_build { CI_SYSTEM_NAME="$(uname -s)" CI_MACHINE_NAME="$(uname -m)" CI_MAKE="${CI_MAKE:-make}" @@ -45,12 +44,11 @@ function ci_init_makefiles { esac } -function ci_trace_makefiles { +function ci_trace_makefiles_build { ci_info "## START OF CONFIGURATION ##" ci_info "system name: $CI_SYSTEM_NAME" ci_info "machine hardware name: $CI_MACHINE_NAME" ci_info "source directory: $CI_SRCDIR" - ci_info "build directory: $CI_BUILDDIR" ci_info "environment option: \$CI_MAKEFILES: '$CI_MAKEFILES'" ci_info "environment option: \$CI_MAKE: '$CI_MAKE'" ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'" @@ -81,6 +79,19 @@ function ci_trace_makefiles { ci_info "## END OF CONFIGURATION ##" } +function ci_cleanup_old_makefiles_build { + # Any old makefile-based build will most likely leave a mess + # of object files behind if interrupted, e.g., via Ctrl+C. + # There may be other files behind, depending on what makefile + # had been used. We cannot easily enumerate all of those. + # Fortunately, for a clean makefiles-based build, it should be + # sufficient to remove the old object files only. + [[ -z $(find "$CI_SRCDIR" -maxdepth 1 -name "*.o") ]] || + ci_spawn rm -f "$CI_SRCDIR"/*.o + [[ -z $(find "$CI_SRCDIR" -maxdepth 1 -name "*.obj") ]] || + ci_spawn rm -f "$CI_SRCDIR"/*.obj +} + function ci_build_makefiles { ci_info "## START OF BUILD ##" # Initialize ALL_CC_FLAGS and ALL_LD_FLAGS as strings. @@ -91,8 +102,8 @@ function ci_build_makefiles { ALL_LD_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_LD_FLAGS" } # Initialize ALL_MAKE_FLAGS and ALL_MAKE_VARS as arrays. - local -a ALL_MAKE_FLAGS=($CI_MAKE_FLAGS) - local -a ALL_MAKE_VARS=() + local ALL_MAKE_FLAGS=($CI_MAKE_FLAGS) + local ALL_MAKE_VARS=() [[ $CI_CC ]] && ALL_MAKE_VARS+=(CC="$CI_CC") [[ $ALL_CC_FLAGS ]] && ALL_MAKE_VARS+=(CFLAGS="$ALL_CC_FLAGS") [[ $CI_CPP ]] && ALL_MAKE_VARS+=(CPP="$CI_CPP") @@ -107,7 +118,7 @@ function ci_build_makefiles { [[ $CI_LIBS ]] && ALL_MAKE_VARS+=(LIBS="$CI_LIBS") ALL_MAKE_VARS+=($CI_MAKE_VARS) # Build! - ci_spawn cd "$CI_SRCDIR" + cd "$CI_SRCDIR" local MY_MAKEFILE for MY_MAKEFILE in $CI_MAKEFILES do @@ -129,10 +140,15 @@ function ci_build_makefiles { ci_info "## END OF BUILD ##" } -ci_init_makefiles -ci_trace_makefiles -[[ $# -eq 0 ]] || { - ci_info "note: this program accepts environment options only" - ci_err "unexpected command arguments: '$*'" +function main { + [[ $# -eq 0 ]] || { + ci_info "note: this program accepts environment options only" + ci_err "unexpected command arguments: '$*'" + } + ci_init_makefiles_build + ci_trace_makefiles_build + ci_cleanup_old_makefiles_build + ci_build_makefiles } -ci_build_makefiles + +main "$@" -- cgit v1.2.3 From c22ef3b2e342bdfe3140b7e94879996d0e18c95b Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Tue, 7 Feb 2023 17:49:06 +0200 Subject: 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. --- CMakeLists.txt | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c9f37abc..6d4952524 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,6 @@ # Revised by Owen Rudge, 2020 # Revised by Gleb Mazovetskiy, 2021 # Revised by Christopher Sean Morrison, 2022 -# Revised by B. Scott Michel, 2022 # Revised by Martin Storsjo, 2022 # Revised by Jon Creighton, 2023 # Revised by Gunther Nikl, 2023 @@ -229,18 +228,6 @@ set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR}) # Distinguish between debug and release builds. set(CMAKE_DEBUG_POSTFIX "d") -# Win32 and Clang (MinGW gcc is not affected by naming issues) -set(PNG_PREPEND_LIB_NAME "") -set(PNG_LIB_NAME_STATIC "${PNG_LIB_NAME}") -if(MSVC OR (WIN32 AND CMAKE_C_COMPILER_ID MATCHES ".*Clang")) - # MSVC and Clang do not prepend 'lib'. Establish a consistent naming convention. - set(PNG_PREPEND_LIB_NAME "lib") - # Change the name of the static library. - set(PNG_LIB_NAME_STATIC png_static) - # Tamp down on the deprecated/potentially insecure warnings about fopen() and ilk. - add_definitions(-D_CRT_SECURE_NO_WARNINGS) -endif() - include(CheckCSourceCompiles) option(ld-version-script "Enable linker version script" ON) if(ld-version-script AND NOT ANDROID AND NOT APPLE) @@ -610,8 +597,11 @@ if(PNG_SHARED) set(PNG_LIB_TARGETS png) set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME}) add_dependencies(png genfiles) - set_target_properties(png PROPERTIES PREFIX "${PNG_PREPEND_LIB_NAME}") - set_target_properties(png PROPERTIES IMPORT_PREFIX "${PNG_PREPEND_LIB_NAME}") + if(MSVC) + # MVC does not append 'lib'. Do it here, to have consistent name. + set_target_properties(png PROPERTIES PREFIX "lib") + set_target_properties(png PROPERTIES IMPORT_PREFIX "lib") + endif() target_link_libraries(png ${ZLIB_LIBRARIES} ${M_LIBRARY}) if(UNIX AND AWK) @@ -627,16 +617,26 @@ endif() if(PNG_STATIC) # does not work without changing name + set(PNG_LIB_NAME_STATIC png_static) add_library(png_static STATIC ${libpng_sources}) add_dependencies(png_static genfiles) # MSVC doesn't use a different file extension for shared vs. static # libs. We are able to change OUTPUT_NAME to remove the _static # for all other platforms. - set_target_properties(png_static PROPERTIES - OUTPUT_NAME "${PNG_LIB_NAME_STATIC}" - CLEAN_DIRECT_OUTPUT 1) + if(NOT MSVC) + set_target_properties(png_static PROPERTIES + OUTPUT_NAME "${PNG_LIB_NAME}" + CLEAN_DIRECT_OUTPUT 1) + else() + set_target_properties(png_static PROPERTIES + OUTPUT_NAME "${PNG_LIB_NAME}_static" + CLEAN_DIRECT_OUTPUT 1) + endif() list(APPEND PNG_LIB_TARGETS png_static) - set_target_properties(png_static PROPERTIES PREFIX "${PNG_PREPEND_LIB_NAME}") + if(MSVC) + # MSVC does not append 'lib'. Do it here, to have consistent name. + set_target_properties(png_static PROPERTIES PREFIX "lib") + endif() target_link_libraries(png_static ${ZLIB_LIBRARIES} ${M_LIBRARY}) endif() -- cgit v1.2.3 From efa9c2e9204e3a1fa255ef7304791772df515744 Mon Sep 17 00:00:00 2001 From: Jeremy Maitin-Shepard Date: Sun, 2 Oct 2022 14:37:59 -0700 Subject: 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 --- CMakeLists.txt | 55 +++++++++++++++++++++++++------------------------ scripts/gensrc.cmake.in | 2 +- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d4952524..d7e1734b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ # Revised by Owen Rudge, 2020 # Revised by Gleb Mazovetskiy, 2021 # Revised by Christopher Sean Morrison, 2022 +# Revised by Jeremy Maitin-Shepard, 2022 # Revised by Martin Storsjo, 2022 # Revised by Jon Creighton, 2023 # Revised by Gunther Nikl, 2023 @@ -309,7 +310,7 @@ if(NOT AWK OR ANDROID OR IOS) # No awk available to generate sources; use pre-built pnglibconf.h configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h) - add_custom_target(genfiles) # Dummy + add_custom_target(png_genfiles) # Dummy else() # Copy the awk scripts, converting their line endings to Unix (LF) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk @@ -411,7 +412,7 @@ else() DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa" "${CMAKE_CURRENT_BINARY_DIR}/scripts/options.awk" "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h") - add_custom_target(scripts_pnglibconf_c DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c") + add_custom_target(png_scripts_pnglibconf_c DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c") # Generate pnglibconf.c generate_source(OUTPUT "pnglibconf.c" @@ -442,14 +443,14 @@ else() 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) - add_custom_target(scripts_intprefix_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out") + add_custom_target(png_scripts_intprefix_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out") generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c" 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) - add_custom_target(scripts_prefix_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out") + add_custom_target(png_scripts_prefix_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out") # Generate pngprefix.h generate_source(OUTPUT "pngprefix.h" @@ -459,64 +460,64 @@ 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) - add_custom_target(scripts_sym_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out") + add_custom_target(png_scripts_sym_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out") generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt") - add_custom_target(scripts_symbols_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out") + add_custom_target(png_scripts_symbols_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out") generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c" 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) - add_custom_target(scripts_vers_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out") + add_custom_target(png_scripts_vers_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out") generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" - DEPENDS scripts_symbols_out + DEPENDS png_scripts_symbols_out "${CMAKE_CURRENT_BINARY_DIR}/scripts/checksym.awk" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def") - add_custom_target(scripts_symbols_chk + add_custom_target(png_scripts_symbols_chk DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk") generate_copy(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym" - DEPENDS scripts_sym_out) + DEPENDS png_scripts_sym_out) generate_copy(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers" - DEPENDS scripts_vers_out) + DEPENDS png_scripts_vers_out) - add_custom_target(genvers + add_custom_target(png_genvers DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers") - add_custom_target(gensym + add_custom_target(png_gensym DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym") - add_custom_target("genprebuilt" + add_custom_target(png_genprebuilt COMMAND "${CMAKE_COMMAND}" "-DOUTPUT=scripts/pnglibconf.h.prebuilt" -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") # A single target handles generation of all generated files. - add_custom_target(genfiles - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym" gensym - "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers" genvers + 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" scripts_intprefix_out - "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c" scripts_pnglibconf_c - "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" scripts_prefix_out - "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" scripts_sym_out - "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" scripts_symbols_chk - "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" scripts_symbols_out - "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" scripts_vers_out) + "${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(NOT AWK OR ANDROID OR IOS) # List the source code files. @@ -596,7 +597,7 @@ if(PNG_SHARED) add_library(png SHARED ${libpng_sources}) set(PNG_LIB_TARGETS png) set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME}) - add_dependencies(png genfiles) + add_dependencies(png png_genfiles) if(MSVC) # MVC does not append 'lib'. Do it here, to have consistent name. set_target_properties(png PROPERTIES PREFIX "lib") @@ -619,7 +620,7 @@ if(PNG_STATIC) # does not work without changing name set(PNG_LIB_NAME_STATIC png_static) add_library(png_static STATIC ${libpng_sources}) - add_dependencies(png_static genfiles) + add_dependencies(png_static png_genfiles) # MSVC doesn't use a different file extension for shared vs. static # libs. We are able to change OUTPUT_NAME to remove the _static # for all other platforms. @@ -643,7 +644,7 @@ endif() if(PNG_FRAMEWORK) set(PNG_LIB_NAME_FRAMEWORK png_framework) add_library(png_framework SHARED ${libpng_sources}) - add_dependencies(png_framework genfiles) + add_dependencies(png_framework png_genfiles) list(APPEND PNG_LIB_TARGETS png_framework) set_target_properties(png_framework PROPERTIES FRAMEWORK TRUE diff --git a/scripts/gensrc.cmake.in b/scripts/gensrc.cmake.in index f28a62266..e97fada20 100644 --- a/scripts/gensrc.cmake.in +++ b/scripts/gensrc.cmake.in @@ -128,7 +128,7 @@ elseif("${OUTPUT}" STREQUAL "scripts/pnglibconf.h.prebuilt") message(STATUS "Attempting to build scripts/pnglibconf.h.prebuilt") message(STATUS "This is a machine generated file, but if you want to make") - message(STATUS "a new one simply build the 'genfiles' target, and copy") + message(STATUS "a new one simply build the 'png_genfiles' target, and copy") message(STATUS "scripts/pnglibconf.out to scripts/pnglibconf.h.prebuilt") message(STATUS "AND set PNG_ZLIB_VERNUM to 0 (you MUST do this)") message(FATAL_ERROR "Stopping build") -- cgit v1.2.3 From aab24fa1b3ccaab8770902a3c50ea9564925d053 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Wed, 8 Feb 2023 19:44:31 +0200 Subject: 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. --- CMakeLists.txt | 174 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 91 insertions(+), 83 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7e1734b7..4d2eebfec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ # Written by Christian Ehrlicher, 2007 # Revised by Roger Lowman, 2009-2010 # Revised by Clifford Yapp, 2011-2012,2017 +# Revised by Claudio Bley, 2013 # Revised by Roger Leigh, 2016 # Revised by Andreas Franek, 2016 # Revised by Sam Serrels, 2017 @@ -34,6 +35,10 @@ cmake_policy(VERSION 3.1) project(libpng C ASM) enable_testing() +include(CMakeParseArguments) +include(CheckCSourceCompiles) +include(GNUInstallDirs) + set(PNGLIB_MAJOR 1) set(PNGLIB_MINOR 6) set(PNGLIB_REVISION 40) @@ -44,8 +49,6 @@ set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_REVISION}) set(PNGLIB_SHARED_SOVERSION ${PNGLIB_MAJOR}${PNGLIB_MINOR}) set(PNGLIB_SHARED_VERSION ${PNGLIB_SHARED_SOVERSION}.${PNGLIB_REVISION}.${PNGLIB_SUBREVISION}) -include(GNUInstallDirs) - # Allow users to specify location of zlib. # Useful if zlib is being built alongside this as a sub-project. option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" OFF) @@ -229,13 +232,12 @@ set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR}) # Distinguish between debug and release builds. set(CMAKE_DEBUG_POSTFIX "d") -include(CheckCSourceCompiles) option(ld-version-script "Enable linker version script" ON) if(ld-version-script AND NOT ANDROID AND NOT APPLE) # Check if LD supports linker scripts. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" " VERS_1 { - global: sym; + global: sym1; local: *; }; @@ -249,7 +251,8 @@ VERS_2 { ${CMAKE_REQUIRED_FLAGS} ${CMAKE_SHARED_LIBRARY_C_FLAGS} "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'") - check_c_source_compiles("void sym(void) {} + check_c_source_compiles(" +void sym1(void) {} void sym2(void) {} int main(void) {return 0;} " HAVE_LD_VERSION_SCRIPT) @@ -258,7 +261,8 @@ int main(void) {return 0;} ${CMAKE_REQUIRED_FLAGS_SAVE} ${CMAKE_SHARED_LIBRARY_C_FLAGS} "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map") - check_c_source_compiles("void sym(void) {} + check_c_source_compiles(" +void sym1(void) {} void sym2(void) {} int main(void) {return 0;} " HAVE_SOLARIS_LD_VERSION_SCRIPT) @@ -269,10 +273,10 @@ endif() # Find symbol prefix. Likely obsolete and unnecessary with recent # toolchains (it's not done in many other projects). -function(symbol_prefix) +function(find_symbol_prefix) set(SYMBOL_PREFIX) - execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E" "-" + execute_process(COMMAND "${CMAKE_C_COMPILER}" -E - INPUT_FILE /dev/null OUTPUT_VARIABLE OUT RESULT_VARIABLE STATUS) @@ -299,7 +303,7 @@ function(symbol_prefix) endfunction() if(UNIX) - symbol_prefix() + find_symbol_prefix() endif() find_program(AWK NAMES gawk awk) @@ -310,7 +314,7 @@ if(NOT AWK OR ANDROID OR IOS) # No awk available to generate sources; use pre-built pnglibconf.h configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h) - add_custom_target(png_genfiles) # Dummy + add_custom_target(png_genfiles) else() # Copy the awk scripts, converting their line endings to Unix (LF) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk @@ -328,7 +332,6 @@ else() # Generate .chk from .out with awk: # generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) - include(CMakeParseArguments) function(generate_chk) set(options) set(oneValueArgs INPUT OUTPUT) @@ -399,6 +402,13 @@ else() set(oneValueArgs INPUT OUTPUT) set(multiValueArgs DEPENDS) cmake_parse_arguments(_GCO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if(NOT _GCO_INPUT) + message(FATAL_ERROR "generate_copy: Missing INPUT argument") + endif() + if(NOT _GCO_OUTPUT) + message(FATAL_ERROR "generate_copy: Missing OUTPUT argument") + endif() + add_custom_command(OUTPUT "${_GCO_OUTPUT}" COMMAND "${CMAKE_COMMAND}" -E remove "${_GCO_OUTPUT}" @@ -412,14 +422,16 @@ else() DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa" "${CMAKE_CURRENT_BINARY_DIR}/scripts/options.awk" "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h") - add_custom_target(png_scripts_pnglibconf_c DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c") + add_custom_target(png_scripts_pnglibconf_c + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c") # Generate pnglibconf.c generate_source(OUTPUT "pnglibconf.c" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa" "${CMAKE_CURRENT_BINARY_DIR}/scripts/options.awk" "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h") - add_custom_target(pnglibconf_c DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c") + add_custom_target(pnglibconf_c + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c") if(PNG_PREFIX) set(PNGLIBCONF_H_EXTRA_DEPENDS @@ -432,49 +444,57 @@ else() generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" DEPENDS pnglibconf_c) - add_custom_target(pnglibconf_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out") + add_custom_target(pnglibconf_out + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out") # Generate pnglibconf.h generate_source(OUTPUT "pnglibconf.h" 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") + 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) - add_custom_target(png_scripts_intprefix_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out") + add_custom_target(png_scripts_intprefix_out + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out") generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c" 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) - add_custom_target(png_scripts_prefix_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out") + add_custom_target(png_scripts_prefix_out + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out") # Generate pngprefix.h generate_source(OUTPUT "pngprefix.h" DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS}) - add_custom_target(pngprefix_h DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h") + add_custom_target(pngprefix_h + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h") 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) - add_custom_target(png_scripts_sym_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out") + add_custom_target(png_scripts_sym_out + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out") generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt") - add_custom_target(png_scripts_symbols_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out") + add_custom_target(png_scripts_symbols_out + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out") generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c" 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) - add_custom_target(png_scripts_vers_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out") + add_custom_target(png_scripts_vers_out + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out") generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" @@ -591,49 +611,48 @@ endif() # Now build our target. include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIRS}) -unset(PNG_LIB_TARGETS) +set(PNG_LIB_TARGETS "") if(PNG_SHARED) - add_library(png SHARED ${libpng_sources}) - set(PNG_LIB_TARGETS png) - set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME}) - add_dependencies(png png_genfiles) + add_library(png_shared SHARED ${libpng_sources}) + add_dependencies(png_shared png_genfiles) + list(APPEND PNG_LIB_TARGETS png_shared) + set_target_properties(png_shared PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME}) if(MSVC) - # MVC does not append 'lib'. Do it here, to have consistent name. - set_target_properties(png PROPERTIES PREFIX "lib") - set_target_properties(png PROPERTIES IMPORT_PREFIX "lib") + # MSVC does not append 'lib'. Do it here, to have consistent names. + set_target_properties(png_shared PROPERTIES PREFIX "lib") + set_target_properties(png_shared PROPERTIES IMPORT_PREFIX "lib") endif() - target_link_libraries(png ${ZLIB_LIBRARIES} ${M_LIBRARY}) + target_link_libraries(png_shared ${ZLIB_LIBRARIES} ${M_LIBRARY}) if(UNIX AND AWK) if(HAVE_LD_VERSION_SCRIPT) - set_target_properties(png PROPERTIES + 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 PROPERTIES + set_target_properties(png_shared PROPERTIES LINK_FLAGS "-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'") endif() endif() + if(WIN32) + set_target_properties(png_shared PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL) + endif() endif() if(PNG_STATIC) - # does not work without changing name - set(PNG_LIB_NAME_STATIC png_static) add_library(png_static STATIC ${libpng_sources}) add_dependencies(png_static png_genfiles) + list(APPEND PNG_LIB_TARGETS png_static) # MSVC doesn't use a different file extension for shared vs. static # libs. We are able to change OUTPUT_NAME to remove the _static # for all other platforms. if(NOT MSVC) set_target_properties(png_static PROPERTIES - OUTPUT_NAME "${PNG_LIB_NAME}" - CLEAN_DIRECT_OUTPUT 1) + OUTPUT_NAME "${PNG_LIB_NAME}") else() set_target_properties(png_static PROPERTIES - OUTPUT_NAME "${PNG_LIB_NAME}_static" - CLEAN_DIRECT_OUTPUT 1) + OUTPUT_NAME "${PNG_LIB_NAME}_static") endif() - list(APPEND PNG_LIB_TARGETS png_static) if(MSVC) # MSVC does not append 'lib'. Do it here, to have consistent name. set_target_properties(png_static PROPERTIES PREFIX "lib") @@ -642,7 +661,6 @@ if(PNG_STATIC) endif() if(PNG_FRAMEWORK) - set(PNG_LIB_NAME_FRAMEWORK png_framework) add_library(png_framework SHARED ${libpng_sources}) add_dependencies(png_framework png_genfiles) list(APPEND PNG_LIB_TARGETS png_framework) @@ -661,12 +679,7 @@ endif() if(NOT PNG_LIB_TARGETS) message(SEND_ERROR "No library variant selected to build. " "Please enable at least one of the following options: " - "PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK") -endif() - -if(PNG_SHARED AND WIN32) - set_target_properties(png PROPERTIES - DEFINE_SYMBOL PNG_BUILD_DLL) + "PNG_SHARED, PNG_STATIC, PNG_FRAMEWORK") endif() function(png_add_test) @@ -674,7 +687,6 @@ function(png_add_test) set(oneValueArgs NAME COMMAND) set(multiValueArgs OPTIONS FILES) cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if(NOT _PAT_NAME) message(FATAL_ERROR "png_add_test: Missing NAME argument") endif() @@ -690,7 +702,7 @@ function(png_add_test) @ONLY) add_test(NAME "${_PAT_NAME}" COMMAND "${CMAKE_COMMAND}" - "-DLIBPNG=$" + "-DLIBPNG=$" "-DTEST_COMMAND=$" -P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake") endfunction() @@ -706,14 +718,14 @@ if(PNG_TESTS AND PNG_SHARED) set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png") add_executable(pngtest ${pngtest_sources}) - target_link_libraries(pngtest png) + target_link_libraries(pngtest png_shared) png_add_test(NAME pngtest COMMAND pngtest FILES "${PNGTEST_PNG}") add_executable(pngvalid ${pngvalid_sources}) - target_link_libraries(pngvalid png) + target_link_libraries(pngvalid png_shared) png_add_test(NAME pngvalid-gamma-16-to-8 COMMAND pngvalid @@ -759,7 +771,7 @@ if(PNG_TESTS AND PNG_SHARED) OPTIONS --transform) add_executable(pngstest ${pngstest_sources}) - target_link_libraries(pngstest png) + target_link_libraries(pngstest png_shared) foreach(gamma_type 1.8 linear none sRGB) foreach(alpha_type none alpha) @@ -814,7 +826,7 @@ if(PNG_TESTS AND PNG_SHARED) endforeach() add_executable(pngunknown ${pngunknown_sources}) - target_link_libraries(pngunknown png) + target_link_libraries(pngunknown png_shared) png_add_test(NAME pngunknown-discard COMMAND pngunknown @@ -846,7 +858,7 @@ if(PNG_TESTS AND PNG_SHARED) FILES "${PNGTEST_PNG}") add_executable(pngimage ${pngimage_sources}) - target_link_libraries(pngimage png) + target_link_libraries(pngimage png_shared) png_add_test(NAME pngimage-quick COMMAND pngimage @@ -860,7 +872,7 @@ endif() if(PNG_SHARED AND PNG_EXECUTABLES) add_executable(pngfix ${pngfix_sources}) - target_link_libraries(pngfix png) + target_link_libraries(pngfix png_shared) set(PNG_BIN_TARGETS pngfix) add_executable(png-fix-itxt ${png_fix_itxt_sources}) @@ -868,56 +880,53 @@ if(PNG_SHARED AND PNG_EXECUTABLES) list(APPEND PNG_BIN_TARGETS png-fix-itxt) endif() -# Creates a symlink from src to dest (if possible), or, alternatively, -# copies src to dest if different. -include(CMakeParseArguments) +# Create a symlink from src to dest (if possible), or, alternatively, +# copy src to dest if different. function(create_symlink DEST_FILE) - cmake_parse_arguments(S "" "FILE;TARGET" "" ${ARGN}) - - if(NOT S_TARGET AND NOT S_FILE) - message(FATAL_ERROR "create_symlink: Missing TARGET or FILE argument") + 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") endif() - - if(S_TARGET AND S_FILE) + if(_SYM_FILE AND _SYM_TARGET) message(FATAL_ERROR "create_symlink: " - "Both source file ${S_FILE} and build target ${S_TARGET} arguments are present; " - "can only have one") + "The arguments FILE (${_SYM_FILE}) and TARGET (${_SYM_TARGET}) " + "are mutually-exclusive") endif() - if(S_FILE) + if(_SYM_FILE) # If we don't need to symlink something that's coming from a build target, # we can go ahead and symlink/copy at configure time. if(CMAKE_HOST_WIN32 AND NOT CYGWIN) execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_if_different - ${S_FILE} ${DEST_FILE} + ${_SYM_FILE} ${DEST_FILE} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") else() execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink - ${S_FILE} ${DEST_FILE} + ${_SYM_FILE} ${DEST_FILE} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") endif() endif() - if(S_TARGET) + if(_SYM_TARGET) # We need to use generator expressions, which can be a bit tricky. # For simplicity, make the symlink a POST_BUILD step, and use the TARGET # signature of add_custom_command. if(CMAKE_HOST_WIN32 AND NOT CYGWIN) - add_custom_command(TARGET ${S_TARGET} + add_custom_command(TARGET ${_SYM_TARGET} POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_if_different - $ - $/${DEST_FILE}) + $ + $/${DEST_FILE}) else() - add_custom_command(TARGET ${S_TARGET} + add_custom_command(TARGET ${_SYM_TARGET} POST_BUILD COMMAND "${CMAKE_COMMAND}" -E create_symlink - $ - $/${DEST_FILE}) + $ + $/${DEST_FILE}) endif() endif() endfunction() @@ -960,10 +969,9 @@ endif() # Set up links. if(PNG_SHARED) - set_target_properties(png PROPERTIES - VERSION ${PNGLIB_SHARED_VERSION} - SOVERSION ${PNGLIB_SHARED_SOVERSION} - CLEAN_DIRECT_OUTPUT 1) + set_target_properties(png_shared PROPERTIES + VERSION ${PNGLIB_SHARED_VERSION} + SOVERSION ${PNGLIB_SHARED_SOVERSION}) endif() # Install. @@ -978,14 +986,14 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) if(PNG_SHARED) # Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin if(CYGWIN OR MINGW) - create_symlink(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png) - install(FILES $/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} + create_symlink(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png_shared) + install(FILES $/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() if(NOT WIN32) - create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png) - install(FILES $/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} + create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png_shared) + install(FILES $/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() endif() -- cgit v1.2.3 From efc96c9d59a9052c4db9245ca0a204fc267fe396 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 12 Feb 2023 17:22:08 +0200 Subject: 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 Signed-off-by: Cosmin Truta --- CMakeLists.txt | 146 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 72 insertions(+), 74 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d2eebfec..e08f4c445 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ # Revised by Owen Rudge, 2020 # Revised by Gleb Mazovetskiy, 2021 # Revised by Christopher Sean Morrison, 2022 +# Revised by B. Scott Michel, 2022 # Revised by Jeremy Maitin-Shepard, 2022 # Revised by Martin Storsjo, 2022 # Revised by Jon Creighton, 2023 @@ -44,15 +45,31 @@ set(PNGLIB_MINOR 6) set(PNGLIB_REVISION 40) #set(PNGLIB_SUBREVISION 0) set(PNGLIB_SUBREVISION "git") -set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_REVISION}) -set(PNGLIB_SHARED_SOVERSION ${PNGLIB_MAJOR}${PNGLIB_MINOR}) -set(PNGLIB_SHARED_VERSION ${PNGLIB_SHARED_SOVERSION}.${PNGLIB_REVISION}.${PNGLIB_SUBREVISION}) +set(PNGLIB_ABI_VERSION ${PNGLIB_MAJOR}${PNGLIB_MINOR}) +set(PNGLIB_SHARED_VERSION ${PNGLIB_ABI_VERSION}.${PNGLIB_REVISION}.${PNGLIB_SUBREVISION}) + +# 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 "" + CACHE STRING "Prefix to prepend to the API function names") + +# Allow the users to import their own extra configuration settings. +set(DFA_XTRA "" + CACHE FILEPATH "File containing extra configuration settings") + +# Allow the users to configure the following build options. +option(PNG_SHARED "Build libpng as a shared lib" ON) +option(PNG_STATIC "Build libpng as a static lib" ON) +option(PNG_FRAMEWORK "Build libpng as a Mac OS X framework" OFF) +option(PNG_EXECUTABLES "Build libpng executables" ON) +option(PNG_TESTS "Build libpng tests" ON) +option(PNG_DEBUG "Enable debug output" OFF) +option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" ON) -# Allow users to specify location of zlib. +# Allow the users to specify a location of zlib. # Useful if zlib is being built alongside this as a sub-project. -option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" OFF) - +option(PNG_BUILD_ZLIB "Custom zlib location, else find_package is used" OFF) if(NOT PNG_BUILD_ZLIB) find_package(ZLIB REQUIRED) include_directories(${ZLIB_INCLUDE_DIRS}) @@ -68,20 +85,6 @@ else() set(M_LIBRARY "") endif() -# Public CMake configuration variables. -option(PNG_SHARED "Build shared lib" ON) -option(PNG_STATIC "Build static lib" ON) -option(PNG_EXECUTABLES "Build libpng executables" ON) -option(PNG_TESTS "Build libpng tests" ON) - -# Many more configuration options could be added here. -option(PNG_FRAMEWORK "Build OS X framework" OFF) -option(PNG_DEBUG "Build with debug output" OFF) -option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" ON) - -set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names") -set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings") - # CMake currently sets CMAKE_SYSTEM_PROCESSOR to one of x86_64 or arm64 on macOS, # based upon the OS architecture, not the target architecture. As such, we need # to check CMAKE_OSX_ARCHITECTURES to identify which hardware-specific flags to @@ -226,9 +229,6 @@ endif() endif(PNG_HARDWARE_OPTIMIZATIONS) -# Set PNG_LIB_NAME. -set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR}) - # Distinguish between debug and release builds. set(CMAKE_DEBUG_POSTFIX "d") @@ -600,7 +600,8 @@ set(png_fix_itxt_sources contrib/tools/png-fix-itxt.c ) -if(MSVC) +if(MSVC OR (WIN32 AND (CMAKE_C_COMPILER_ID MATCHES ".*Clang"))) + add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) add_definitions(-D_CRT_SECURE_NO_DEPRECATE) endif() @@ -608,23 +609,38 @@ if(PNG_DEBUG) add_definitions(-DPNG_DEBUG) endif() -# Now build our target. +# Now build our targets. include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIRS}) -set(PNG_LIB_TARGETS "") +# Initialize the list of libpng library targets. +set(PNG_LIBRARY_TARGETS "") + +# Initialize the libpng library file names. +if(UNIX + OR (WIN32 AND NOT "${CMAKE_SHARED_LIBRARY_PREFIX}" STREQUAL "") + OR (WIN32 AND NOT "${CMAKE_STATIC_LIBRARY_PREFIX}" STREQUAL "")) + # We are on a Unix or Unix-like toolchain like the GNU toolchain on Windows. + # Library file names are expected to have an implicit prefix such as "lib". + # Let CMake prepend and append its usual prefixes and suffixes by default. + set(PNG_SHARED_OUTPUT_NAME "png${PNGLIB_ABI_VERSION}") + set(PNG_STATIC_OUTPUT_NAME "png${PNGLIB_ABI_VERSION}") +else() + # We are, most likely, on a Windows toolchain like MSVC, Clang on Windows, + # Borland/Embarcadero, etc. We need to specify the "libpng" name explicitly. + # We also need to use a custom suffix, in order to distinguish between the + # shared import library name and the static library name. + set(PNG_SHARED_OUTPUT_NAME "libpng${PNGLIB_ABI_VERSION}") + set(PNG_STATIC_OUTPUT_NAME "libpng${PNGLIB_ABI_VERSION}_static") +endif() if(PNG_SHARED) add_library(png_shared SHARED ${libpng_sources}) add_dependencies(png_shared png_genfiles) - list(APPEND PNG_LIB_TARGETS png_shared) - set_target_properties(png_shared PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME}) - if(MSVC) - # MSVC does not append 'lib'. Do it here, to have consistent names. - set_target_properties(png_shared PROPERTIES PREFIX "lib") - set_target_properties(png_shared PROPERTIES IMPORT_PREFIX "lib") - endif() - target_link_libraries(png_shared ${ZLIB_LIBRARIES} ${M_LIBRARY}) - + list(APPEND PNG_LIBRARY_TARGETS png_shared) + set_target_properties(png_shared PROPERTIES + OUTPUT_NAME "${PNG_SHARED_OUTPUT_NAME}" + VERSION "${PNGLIB_SHARED_VERSION}" + SOVERSION "${PNGLIB_ABI_VERSION}") if(UNIX AND AWK) if(HAVE_LD_VERSION_SCRIPT) set_target_properties(png_shared PROPERTIES @@ -637,46 +653,35 @@ if(PNG_SHARED) if(WIN32) set_target_properties(png_shared PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL) endif() + target_link_libraries(png_shared ${ZLIB_LIBRARIES} ${M_LIBRARY}) endif() if(PNG_STATIC) add_library(png_static STATIC ${libpng_sources}) add_dependencies(png_static png_genfiles) - list(APPEND PNG_LIB_TARGETS png_static) - # MSVC doesn't use a different file extension for shared vs. static - # libs. We are able to change OUTPUT_NAME to remove the _static - # for all other platforms. - if(NOT MSVC) - set_target_properties(png_static PROPERTIES - OUTPUT_NAME "${PNG_LIB_NAME}") - else() - set_target_properties(png_static PROPERTIES - OUTPUT_NAME "${PNG_LIB_NAME}_static") - endif() - if(MSVC) - # MSVC does not append 'lib'. Do it here, to have consistent name. - set_target_properties(png_static PROPERTIES PREFIX "lib") - endif() + list(APPEND PNG_LIBRARY_TARGETS png_static) + set_target_properties(png_static PROPERTIES + OUTPUT_NAME "${PNG_STATIC_OUTPUT_NAME}") target_link_libraries(png_static ${ZLIB_LIBRARIES} ${M_LIBRARY}) endif() if(PNG_FRAMEWORK) add_library(png_framework SHARED ${libpng_sources}) add_dependencies(png_framework png_genfiles) - list(APPEND PNG_LIB_TARGETS png_framework) + 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 + 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) + OUTPUT_NAME "png") target_link_libraries(png_framework ${ZLIB_LIBRARIES} ${M_LIBRARY}) endif() -if(NOT PNG_LIB_TARGETS) +if(NOT PNG_LIBRARY_TARGETS) message(SEND_ERROR "No library variant selected to build. " "Please enable at least one of the following options: " "PNG_SHARED, PNG_STATIC, PNG_FRAMEWORK") @@ -958,25 +963,18 @@ if(NOT WIN32 OR CYGWIN OR MINGW) set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) set(LIBS "-lz -lm") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc + ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}.pc @ONLY) - create_symlink(libpng.pc FILE ${PNGLIB_NAME}.pc) + create_symlink(libpng.pc FILE libpng${PNGLIB_ABI_VERSION}.pc) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in - ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config + ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config @ONLY) - create_symlink(libpng-config FILE ${PNGLIB_NAME}-config) -endif() - -# Set up links. -if(PNG_SHARED) - set_target_properties(png_shared PROPERTIES - VERSION ${PNGLIB_SHARED_VERSION} - SOVERSION ${PNGLIB_SHARED_SOVERSION}) + create_symlink(libpng-config FILE libpng${PNGLIB_ABI_VERSION}-config) endif() # Install. if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) - install(TARGETS ${PNG_LIB_TARGETS} + install(TARGETS ${PNG_LIBRARY_TARGETS} EXPORT libpng RUNTIME DESTINATION bin LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -1011,13 +1009,13 @@ if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL) install(FILES ${libpng_public_hdrs} DESTINATION include) install(FILES ${libpng_public_hdrs} - DESTINATION include/${PNGLIB_NAME}) + DESTINATION include/libpng${PNGLIB_ABI_VERSION}) endif() if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL) if(NOT WIN32 OR CYGWIN OR MINGW) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config DESTINATION bin) endif() endif() @@ -1039,9 +1037,9 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL) DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION ${CMAKE_INSTALL_BINDIR}) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() endif() @@ -1050,7 +1048,7 @@ endif() if(NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL) install(EXPORT libpng DESTINATION lib/libpng - FILE lib${PNG_LIB_NAME}.cmake) + FILE libpng${PNGLIB_ABI_VERSION}.cmake) endif() # TODO: Create MSVC import lib for MinGW-compiled shared lib. -- cgit v1.2.3 From e519af8b49f52c4ac400f50f23b48ebe36a5f4df Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 12 Feb 2023 22:31:11 +0200 Subject: 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 --- CMakeLists.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e08f4c445..90b53f37c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,13 @@ set(PNGLIB_SHARED_VERSION ${PNGLIB_ABI_VERSION}.${PNGLIB_REVISION}.${PNGLIB_SUBR 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" + CACHE STRING "Postfix to append to library file names under the Debug configuration") + # Allow the users to import their own extra configuration settings. set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings") @@ -229,9 +236,6 @@ endif() endif(PNG_HARDWARE_OPTIMIZATIONS) -# Distinguish between debug and release builds. -set(CMAKE_DEBUG_POSTFIX "d") - option(ld-version-script "Enable linker version script" ON) if(ld-version-script AND NOT ANDROID AND NOT APPLE) # Check if LD supports linker scripts. @@ -639,6 +643,7 @@ if(PNG_SHARED) 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}") if(UNIX AND AWK) @@ -661,7 +666,8 @@ if(PNG_STATIC) 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}") + OUTPUT_NAME "${PNG_STATIC_OUTPUT_NAME}" + DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}") target_link_libraries(png_static ${ZLIB_LIBRARIES} ${M_LIBRARY}) endif() -- cgit v1.2.3 From 82097c2108b07625a03fd8f3d10d90100a66cd02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20Gonza=CC=81lez?= Date: Tue, 14 Feb 2023 17:26:12 +0100 Subject: Fix a doc typo in pnglibconf.dfa Signed-off-by: Cosmin Truta --- scripts/pnglibconf.dfa | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/pnglibconf.dfa b/scripts/pnglibconf.dfa index 261954e47..003e0f2f0 100644 --- a/scripts/pnglibconf.dfa +++ b/scripts/pnglibconf.dfa @@ -69,9 +69,9 @@ file pnglibconf.h scripts/pnglibconf.dfa PNGLCONF_H # # 1) Create 'pngusr.h', enter the required private build information # detailed below and #define PNG_NO_