mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
build: Move scripts/*.cmake.in to scripts/cmake/; add cmake/AUTHORS.md
From the libpng licensing point of view, the build projects, the build scripts, the test scripts, the CI verification scripts, et cetera, have not traditionally been part of libpng proper, although some of these, including the CMake-based build, have been released under the libpng license. Considering how the CMake build grew as a result of many contributions from many contributing authors over a long time, one may argue that it almost became an individual piece of software in its own right. Moving on, everything CMake-related shall be placed in the subdirectory scripts/cmake/ (except, of course, the main CMakeLists.txt). Moreover, contributing authors shall be acknowledged in scripts/cmake/AUTHORS.md. Please see scripts/cmake/README.md for more information.
This commit is contained in:
35
scripts/cmake/AUTHORS.md
Normal file
35
scripts/cmake/AUTHORS.md
Normal file
@@ -0,0 +1,35 @@
|
||||
CMake Files, Lists and Scripts for the PNG Reference Library
|
||||
============================================================
|
||||
|
||||
Author List
|
||||
-----------
|
||||
|
||||
* Alex Gaynor
|
||||
* Andreas Franek
|
||||
* B. Scott Michel
|
||||
* Cameron Cawley
|
||||
* Christian Ehrlicher
|
||||
* Christopher Sean Morrison
|
||||
* Claudio Bley
|
||||
* Clifford Yapp
|
||||
* Clinton Ingram
|
||||
* Cosmin Truta
|
||||
* David Callu
|
||||
* Gleb Mazovetskiy
|
||||
* Glenn Randers-Pehrson
|
||||
* Gunther Nikl
|
||||
* Jeremy Maitin-Shepard
|
||||
* John Bowler
|
||||
* Jon Creighton
|
||||
* Kyle Bentley
|
||||
* Martin Storsjö
|
||||
* Owen Rudge
|
||||
* Roger Leigh
|
||||
* Roger Lowman
|
||||
* Sam Serrels
|
||||
* Simon Hausmann
|
||||
* Steve Robinson
|
||||
* Timothy Lyanguzov
|
||||
* Tyler Kropp
|
||||
* Vadim Barkov
|
||||
* Vicky Pfau
|
||||
35
scripts/cmake/README.md
Normal file
35
scripts/cmake/README.md
Normal file
@@ -0,0 +1,35 @@
|
||||
CMake Files, Lists and Scripts for the PNG Reference Library
|
||||
============================================================
|
||||
|
||||
Copyright Notice
|
||||
----------------
|
||||
|
||||
* Copyright (c) 2018-2024 Cosmin Truta.
|
||||
* Copyright (c) 2007-2018 Glenn Randers-Pehrson.
|
||||
* Originally written by Christian Ehrlicher, 2007.
|
||||
|
||||
Use, modification and distribution of the CMake
|
||||
files in the libpng distribution are subject to
|
||||
the same licensing terms and conditions as libpng.
|
||||
Please see the copyright notice in `png.h` or visit
|
||||
http://libpng.org/pub/png/src/libpng-LICENSE.txt
|
||||
|
||||
File List
|
||||
---------
|
||||
|
||||
CMakeLists.txt ==> The main CMake lists file
|
||||
scripts/cmake/AUTHORS.md ==> The Authors file
|
||||
scripts/cmake/README.md ==> This file
|
||||
scripts/cmake/genchk.cmake.in ==> Template for genchk.cmake
|
||||
scripts/cmake/genout.cmake.in ==> Template for genout.cmake
|
||||
scripts/cmake/gensrc.cmake.in ==> Template for gensrc.cmake
|
||||
scripts/cmake/test.cmake.in ==> Template for test.cmake
|
||||
|
||||
Acknowledgements
|
||||
----------------
|
||||
|
||||
See the accompanying file `scripts/cmake/AUTHORS.md`
|
||||
for the list of Contributing Authors.
|
||||
|
||||
If you are a Contributing Author, please make sure
|
||||
that you are being acknowledged.
|
||||
42
scripts/cmake/genchk.cmake.in
Normal file
42
scripts/cmake/genchk.cmake.in
Normal file
@@ -0,0 +1,42 @@
|
||||
# genchk.cmake.in
|
||||
# Generate .chk from .out with awk (generic), based upon the automake logic.
|
||||
|
||||
# Copyright (c) 2022-2024 Cosmin Truta
|
||||
# Copyright (c) 2016 Glenn Randers-Pehrson
|
||||
# Written by Roger Leigh, 2016
|
||||
#
|
||||
# Use, modification and distribution are subject to
|
||||
# the same licensing terms and conditions as libpng.
|
||||
# Please see the copyright notice in png.h or visit
|
||||
# http://libpng.org/pub/png/src/libpng-LICENSE.txt
|
||||
#
|
||||
# SPDX-License-Identifier: libpng-2.0
|
||||
|
||||
# Variables substituted from CMakeLists.txt
|
||||
set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@")
|
||||
set(BINDIR "@CMAKE_CURRENT_BINARY_DIR@")
|
||||
|
||||
set(AWK "@AWK@")
|
||||
|
||||
get_filename_component(INPUTEXT "${INPUT}" EXT)
|
||||
get_filename_component(OUTPUTEXT "${OUTPUT}" EXT)
|
||||
get_filename_component(INPUTBASE "${INPUT}" NAME_WE)
|
||||
get_filename_component(OUTPUTBASE "${OUTPUT}" NAME_WE)
|
||||
get_filename_component(INPUTDIR "${INPUT}" PATH)
|
||||
get_filename_component(OUTPUTDIR "${OUTPUT}" PATH)
|
||||
|
||||
if(INPUTEXT STREQUAL ".out" AND OUTPUTEXT STREQUAL ".chk")
|
||||
# Generate .chk from .out with awk (generic)
|
||||
file(REMOVE "${OUTPUT}" "${OUTPUTDIR}/${OUTPUTBASE}.new")
|
||||
execute_process(COMMAND "${AWK}" -f "${BINDIR}/scripts/checksym.awk"
|
||||
"${SRCDIR}/scripts/${INPUTBASE}.def"
|
||||
"of=${OUTPUTDIR}/${OUTPUTBASE}.new"
|
||||
"${INPUT}"
|
||||
RESULT_VARIABLE AWK_FAIL)
|
||||
if(AWK_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate ${OUTPUTDIR}/${OUTPUTBASE}.new")
|
||||
endif()
|
||||
file(RENAME "${OUTPUTDIR}/${OUTPUTBASE}.new" "${OUTPUT}")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported conversion: ${INPUTEXT} to ${OUTPUTEXT}")
|
||||
endif()
|
||||
97
scripts/cmake/genout.cmake.in
Normal file
97
scripts/cmake/genout.cmake.in
Normal file
@@ -0,0 +1,97 @@
|
||||
# genout.cmake.in
|
||||
# Generate .out from .c with awk (generic), based upon the automake logic.
|
||||
|
||||
# Copyright (c) 2022-2024 Cosmin Truta
|
||||
# Copyright (c) 2016 Glenn Randers-Pehrson
|
||||
# Written by Roger Leigh, 2016
|
||||
#
|
||||
# Use, modification and distribution are subject to
|
||||
# the same licensing terms and conditions as libpng.
|
||||
# Please see the copyright notice in png.h or visit
|
||||
# http://libpng.org/pub/png/src/libpng-LICENSE.txt
|
||||
#
|
||||
# SPDX-License-Identifier: libpng-2.0
|
||||
|
||||
# Variables substituted from CMakeLists.txt
|
||||
set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@")
|
||||
set(BINDIR "@CMAKE_CURRENT_BINARY_DIR@")
|
||||
|
||||
set(AWK "@AWK@")
|
||||
set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@")
|
||||
set(CMAKE_C_FLAGS @CMAKE_C_FLAGS@)
|
||||
set(INCDIR "@CMAKE_CURRENT_BINARY_DIR@")
|
||||
set(PNG_PREFIX "@PNG_PREFIX@")
|
||||
set(PNGLIB_MAJOR "@PNGLIB_MAJOR@")
|
||||
set(PNGLIB_MINOR "@PNGLIB_MINOR@")
|
||||
set(PNGLIB_VERSION "@PNGLIB_VERSION@")
|
||||
set(ZLIBINCDIR "@ZLIB_INCLUDE_DIRS@")
|
||||
|
||||
set(PLATFORM_C_FLAGS)
|
||||
if(APPLE)
|
||||
set(CMAKE_OSX_INTERNAL_ARCHITECTURES "@CMAKE_OSX_INTERNAL_ARCHITECTURES@")
|
||||
set(CMAKE_OSX_SYSROOT "@CMAKE_OSX_SYSROOT@")
|
||||
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})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
get_filename_component(INPUTEXT "${INPUT}" EXT)
|
||||
get_filename_component(OUTPUTEXT "${OUTPUT}" EXT)
|
||||
get_filename_component(INPUTBASE "${INPUT}" NAME_WE)
|
||||
get_filename_component(OUTPUTBASE "${OUTPUT}" NAME_WE)
|
||||
get_filename_component(INPUTDIR "${INPUT}" PATH)
|
||||
get_filename_component(OUTPUTDIR "${OUTPUT}" PATH)
|
||||
|
||||
if(INPUTEXT STREQUAL ".c" AND OUTPUTEXT STREQUAL ".out")
|
||||
get_filename_component(GENDIR "${OUTPUT}" PATH)
|
||||
file(MAKE_DIRECTORY "${GENDIR}")
|
||||
|
||||
file(REMOVE "${OUTPUT}.tf1" "${OUTPUT}.tf2")
|
||||
|
||||
set(INCLUDES "-I${INCDIR}")
|
||||
if(ZLIBINCDIR)
|
||||
foreach(dir ${ZLIBINCDIR})
|
||||
list(APPEND INCLUDES "-I${dir}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(PNG_PREFIX)
|
||||
set(PNG_PREFIX_DEF "-DPNG_PREFIX=${PNG_PREFIX}")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E"
|
||||
${CMAKE_C_FLAGS}
|
||||
${PLATFORM_C_FLAGS}
|
||||
"-I${SRCDIR}"
|
||||
"-I${BINDIR}"
|
||||
${INCLUDES}
|
||||
"-DPNGLIB_LIBNAME=PNG${PNGLIB_MAJOR}${PNGLIB_MINOR}_0"
|
||||
"-DPNGLIB_VERSION=${PNGLIB_VERSION}"
|
||||
"-DSYMBOL_PREFIX=${SYMBOL_PREFIX}"
|
||||
"-DPNG_NO_USE_READ_MACROS"
|
||||
"-DPNG_BUILDING_SYMBOL_TABLE"
|
||||
${PNG_PREFIX_DEF}
|
||||
"${INPUT}"
|
||||
OUTPUT_FILE "${OUTPUT}.tf1"
|
||||
WORKING_DIRECTORY "${BINDIR}"
|
||||
RESULT_VARIABLE CPP_FAIL)
|
||||
if(CPP_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate ${OUTPUT}.tf1")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/dfn.awk"
|
||||
"out=${OUTPUT}.tf2" "${OUTPUT}.tf1"
|
||||
WORKING_DIRECTORY "${BINDIR}"
|
||||
RESULT_VARIABLE AWK_FAIL)
|
||||
if(AWK_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate ${OUTPUT}.tf2")
|
||||
endif()
|
||||
|
||||
file(REMOVE "${OUTPUT}.tf1")
|
||||
file(RENAME "${OUTPUT}.tf2" "${OUTPUT}")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported conversion: ${INPUTEXT} to ${OUTPUTEXT}")
|
||||
endif()
|
||||
144
scripts/cmake/gensrc.cmake.in
Normal file
144
scripts/cmake/gensrc.cmake.in
Normal file
@@ -0,0 +1,144 @@
|
||||
# gensrc.cmake.in
|
||||
# Generate source files with awk, based upon the automake logic.
|
||||
|
||||
# Copyright (c) 2022-2024 Cosmin Truta
|
||||
# Copyright (c) 2016 Glenn Randers-Pehrson
|
||||
# Written by Roger Leigh, 2016
|
||||
#
|
||||
# Use, modification and distribution are subject to
|
||||
# the same licensing terms and conditions as libpng.
|
||||
# Please see the copyright notice in png.h or visit
|
||||
# http://libpng.org/pub/png/src/libpng-LICENSE.txt
|
||||
#
|
||||
# SPDX-License-Identifier: libpng-2.0
|
||||
|
||||
# Variables substituted from CMakeLists.txt
|
||||
set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@")
|
||||
set(BINDIR "@CMAKE_CURRENT_BINARY_DIR@")
|
||||
|
||||
set(AWK "@AWK@")
|
||||
set(DFA_XTRA "@DFA_XTRA@")
|
||||
set(PNG_PREFIX "@PNG_PREFIX@")
|
||||
set(PNGLIB_VERSION "@PNGLIB_VERSION@")
|
||||
|
||||
if(OUTPUT STREQUAL "scripts/pnglibconf.c")
|
||||
# Generate scripts/pnglibconf.c
|
||||
|
||||
file(REMOVE "${BINDIR}/pnglibconf.tf6" "${BINDIR}/pnglibconf.tf7")
|
||||
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "com ${PNGLIB_VERSION} STANDARD API DEFINITION"
|
||||
COMMAND "${AWK}" -f "${SRCDIR}/scripts/options.awk"
|
||||
"out=pnglibconf.tf6" "logunsupported=1" "version=search"
|
||||
"${SRCDIR}/pngconf.h" "-"
|
||||
"${SRCDIR}/scripts/pnglibconf.dfa"
|
||||
WORKING_DIRECTORY "${BINDIR}"
|
||||
RESULT_VARIABLE AWK_FAIL)
|
||||
if(AWK_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate pnglibconf.tf6")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/options.awk"
|
||||
"out=pnglibconf.tf7" "pnglibconf.tf6"
|
||||
WORKING_DIRECTORY "${BINDIR}"
|
||||
RESULT_VARIABLE AWK_FAIL)
|
||||
if(AWK_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate pnglibconf.tf7")
|
||||
endif()
|
||||
|
||||
file(REMOVE "pnglibconf.tf6")
|
||||
file(MAKE_DIRECTORY "${BINDIR}/scripts")
|
||||
file(RENAME "pnglibconf.tf7" "${BINDIR}/scripts/pnglibconf.c")
|
||||
|
||||
elseif(OUTPUT STREQUAL "pnglibconf.c")
|
||||
# Generate pnglibconf.c
|
||||
|
||||
file(REMOVE "${BINDIR}/pnglibconf.tf4" "${BINDIR}/pnglibconf.tf5")
|
||||
|
||||
execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/options.awk"
|
||||
out=pnglibconf.tf4 version=search
|
||||
${SRCDIR}/pngconf.h ${SRCDIR}/scripts/pnglibconf.dfa
|
||||
${SRCDIR}/pngusr.dfa ${DFA_XTRA}
|
||||
WORKING_DIRECTORY "${BINDIR}"
|
||||
RESULT_VARIABLE AWK_FAIL)
|
||||
if(AWK_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate pnglibconf.tf4")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/options.awk"
|
||||
out=pnglibconf.tf5 pnglibconf.tf4
|
||||
WORKING_DIRECTORY "${BINDIR}"
|
||||
RESULT_VARIABLE AWK_FAIL)
|
||||
if(AWK_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate pnglibconf.tf5")
|
||||
endif()
|
||||
|
||||
file(REMOVE "pnglibconf.tf4")
|
||||
file(MAKE_DIRECTORY "${BINDIR}/scripts")
|
||||
file(RENAME "pnglibconf.tf5" "${BINDIR}/pnglibconf.c")
|
||||
|
||||
elseif(OUTPUT STREQUAL "pnglibconf.h")
|
||||
# Generate pnglibconf.h
|
||||
|
||||
file(REMOVE "${BINDIR}/${OUTPUT}")
|
||||
if(PNG_PREFIX)
|
||||
file(REMOVE "pnglibconf.tf8")
|
||||
|
||||
execute_process(COMMAND "${AWK}" "s==0 && NR>1{print prev}
|
||||
s==0{prev=\$0}
|
||||
s==1{print \"#define\", \$1, \"${PNG_PREFIX}\" \$1}
|
||||
s==2{print \"#define ${PNG_PREFIX}png_\" \$1, \"PNG_\" \$1}
|
||||
END{print prev}" s=0 pnglibconf.out s=1 "${BINDIR}/scripts/prefix.out"
|
||||
s=2 "${SRCDIR}/scripts/macro.lst"
|
||||
OUTPUT_FILE pnglibconf.tf8
|
||||
RESULT_VARIABLE AWK_FAIL)
|
||||
if(AWK_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate pnglibconf.tf8")
|
||||
endif()
|
||||
|
||||
file(RENAME "pnglibconf.tf8" "${BINDIR}/${OUTPUT}")
|
||||
else()
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${BINDIR}/pnglibconf.out"
|
||||
"${BINDIR}/${OUTPUT}"
|
||||
RESULT_VARIABLE COPY_FAIL)
|
||||
if(COPY_FAIL)
|
||||
message(FATAL_ERROR "Failed to create pnglibconf.h")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
elseif(OUTPUT STREQUAL "pngprefix.h")
|
||||
# Generate pngprefix.h
|
||||
|
||||
file(REMOVE "${BINDIR}/${OUTPUT}")
|
||||
|
||||
if(PNG_PREFIX)
|
||||
file(REMOVE "pngprefix.tf1")
|
||||
|
||||
execute_process(COMMAND "${AWK}"
|
||||
"{print \"#define\", \$1, \"${PNG_PREFIX}\" \$1}"
|
||||
"${BINDIR}/scripts/intprefix.out"
|
||||
OUTPUT_FILE "pngprefix.tf1"
|
||||
RESULT_VARIABLE AWK_FAIL)
|
||||
if(AWK_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate pngprefix.tf1")
|
||||
endif()
|
||||
|
||||
file(RENAME "pngprefix.tf1" "${BINDIR}/${OUTPUT}")
|
||||
else()
|
||||
file(WRITE "${BINDIR}/${OUTPUT}" "/* No libpng symbol prefix configured. */")
|
||||
endif()
|
||||
|
||||
elseif(OUTPUT STREQUAL "scripts/pnglibconf.h.prebuilt")
|
||||
# Generate scripts/pnglibconf.h.prebuilt (fails build)
|
||||
|
||||
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 '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")
|
||||
|
||||
else()
|
||||
|
||||
message(FATAL_ERROR "Unsupported output: ${OUTPUT}")
|
||||
|
||||
endif()
|
||||
34
scripts/cmake/test.cmake.in
Normal file
34
scripts/cmake/test.cmake.in
Normal file
@@ -0,0 +1,34 @@
|
||||
# test.cmake.in
|
||||
|
||||
# Copyright (c) 2024 Cosmin Truta
|
||||
# Copyright (c) 2016 Glenn Randers-Pehrson
|
||||
# Written by Roger Leigh, 2016
|
||||
#
|
||||
# Use, modification and distribution are subject to
|
||||
# the same licensing terms and conditions as libpng.
|
||||
# Please see the copyright notice in png.h or visit
|
||||
# http://libpng.org/pub/png/src/libpng-LICENSE.txt
|
||||
#
|
||||
# SPDX-License-Identifier: libpng-2.0
|
||||
|
||||
set(TEST_OPTIONS "@TEST_OPTIONS@")
|
||||
set(TEST_FILES "@TEST_FILES@")
|
||||
|
||||
foreach(file ${TEST_FILES})
|
||||
file(TO_NATIVE_PATH "${file}" native_file)
|
||||
list(APPEND NATIVE_TEST_FILES "${native_file}")
|
||||
endforeach()
|
||||
|
||||
# Add the directory containing libpng to the PATH (Windows only)
|
||||
if(WIN32)
|
||||
get_filename_component(LIBPNG_DIR "${LIBPNG}" PATH)
|
||||
file(TO_NATIVE_PATH "${LIBPNG_DIR}" LIBPNG_DIR)
|
||||
set(ENV{PATH} "${LIBPNG_DIR};$ENV{PATH}")
|
||||
endif()
|
||||
|
||||
message("Running ${TEST_COMMAND}" ${TEST_OPTIONS} ${NATIVE_TEST_FILES})
|
||||
execute_process(COMMAND "${TEST_COMMAND}" ${TEST_OPTIONS} ${NATIVE_TEST_FILES}
|
||||
RESULT_VARIABLE TEST_STATUS)
|
||||
if(TEST_STATUS)
|
||||
message(FATAL_ERROR "Returned failed status ${TEST_STATUS}!")
|
||||
endif()
|
||||
Reference in New Issue
Block a user