Skip to content

Commit 17acaac

Browse files
committed
win deps build fix
1 parent 107d739 commit 17acaac

18 files changed

+705
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Scripts/__pycache__
1111
Scripts/lib/spirv-cross/all/test_package/build
1212
Scripts/lib/spirv-tools/all/test_package/build
1313
Scripts/lib/glslang/all/test_package/build
14+
Scripts/lib/zlib/all/test_package/build/
1415

1516
CMakeUserPresets.json
1617
ConanPresets.json

Scripts/conan/profiles/default

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
os=Windows
33
arch=x86_64
44
compiler=clang
5-
compiler.version=17
5+
compiler.version=19
66
compiler.cppstd=17
77
build_type=Release
88

Scripts/conan/profiles/win-64-ninja-clang

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
os=Windows
33
arch=x86_64
44
compiler=clang
5-
compiler.version=17
5+
compiler.version=19
66
compiler.cppstd=17
77
build_type=Release
88

Scripts/custom_packages.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
IMGUIZMO_VERSION = "1.83.2"
66
RTTR_VERSION = "0.9.8"
7+
ZLIB_VERSION = "1.3.1"
78

89
def check_lib_version(package_name, version):
910
conan_api = ConanAPI()
@@ -19,3 +20,7 @@ def install_custom_packages(profile_name: str):
1920
if not check_lib_version("rttr", RTTR_VERSION):
2021
sub.run(f"poetry run conan create Scripts/lib/rttr/all -s build_type=Debug --build=missing --version {RTTR_VERSION} --profile:host={profile_name} --profile:build={profile_name}", shell=True, check=True, text=True)
2122
sub.run(f"poetry run conan create Scripts/lib/rttr/all -s build_type=Release --build=missing --version {RTTR_VERSION} --profile:host={profile_name} --profile:build={profile_name}", shell=True, check=True, text=True)
23+
24+
if not check_lib_version("zlib", ZLIB_VERSION):
25+
sub.run(f"poetry run conan create Scripts/lib/zlib/all -s build_type=Debug --build=missing --version {ZLIB_VERSION} --profile:host={profile_name} --profile:build={profile_name}", shell=True, check=True, text=True)
26+
sub.run(f"poetry run conan create Scripts/lib/zlib/all -s build_type=Release --build=missing --version {ZLIB_VERSION} --profile:host={profile_name} --profile:build={profile_name}", shell=True, check=True, text=True)

Scripts/lib/imguizmo/all/conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def layout(self):
4141
cmake_layout(self, src_folder="src")
4242

4343
def requirements(self):
44-
self.requires("imgui/1.91.8-docking", transitive_headers=True)
44+
self.requires("imgui/1.90.2-docking", transitive_headers=True)
4545

4646
def source(self):
4747
get(self, **self.conan_data["sources"][self.version], strip_root=True)

Scripts/lib/zlib/all/conandata.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
sources:
2+
"1.3.1":
3+
url:
4+
- "https://zlib.net/fossils/zlib-1.3.1.tar.gz"
5+
- "https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.gz"
6+
sha256: "9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23"
7+
"1.3":
8+
url:
9+
- "https://zlib.net/fossils/zlib-1.3.tar.gz"
10+
- "https://github.com/madler/zlib/releases/download/v1.3/zlib-1.3.tar.gz"
11+
sha256: "ff0ba4c292013dbc27530b3a81e1f9a813cd39de01ca5e0f8bf355702efa593e"
12+
"1.2.13":
13+
url:
14+
- "https://zlib.net/fossils/zlib-1.2.13.tar.gz"
15+
- "https://github.com/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.gz"
16+
sha256: "b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30"
17+
"1.2.12":
18+
url: "https://zlib.net/fossils/zlib-1.2.12.tar.gz"
19+
sha256: "91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9"
20+
"1.2.11":
21+
url: "https://zlib.net/fossils/zlib-1.2.11.tar.gz"
22+
sha256: "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1"
23+
patches:
24+
"1.3.1":
25+
- patch_file: "patches/1.3.1/0001-fix-cmake.patch"
26+
patch_description: "separate static/shared builds, disable debug suffix"
27+
patch_type: "conan"
28+
"1.3":
29+
- patch_file: "patches/1.3/0001-fix-cmake.patch"
30+
patch_description: "separate static/shared builds, disable debug suffix, disable building examples"
31+
patch_type: "conan"
32+
"1.2.13":
33+
- patch_file: "patches/1.2.13/0001-Fix-cmake.patch"
34+
patch_description: "separate static/shared builds, disable debug suffix, disable building examples"
35+
patch_type: "conan"
36+
"1.2.12":
37+
- patch_file: "patches/1.2.x/0001-fix-cmake.patch"
38+
patch_description: "separate static/shared builds, disable debug suffix, disable building examples"
39+
patch_type: "conan"
40+
- patch_file: "patches/1.2.x/0004-Fix-a-bug-when-getting-a-gzip-header-extra-field-wit.patch"
41+
patch_description: "CVE-2022-37434: Fix a bug when getting a gzip header extra field with inflate()"
42+
patch_type: "vulnerability"
43+
patch_source: "https://github.com/madler/zlib/commit/eff308af425b67093bab25f80f1ae950166bece1"
44+
sha256: "15e3c177dc2a034a22e02490a97ba5b1719aae3f8129a06c16d727b661d1650f"
45+
- patch_file: "patches/1.2.x/0005-Fix-extra-field-processing-bug-that-dereferences-NUL.patch"
46+
patch_description: "CVE-2022-37434: Fix extra field processing bug that dereferences NULL state->head"
47+
patch_type: "vulnerability"
48+
patch_source: "https://github.com/madler/zlib/commit/1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d"
49+
sha256: "cdd69eb3251728b1875c8ecae6427b50aa750b4045ef984ab79b6c07b7e6dd3a"
50+
"1.2.11":
51+
- patch_file: "patches/1.2.x/0001-fix-cmake.patch"
52+
patch_description: "separate static/shared builds, disable debug suffix, disable building examples"
53+
patch_type: "conan"
54+
- patch_file: "patches/1.2.x/0003-gzguts-fix-widechar-condition.patch"
55+
patch_description: "fix condition for WIDECHAR usage"
56+
patch_type: "portability"
57+
patch_source: "https://github.com/madler/zlib/issues/268"

