Skip to content

Commit 64a8c6e

Browse files
committed
[build] Update libpng, fix build warnings
Update libpng 1.6.40 : 1.6.50 Avoid CMake deprecation warnings Update how zlib is imported based on libpng CMake changes Bump version Update copyright year
1 parent f5a1954 commit 64a8c6e

File tree

11 files changed

+79
-60
lines changed

11 files changed

+79
-60
lines changed

src/CMakeLists.txt

Lines changed: 57 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
2-
project(ect VERSION 0.9.5 LANGUAGES CXX C)
1+
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
2+
project(ect VERSION 0.9.6 LANGUAGES CXX C)
33
cmake_policy(SET CMP0048 NEW)
4+
# Allow use of ZLIB_ROOT
5+
cmake_policy(SET CMP0074 NEW)
46

57
include(GNUInstallDirs)
68

79
#Note that C++11 is still supported, but using it will cause the directory support to be disabled.
810
set (CMAKE_CXX_STANDARD 17)
911

1012
if(NOT CMAKE_BUILD_TYPE)
11-
set(CMAKE_BUILD_TYPE Release)
13+
set(CMAKE_BUILD_TYPE Release)
1214
endif()
1315

1416
# Check that submodules are present only if source was downloaded with git
@@ -17,37 +19,38 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/../.git" AND NOT EXISTS "${CMAKE_SOURCE_DIR}/../s
1719
endif()
1820

1921
add_executable(ect
20-
main.cpp
21-
gztools.cpp
22-
jpegtran.cpp
23-
LzFind.c
24-
support.cpp
25-
zopflipng.cpp
26-
# Add headers so they get added to things like Xcode projects
27-
gztools.h
28-
LzFind.h
29-
main.h
30-
pngusr.h
31-
support.h
32-
mozjpeg/transupp.c)
22+
main.cpp
23+
gztools.cpp
24+
jpegtran.cpp
25+
LzFind.c
26+
support.cpp
27+
zopflipng.cpp
28+
# Add headers so they get added to things like Xcode projects
29+
gztools.h
30+
LzFind.h
31+
main.h
32+
pngusr.h
33+
support.h
34+
mozjpeg/transupp.c)
3335

3436
add_executable(ect::ect ALIAS ect)
3537

3638
if(MINGW)
37-
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-mno-ms-bitfields>)
38-
add_compile_options($<$<COMPILE_LANGUAGE:C>:-mno-ms-bitfields>)
39+
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-mno-ms-bitfields>)
40+
add_compile_options($<$<COMPILE_LANGUAGE:C>:-mno-ms-bitfields>)
3941
endif()
4042

4143
if(NOT MSVC)
42-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-sign-compare -Wno-unused -Wno-unused-parameter")
43-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-sign-compare -Wno-unused -Wno-unused-parameter")
44+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-sign-compare -Wno-unused -Wno-unused-parameter")
45+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-sign-compare -Wno-unused -Wno-unused-parameter")
4446
endif()
4547

4648
# Use -Ofast in release builds
49+
# TODO: This is now deprecated in clang and likely makes little difference, switch back to -O3.
4750
foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO)
48-
if(${var} MATCHES "-O(2|3)")
49-
string(REGEX REPLACE "-O(2|3)" "-Ofast" ${var} "${${var}}")
50-
endif()
51+
if(${var} MATCHES "-O(2|3)")
52+
string(REGEX REPLACE "-O(2|3)" "-Ofast" ${var} "${${var}}")
53+
endif()
5154
endforeach()
5255

5356
# Detect CPU type and whether we're building 64-bit or 32-bit code, courtesy of mozjpeg
@@ -61,10 +64,10 @@ foreach(ARCH ${CMAKE_OSX_ARCHITECTURES})
6164
math(EXPR COUNT "${COUNT}+1")
6265
endforeach()
6366
if(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86_64" OR
64-
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "amd64" OR
65-
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "i[0-9]86" OR
66-
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86" OR
67-
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "ia32")
67+
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "amd64" OR
68+
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "i[0-9]86" OR
69+
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86" OR
70+
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "ia32")
6871
if(BITS EQUAL 64 OR CMAKE_C_COMPILER_ABI MATCHES "ELF X32")
6972
set(CPU_TYPE x86_64)
7073
else()
@@ -74,7 +77,7 @@ if(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86_64" OR
7477
set(CMAKE_SYSTEM_PROCESSOR ${CPU_TYPE})
7578
endif()
7679
elseif(CMAKE_SYSTEM_PROCESSOR_LC STREQUAL "aarch64" OR
77-
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "^arm")
80+
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "^arm")
7881
if(BITS EQUAL 64)
7982
set(CPU_TYPE arm64)
8083
else()
@@ -84,8 +87,8 @@ else()
8487
set(CPU_TYPE ${CMAKE_SYSTEM_PROCESSOR_LC})
8588
endif()
8689
if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR
87-
CMAKE_OSX_ARCHITECTURES MATCHES "arm64" OR
88-
CMAKE_OSX_ARCHITECTURES MATCHES "i386")
90+
CMAKE_OSX_ARCHITECTURES MATCHES "arm64" OR
91+
CMAKE_OSX_ARCHITECTURES MATCHES "i386")
8992
set(CPU_TYPE ${CMAKE_OSX_ARCHITECTURES})
9093
endif()
9194
if(MSVC_IDE AND CMAKE_GENERATOR_PLATFORM MATCHES "arm64")
@@ -121,6 +124,10 @@ endif()
121124
# Enable ZLIB_CONST for everything
122125
add_definitions(-DZLIB_CONST)
123126

