Skip to content

Commit a85c6b0

Browse files
fedorovclaude
andcommitted
superbuild: pin CMAKE_INSTALL_LIBDIR, fix lib64 assumptions
The Linux build failed in the manylinux container: GNUInstallDirs resolves CMAKE_INSTALL_LIBDIR to "lib64" on 64-bit RHEL-family systems, which is what the manylinux images are, so zlib installed to deps/zlib/lib64 while the ZLIB_LIBRARY path computed at configure time pointed at deps/zlib/lib. macOS and Debian both use "lib", so this could not reproduce anywhere the earlier workflows ran. Pin CMAKE_INSTALL_LIBDIR=lib for every sub-project so the dependency install trees have the same shape on all platforms, and stop hardcoding a single directory in the two scripts that look for installed libraries -- both now search lib and lib64 so a project that ignores the setting still resolves. The ITK bundled-zlib check needed this most: it globs for a file that should not exist, so pointing it at the wrong directory made it pass silently, which is the worst thing a guard can do. Also drop cancel-in-progress here. A cold build is 30-60 minutes per platform, so cancelling on every push discards the results of platforms that were about to report something useful. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent ae5efed commit a85c6b0

6 files changed

Lines changed: 46 additions & 18 deletions

File tree

.github/workflows/build-binaries.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ on:
3535

3636
concurrency:
3737
group: ${{ github.workflow }}-${{ github.ref }}
38-
cancel-in-progress: true
38+
# Deliberately not cancel-in-progress, unlike the wheel workflows. A cold build here is
39+
# 30-60 minutes per platform, so cancelling on every push discards a lot of work and, worse,
40+
# discards the results of platforms that were about to tell you something. A new run queues
41+
# behind the current one instead.
42+
cancel-in-progress: false
3943

4044
env:
4145
# AlmaLinux 8 / glibc 2.28. Chosen over dockcross/manylinux2014 (glibc 2.17, what dcmqi

superbuild/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ set(SB_COMMON_ARGS
110110
-DBUILD_SHARED_LIBS:BOOL=OFF
111111
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
112112
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
113+
# Pin the library install directory. GNUInstallDirs resolves CMAKE_INSTALL_LIBDIR to
114+
# "lib64" on 64-bit RHEL-family systems -- which is what the manylinux images are -- and to
115+
# "lib" on macOS and Debian. Leaving it to the default means the dependency install trees
116+
# have a different shape on Linux than everywhere else, and any path this superbuild
117+
# computes for a specific library is then wrong on exactly one platform.
118+
-DCMAKE_INSTALL_LIBDIR:STRING=lib
113119
)
114120

115121
if(APPLE)