Scripts/lib/zlib/all/conanfile.py

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
from conan import ConanFile
2+
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
3+
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, load, replace_in_file, save
4+
from conan.tools.scm import Version
5+
import os
6+
7+
required_conan_version = ">=1.53.0"
8+
9+
10+
class ZlibConan(ConanFile):
11+
name = "zlib"
12+
package_type = "library"
13+
url = "https://github.com/conan-io/conan-center-index"
14+
homepage = "https://zlib.net"
15+
license = "Zlib"
16+
description = ("A Massively Spiffy Yet Delicately Unobtrusive Compression Library "
17+
"(Also Free, Not to Mention Unencumbered by Patents)")
18+
topics = ("zlib", "compression")
19+
20+
settings = "os", "arch", "compiler", "build_type"
21+
options = {
22+
"shared": [True, False],
23+
"fPIC": [True, False],
24+
}
25+
default_options = {
26+
"shared": False,
27+
"fPIC": True,
28+
}
29+
30+
def export_sources(self):
31+
export_conandata_patches(self)
32+
33+
def config_options(self):
34+
if self.settings.os == "Windows":
35+
del self.options.fPIC
36+
37+
def configure(self):
38+
if self.options.shared:
39+
self.options.rm_safe("fPIC")
40+
self.settings.rm_safe("compiler.libcxx")
41+
self.settings.rm_safe("compiler.cppstd")
42+
43+
def layout(self):
44+
cmake_layout(self, src_folder="src")
45+
46+
def source(self):
47+
get(self, **self.conan_data["sources"][self.version],
48+
destination=self.source_folder, strip_root=True)
49+
50+
def generate(self):
51+
tc = CMakeToolchain(self)
52+
tc.variables["SKIP_INSTALL_ALL"] = False
53+
tc.variables["SKIP_INSTALL_LIBRARIES"] = False
54+
tc.variables["SKIP_INSTALL_HEADERS"] = False
55+
tc.variables["SKIP_INSTALL_FILES"] = True
56+
# Correct for misuse of "${CMAKE_INSTALL_PREFIX}/" in CMakeLists.txt
57+
tc.variables["INSTALL_LIB_DIR"] = "lib"
58+
tc.variables["INSTALL_INC_DIR"] = "include"
59+
tc.variables["ZLIB_BUILD_EXAMPLES"] = False
60+
tc.generate()
61+
62+
def _patch_sources(self):
63+
apply_conandata_patches(self)
64+
65+
is_apple_clang12 = self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version) >= "12.0"
66+
if not is_apple_clang12:
67+
for filename in ['zconf.h', 'zconf.h.cmakein', 'zconf.h.in']:
68+
filepath = os.path.join(self.source_folder, filename)
69+
replace_in_file(self, filepath,
70+
'#ifdef HAVE_UNISTD_H '
71+
'/* may be set to #if 1 by ./configure */',
72+
'#if defined(HAVE_UNISTD_H) && (1-HAVE_UNISTD_H-1 != 0)')
73+
replace_in_file(self, filepath,
74+
'#ifdef HAVE_STDARG_H '
75+
'/* may be set to #if 1 by ./configure */',
76+
'#if defined(HAVE_STDARG_H) && (1-HAVE_STDARG_H-1 != 0)')
77+
78+
def build(self):
79+
self._patch_sources()
80+
cmake = CMake(self)
81+
cmake.configure()
82+
cmake.build()
83+
84+
def _extract_license(self):
85+
tmp = load(self, os.path.join(self.source_folder, "zlib.h"))
86+
license_contents = tmp[2:tmp.find("*/", 1)]
87+
return license_contents
88+
89+
def package(self):
90+
save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), self._extract_license())
91+
cmake = CMake(self)
92+
cmake.install()
93+
94+
def package_info(self):
95+
self.cpp_info.set_property("cmake_find_mode", "both")
96+
self.cpp_info.set_property("cmake_file_name", "ZLIB")
97+
self.cpp_info.set_property("cmake_target_name", "ZLIB::ZLIB")
98+
self.cpp_info.set_property("pkg_config_name", "zlib")
99+
100+
if self.settings.os == "Windows":
101+
# The recipe patches the CMakeLists.txt to generate different filenames when CMake
102+
# detects MINGW (clang, gcc with compiler.runtime undefined and compiler.libcxx defined)
103+
libname = "zdll" if self.options.shared else "zlib"
104+
else:
105+
libname = "z"
106+
self.cpp_info.libs = [libname]
107+
108+
self.cpp_info.names["cmake_find_package"] = "ZLIB"
109+
self.cpp_info.names["cmake_find_package_multi"] = "ZLIB"
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
From 9a709a43549fbe23ca41eeb450d4c71e3b78c8c4 Mon Sep 17 00:00:00 2001
2+
From: Mikhail Lappo <miklelappo@gmail.com>
3+
Date: Fri, 14 Oct 2022 13:29:56 +0200
4+
Subject: [PATCH] Fix cmake
5+
6+
---
7+
CMakeLists.txt | 33 +++++++++++++++++++++------------
8+
1 file changed, 21 insertions(+), 12 deletions(-)
9+
10+
diff --git a/CMakeLists.txt b/CMakeLists.txt
11+
index b412dc7..a5284ed 100644
12+
--- a/CMakeLists.txt
13+
+++ b/CMakeLists.txt
14+
@@ -1,4 +1,4 @@
15+
-cmake_minimum_required(VERSION 2.4.4)
16+
+cmake_minimum_required(VERSION 3.5) # for CMP0042 and CMake 4
17+
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
18+
19+
project(zlib C)
20+
@@ -57,7 +57,6 @@ endif()
21+
check_include_file(unistd.h Z_HAVE_UNISTD_H)
22+
23+
if(MSVC)
24+
- set(CMAKE_DEBUG_POSTFIX "d")
25+
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
26+
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
27+
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
28+
@@ -80,7 +79,7 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
29+
${ZLIB_PC} @ONLY)
30+
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
31+
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
32+
-include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
33+
+include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
34+
35+
36+
#============================================================================
37+
@@ -120,7 +119,7 @@ set(ZLIB_SRCS
38+
zutil.c
39+
)
40+
41+
-if(NOT MINGW)
42+
+if(MSVC)
43+
set(ZLIB_DLL_SRCS
44+
win32/zlib1.rc # If present will override custom build rule below.
45+
)
46+
@@ -131,7 +130,7 @@ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
47+
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
48+
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
49+
50+
-if(MINGW)
51+
+if(WIN32 AND NOT MSVC)
52+
# This gets us DLL resource information when compiling on MinGW.
53+
if(NOT CMAKE_RC_COMPILER)
54+
set(CMAKE_RC_COMPILER windres.exe)
55+
@@ -145,12 +144,15 @@ if(MINGW)
56+
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
57+
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
58+
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
59+
-endif(MINGW)
60+
+endif()
61+
62+
+if(BUILD_SHARED_LIBS)
63+
add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
64+
-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
65+
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
66+
set_target_properties(zlib PROPERTIES SOVERSION 1)
67+
+else()
68+
+add_library(zlib STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
69+
+endif()
70+
71+
if(NOT CYGWIN)
72+
# This property causes shared libraries on Linux to have the full version
73+
@@ -163,19 +165,24 @@ if(NOT CYGWIN)
74+
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
75+
endif()
76+
77+
-if(UNIX)
78+
+if(WIN32 AND NOT MINGW)
79+
+ if(BUILD_SHARED_LIBS)
80+
+ set_target_properties(zlib PROPERTIES ARCHIVE_OUTPUT_NAME zdll)
81+
+ endif()
82+
+else()
83+
# On unix-like platforms the library is almost always called libz
84+
- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
85+
+ set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
86+
if(NOT APPLE)
87+
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
88+
endif()
89+
-elseif(BUILD_SHARED_LIBS AND WIN32)
90+
+endif()
91+
+if(BUILD_SHARED_LIBS AND WIN32)
92+
# Creates zlib1.dll when building shared library version
93+
- set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
94+
+ set_target_properties(zlib PROPERTIES PREFIX "" RUNTIME_OUTPUT_NAME "zlib1")
95+
endif()
96+
97+
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
98+
- install(TARGETS zlib zlibstatic
99+
+ install(TARGETS zlib
100+
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
101+
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
102+
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
103+
@@ -194,6 +201,7 @@ endif()
104+
# Example binaries
105+
#============================================================================
106+
107+
+if(0)
108+
add_executable(example test/example.c)
109+
target_link_libraries(example zlib)
110+
add_test(example example)
111+
@@ -211,3 +219,4 @@ if(HAVE_OFF64_T)
112+
target_link_libraries(minigzip64 zlib)
113+
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
114+
endif()
115+
+endif()
116+
--
117+
2.24.3 (Apple Git-128)
118+

0 commit comments

Comments
 (0)