127+
# Ensure that zlib target points to our custom zlib zlib
128+
set(ZLIB_ROOT "zlib/")
129+
find_package(ZLIB)
130+
124131
option(ECT_MULTITHREADING "Enable multithreaded processing support" ON)
125132
option(ECT_MP3_SUPPORT "Enable MP3 support (not currently working)" OFF)
126133

@@ -136,33 +143,35 @@ set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT FALSE)
136143
add_subdirectory(mozjpeg EXCLUDE_FROM_ALL)
137144

138145
target_link_libraries(ect
139-
leanify::leanify
140-
lodepng::lodepng
141-
miniz::miniz
142-
optipng::optipng
143-
zopfli::zopfli
144-
zlib::zlib
145-
jpeg-static)
146+
leanify::leanify
147+
lodepng::lodepng
148+
miniz::miniz
149+
optipng::optipng
150+
zopfli::zopfli
151+
zlib::zlib
152+
jpeg-static
153+
)
146154

147155
# mozjpeg generates some header files that we need to be able to include
148156
target_include_directories(ect
149-
PRIVATE
150-
${CMAKE_CURRENT_BINARY_DIR}/mozjpeg)
157+
PRIVATE
158+
${CMAKE_CURRENT_BINARY_DIR}/mozjpeg
159+
)
151160

152161
if(NOT ECT_MULTITHREADING)
153-
target_compile_definitions(ect
154-
PRIVATE
155-
NOMULTI=1)
162+
target_compile_definitions(ect
163+
PRIVATE
164+
NOMULTI=1)
156165
else()
157-
find_package(Threads REQUIRED)
158-
target_link_libraries(ect
159-
Threads::Threads)
166+
find_package(Threads REQUIRED)
167+
target_link_libraries(ect
168+
Threads::Threads)
160169
endif()
161170

162171
if(ECT_MP3_SUPPORT)
163-
target_compile_definitions(ect
164-
PRIVATE
165-
MP3_SUPPORTED=1)
172+
target_compile_definitions(ect
173+
PRIVATE
174+
MP3_SUPPORTED=1)
166175
endif()
167176

168177
install(TARGETS ect RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

src/leanify/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
22
project(leanify LANGUAGES CXX)
33

44
add_library(leanify

src/libpng

src/lodepng/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
22
project(lodepng LANGUAGES CXX)
33

44
add_library(lodepng

src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// main.cpp
22
// Efficient Compression Tool
33
// Created by Felix Hanau on 12/19/14.
4-
// Copyright (c) 2014-2024 Felix Hanau.
4+
// Copyright (c) 2014-2025 Felix Hanau.
55

66
#include "main.h"
77
#include "support.h"
@@ -31,7 +31,7 @@ static std::atomic<long long> savings;
3131
static void Usage() {
3232
printf (
3333
"Efficient Compression Tool\n"
34-
"(c) 2014-2024 Felix Hanau.\n"
34+
"(c) 2014-2025 Felix Hanau.\n"
3535
"Version 0.9.5"
3636
#ifdef __DATE__
3737
" compiled on %s\n"

src/miniz/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
22
project(miniz LANGUAGES C)
33

44
add_library(miniz

src/mozjpeg

src/optipng/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
22
project(optipng LANGUAGES C CXX)
33

44
add_library(optipng
@@ -15,8 +15,7 @@ add_library(optipng
1515

1616
add_library(optipng::optipng ALIAS optipng)
1717

18-
#make sure that we are using custom zlib and custom libpng options
19-
set(PNG_BUILD_ZLIB ON CACHE BOOL "use custom zlib within libpng" FORCE)
18+
# make sure that we are using custom libpng options
2019
set(PNG_ARM_NEON "on" CACHE STRING "Enable ARM NEON optimizations: on|off; on is default" FORCE)
2120
set(ZLIB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../zlib/ CACHE FILEPATH "custom zlib directory" FORCE)
2221

src/pngusr.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@
9191
#undef PNG_tIME_SUPPORTED
9292
#undef PNG_ARM_NEON_CHECK_SUPPORTED
9393

94+
// Disable support for chunks added between 1.6.40..1.6.50
95+
#undef PNG_READ_cICP_SUPPORTED
96+
#undef PNG_READ_cLLI_SUPPORTED
97+
#undef PNG_READ_mDCV_SUPPORTED
98+
#undef PNG_WRITE_cICP_SUPPORTED
99+
#undef PNG_WRITE_cLLI_SUPPORTED
100+
#undef PNG_WRITE_mDCV_SUPPORTED
101+
#undef PNG_cICP_SUPPORTED
102+
#undef PNG_cLLI_SUPPORTED
103+
#undef PNG_mDCV_SUPPORTED
104+
94105
#define PNG_IDAT_READ_SIZE 8192
95106
#define PNG_INFLATE_BUF_SIZE 32768
96107
#define PNG_ZBUF_SIZE 65536

src/zlib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
22
project(zlib LANGUAGES C)
33

44
add_library(zlib

0 commit comments

Comments
 (0)