Skip to content

Commit d36160e

Browse files
authored
Merge pull request #514 from Ka1serM/fix-cmake-build
Fix fatal CMake build error "Could NOT find ZLIB" from OpenEXR Fixes #467, #503, and #493.
2 parents 7d72800 + d2b6c02 commit d36160e

3 files changed

Lines changed: 23 additions & 29 deletions

File tree

.github/workflows/ci-cpu-windows.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ jobs:
3636
- name: Get cmake
3737
uses: lukka/get-cmake@latest
3838

39-
- name: Install pkgconfig and zlib
39+
- name: Install pkgconfig
4040
run: |
4141
choco install pkgconfiglite
42-
vcpkg install zlib:x64-windows
43-
vcpkg install zlib:x64-windows-static
4442
4543
- name: Configure
4644
run: |

.github/workflows/ci-gpu.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ jobs:
7272
if: ${{ matrix.os == 'windows-latest' }}
7373
run: |
7474
choco install pkgconfiglite
75-
vcpkg install zlib:x64-windows
76-
vcpkg install zlib:x64-windows-static
7775
7876
- name: Install OpenGL
7977
if: ${{ matrix.os == 'ubuntu-20.04' }}

src/ext/CMakeLists.txt

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
cmake_minimum_required (VERSION 3.12)
33

44
if (MSVC)
5-
add_definitions(/D _CRT_SECURE_NO_WARNINGS /Dstrdup=_strdup
6-
/wd4018 /wd4100 /wd4101 /wd4127 /wd4146 /wd4232 /wd4242 /wd4244 /wd4245 /wd4267 /wd4305 /wd4309
7-
/wd4310 /wd4334 /wd4456 /wd4464 /wd4668 /wd4701 /wd4703 /wd4711 /wd4756 /wd4820 /wd5045 /wd5250)
5+
add_definitions(/D _CRT_SECURE_NO_WARNINGS /Dstrdup=_strdup
6+
/wd4018 /wd4100 /wd4101 /wd4127 /wd4146 /wd4232 /wd4242 /wd4244 /wd4245 /wd4267 /wd4305 /wd4309
7+
/wd4310 /wd4334 /wd4456 /wd4464 /wd4668 /wd4701 /wd4703 /wd4711 /wd4756 /wd4820 /wd5045 /wd5250)
88
endif ()
99

1010
###########################################################################
@@ -32,27 +32,26 @@ set_property (TARGET deflate PROPERTY FOLDER "ext")
3232

3333
find_package (ZLIB)
3434
if (NOT ZLIB_FOUND)
35-
# Build zlib
36-
set (ZLIB_BUILD_STATIC_LIBS ON CACHE BOOL " " FORCE)
37-
set (ZLIB_BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE)
38-
add_subdirectory (zlib)
39-
40-
set (ZLIB_LIBRARIES zlibstatic)
41-
set (ZLIB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/zlib ${CMAKE_CURRENT_BINARY_DIR}/zlib)
42-
43-
# try to make openexr happy about this...
44-
set (ZLIB_LIBRARY zlibstatic)
45-
set (ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zlib ${CMAKE_CURRENT_BINARY_DIR}/zlib)
46-
set (ZLIB_FOUND TRUE)
47-
48-
set_property (TARGET zlibstatic PROPERTY FOLDER "ext")
49-
50-
add_library (ZLIB::ZLIB ALIAS zlibstatic)
51-
include_directories(${ZLIB_INCLUDE_DIRS}) # yuck, but so openexr/ptex can find zlib.h...
35+
# Build zlib
36+
set (ZLIB_BUILD_STATIC_LIBS ON CACHE BOOL " " FORCE)
37+
set (ZLIB_BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE)
38+
add_subdirectory (zlib)
39+
40+
# Set as CACHE variables so they are visible to OpenEXR find_package
41+
set (ZLIB_LIBRARIES zlibstatic CACHE STRING "zlib library" FORCE)
42+
set (ZLIB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/zlib ${CMAKE_CURRENT_BINARY_DIR}/zlib CACHE STRING "zlib include dirs" FORCE)
43+
set (ZLIB_LIBRARY zlibstatic CACHE STRING "zlib library" FORCE)
44+
set (ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zlib ${CMAKE_CURRENT_BINARY_DIR}/zlib CACHE STRING "zlib include dir" FORCE)
45+
set (ZLIB_FOUND TRUE CACHE BOOL "zlib found" FORCE)
46+
47+
set_property (TARGET zlibstatic PROPERTY FOLDER "ext")
48+
49+
add_library (ZLIB::ZLIB ALIAS zlibstatic)
50+
include_directories(${ZLIB_INCLUDE_DIRS}) # yuck, but so openexr/ptex can find zlib.h...
5251
endif ()
5352

5453
set (ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS} PARENT_SCOPE)
55-
set (ZLIB_LIBRARIES ${ZLIB_LIBARIES} PARENT_SCOPE)
54+
set (ZLIB_LIBRARIES ${ZLIB_LIBRARIES} PARENT_SCOPE)
5655

5756
###########################################################################
5857
# openexr
@@ -66,7 +65,7 @@ set (PTEX_BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE)
6665

6766
set (CMAKE_MACOSX_RPATH 1)
6867
if (WIN32)
69-
add_definitions (/DPTEX_STATIC)
68+
add_definitions (/DPTEX_STATIC)
7069
endif ()
7170

7271
add_subdirectory (ptex)
@@ -128,5 +127,4 @@ add_subdirectory (glfw)
128127
add_subdirectory (glad)
129128

130129
set_property (TARGET glfw PROPERTY FOLDER "ext")
131-
set_property (TARGET glad PROPERTY FOLDER "ext")
132-
130+
set_property (TARGET glad PROPERTY FOLDER "ext")

0 commit comments

Comments
 (0)