superbuild/External_ITK.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ExternalProject_Add(ITK
2727
# Catch it here, next to the cause, rather than in a link error much later.
2828
ExternalProject_Add_Step(ITK check-no-bundled-zlib
2929
COMMAND ${CMAKE_COMMAND}
30-
-DITK_LIB_DIR=${ITK_PREFIX}/lib
30+
-DITK_PREFIX=${ITK_PREFIX}
3131
-P ${CMAKE_CURRENT_LIST_DIR}/check_itk_zlib.cmake
3232
DEPENDEES install
3333
COMMENT "Checking that ITK did not build its own zlib"

superbuild/External_zlib.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ ExternalProject_Add(zlib
3838

3939
ExternalProject_Add_Step(zlib canonicalize
4040
COMMAND ${CMAKE_COMMAND}
41-
-DZLIB_LIB_DIR=${ZLIB_PREFIX}/lib
42-
-DOUTPUT_NAME=${ZLIB_CANONICAL_NAME}
41+
-DZLIB_PREFIX=${ZLIB_PREFIX}
42+
-DTARGET_PATH=${ZLIB_LIBRARY}
4343
-P ${CMAKE_CURRENT_LIST_DIR}/canonicalize_zlib.cmake
4444
DEPENDEES install
4545
COMMENT "Copying the zlib static library to a canonical name"

superbuild/canonicalize_zlib.cmake

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,46 @@
1-
# Copies the zlib-ng static library to a fixed filename.
1+
# Copies the zlib-ng static library to a fixed path.
22
#
33
# zlib-ng names its output differently across platforms and configurations (libz.a, libz-ng.a,
44
# zlib.lib, zlibstatic.lib, ...), but ITK and DCMTK need an explicit ZLIB_LIBRARY path that
55
# the superbuild can compute at configure time, before zlib has been built. Resolving the
66
# real name here and copying it to a canonical one lets the dependents be configured with a
77
# path that is known up front.
88
#
9-
# Invoked as: cmake -DZLIB_LIB_DIR=... -DOUTPUT_NAME=... -P canonicalize_zlib.cmake
9+
# Both lib/ and lib64/ are searched. The superbuild passes CMAKE_INSTALL_LIBDIR=lib so this
10+
# should not be necessary, but a project that ignores it would otherwise fail here with a
11+
# confusing "not found" -- and on RHEL-family systems, which is what the manylinux images
12+
# are, lib64 is the default that gets ignored *to*.
13+
#
14+
# Invoked as: cmake -DZLIB_PREFIX=... -DTARGET_PATH=... -P canonicalize_zlib.cmake
1015

11-
if(NOT ZLIB_LIB_DIR OR NOT OUTPUT_NAME)
12-
message(FATAL_ERROR "ZLIB_LIB_DIR and OUTPUT_NAME must both be set")
16+
if(NOT ZLIB_PREFIX OR NOT TARGET_PATH)
17+
message(FATAL_ERROR "ZLIB_PREFIX and TARGET_PATH must both be set")
1318
endif()
1419

15-
set(_target "${ZLIB_LIB_DIR}/${OUTPUT_NAME}")
16-
17-
file(GLOB _candidates "${ZLIB_LIB_DIR}/*.a" "${ZLIB_LIB_DIR}/*.lib")
18-
list(REMOVE_ITEM _candidates "${_target}")
20+
file(GLOB _candidates
21+
"${ZLIB_PREFIX}/lib/*.a"
22+
"${ZLIB_PREFIX}/lib/*.lib"
23+
"${ZLIB_PREFIX}/lib64/*.a"
24+
"${ZLIB_PREFIX}/lib64/*.lib"
25+
)
26+
list(REMOVE_ITEM _candidates "${TARGET_PATH}")
1927

2028
list(LENGTH _candidates _count)
2129
if(_count EQUAL 0)
2230
message(FATAL_ERROR
23-
"No static zlib library found in ${ZLIB_LIB_DIR}. zlib-ng did not install what was "
24-
"expected -- check that BUILD_SHARED_LIBS was OFF.")
31+
"No static zlib library found under ${ZLIB_PREFIX} (searched lib/ and lib64/). "
32+
"zlib-ng did not install what was expected -- check that BUILD_SHARED_LIBS was OFF.")
2533
endif()
2634
if(_count GREATER 1)
2735
# More than one archive means the naming assumption has drifted, and silently picking the
2836
# first would be how a subtly wrong zlib gets linked into every downstream project.
2937
message(FATAL_ERROR
30-
"Expected exactly one static zlib library in ${ZLIB_LIB_DIR}, found ${_count}: "
38+
"Expected exactly one static zlib library under ${ZLIB_PREFIX}, found ${_count}: "
3139
"${_candidates}")
3240
endif()
3341

3442
list(GET _candidates 0 _source)
35-
file(COPY_FILE "${_source}" "${_target}" ONLY_IF_DIFFERENT)
36-
message(STATUS "zlib: ${_source} -> ${_target}")
43+
get_filename_component(_target_dir "${TARGET_PATH}" DIRECTORY)
44+
file(MAKE_DIRECTORY "${_target_dir}")
45+
file(COPY_FILE "${_source}" "${TARGET_PATH}" ONLY_IF_DIFFERENT)
46+
message(STATUS "zlib: ${_source} -> ${TARGET_PATH}")

superbuild/check_itk_zlib.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55
# stay unprefixed and collide at link time. The resulting error names a plastimatch object
66
# file and gives no hint that ITK is the cause, so check here instead.
77

8-
file(GLOB _bundled "${ITK_LIB_DIR}/libitkzlib*" "${ITK_LIB_DIR}/itkzlib*")
8+
if(NOT ITK_PREFIX)
9+
message(FATAL_ERROR "ITK_PREFIX must be set")
10+
endif()
11+
12+
# lib/ and lib64/ are both searched: this check silently passes -- the worst outcome for a
13+
# guard -- if it looks in a directory the libraries were never installed to.
14+
file(GLOB _bundled
15+
"${ITK_PREFIX}/lib/libitkzlib*" "${ITK_PREFIX}/lib/itkzlib*"
16+
"${ITK_PREFIX}/lib64/libitkzlib*" "${ITK_PREFIX}/lib64/itkzlib*")
917
if(_bundled)
1018
message(FATAL_ERROR
1119
"ITK built its own zlib despite ITK_USE_SYSTEM_ZLIB=ON: ${_bundled}\n"

0 commit comments

Comments
 (0)