Skip to content

Commit 21b19cf

Browse files
committed
fixup! Use native CPack ldconfig triggers on CMake 4.4
1 parent 3187fac commit 21b19cf

2 files changed

Lines changed: 20 additions & 42 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -628,51 +628,23 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
628628
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON)
629629
set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON)
630630
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
631-
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
632631
# set(CPACK_DEBIAN_PACKAGE_DEBUG ON)
633632
# see above assignments
634633
# to CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS or CMAKE_INSTALL_RPATH
635634

636-
# CPack 4.4+ generates the ldconfig trigger itself. Older versions need
637-
# explicit control files and do not classify triggers as executable scripts.
638-
if(CMAKE_VERSION VERSION_LESS "4.4.0")
639-
set(_debian_control_dir "${CMAKE_CURRENT_BINARY_DIR}/debian-control")
640-
set(_debian_control_triggers "${_debian_control_dir}/triggers")
641-
set(_debian_control_postinst "${_debian_control_dir}/postinst")
642-
set(_debian_control_postrm "${_debian_control_dir}/postrm")
643-
file(MAKE_DIRECTORY "${_debian_control_dir}")
644-
foreach(_debian_control_file IN ITEMS triggers postinst postrm)
645-
configure_file(
646-
"${CMAKE_CURRENT_SOURCE_DIR}/debian/extra/${_debian_control_file}"
647-
"${_debian_control_dir}/${_debian_control_file}" COPYONLY)
648-
endforeach()
649-
execute_process(
650-
COMMAND chmod 0644 "${_debian_control_triggers}"
651-
RESULT_VARIABLE _debian_control_chmod_result)
652-
if(NOT _debian_control_chmod_result EQUAL 0)
653-
message(FATAL_ERROR "Failed to set permissions on ${_debian_control_triggers}")
654-
endif()
655-
execute_process(
656-
COMMAND chmod 0755 "${_debian_control_postinst}" "${_debian_control_postrm}"
657-
RESULT_VARIABLE _debian_control_chmod_result)
658-
if(NOT _debian_control_chmod_result EQUAL 0)
659-
message(FATAL_ERROR "Failed to set permissions on maintainer scripts")
660-
endif()
661-
set(_debian_control_extra
662-
"${_debian_control_triggers}"
663-
"${_debian_control_postinst}"
664-
"${_debian_control_postrm}")
665-
endif()
666-
667635
set(CPACK_DEBIAN_LIBRARY_RUNTIME_PACKAGE_NAME "libgencmp2")
668636
set(CPACK_DEBIAN_LIBRARY_RUNTIME_FILE_NAME DEB-DEFAULT)
669637
set(CPACK_DEBIAN_LIBRARY_RUNTIME_PACKAGE_SECTION "libs")
670-
# see also https://gitlab.kitware.com/cmake/cmake/-/issues/21834
671-
if(CMAKE_VERSION VERSION_LESS "4.4.0")
672-
set(CPACK_DEBIAN_LIBRARY_RUNTIME_PACKAGE_CONTROL_EXTRA
673-
${_debian_control_extra})
674-
set(CPACK_DEBIAN_LIBRARY_RUNTIME_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
675-
endif()
638+
# CPack 4.4+ generates the ldconfig trigger itself; supplying it as an
639+
# extra control file would incorrectly make it executable in strict mode.
640+
if(CMAKE_VERSION VERSION_LESS "4.4")
641+
# Older CPack versions need a custom trigger to avoid direct ldconfig calls.
642+
set(CPACK_DEBIAN_LIBRARY_RUNTIME_PACKAGE_CONTROL_EXTRA
643+
"${CMAKE_CURRENT_SOURCE_DIR}/debian/extra/triggers"
644+
"${CMAKE_CURRENT_SOURCE_DIR}/debian/extra/postinst"
645+
"${CMAKE_CURRENT_SOURCE_DIR}/debian/extra/postrm")
646+
set(CPACK_DEBIAN_LIBRARY_RUNTIME_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
647+
endif()
676648

677649
if(FALSE) # for now, disable dependencies to libs of subprojectx because their .so files for some reason already get included in the package:
678650
if(NOT DEFINED GENCMP_NO_SECUTILS)
@@ -697,9 +669,15 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
697669
endif()
698670
# see also https://gitlab.kitware.com/cmake/cmake/-/issues/21834
699671
# CPack Deb does not create postinst when installing to /usr/lib/x86_64-linux-gnu
700-
if(CMAKE_VERSION VERSION_LESS "4.4.0")
701-
set(CPACK_DEBIAN_LIB_PACKAGE_CONTROL_EXTRA ${_debian_control_extra})
702-
set(CPACK_DEBIAN_LIB_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
672+
# CPack 4.4+ generates the ldconfig trigger itself; supplying it as an
673+
# extra control file would incorrectly make it executable in strict mode.
674+
if(CMAKE_VERSION VERSION_LESS "4.4")
675+
# Older CPack versions need a custom trigger to avoid direct ldconfig calls.
676+
set(CPACK_DEBIAN_LIB_PACKAGE_CONTROL_EXTRA
677+
"${CMAKE_CURRENT_SOURCE_DIR}/debian/extra/triggers"
678+
"${CMAKE_CURRENT_SOURCE_DIR}/debian/extra/postinst"
679+
"${CMAKE_CURRENT_SOURCE_DIR}/debian/extra/postrm")
680+
set(CPACK_DEBIAN_LIB_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
703681
endif()
704682

705683
else(Linux)

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ The core library can also be built and used natively under Windows.
124124
The following development and network tools are needed or recommended.
125125

126126
* Git (for conveniently getting and updating the software, tested versions include 2.7.2, 2.11.0, 2.20, 2.34.1, 2.48.0, 2.53.0)
127-
* CMake (for using [`CMakeLists.txt`](CMakeLists.txt), tested versions include 3.18.4, 3.22.1, 3.27.7, 3.31.5, 4.3.0)
127+
* CMake (for using [`CMakeLists.txt`](CMakeLists.txt), tested versions include 3.18.4, 3.22.1, 3.27.7, 3.31.5, 4.3.0, 4.5.0)
128128
* GNU make (tested versions include 3.81, 4.1, 4.2.1, 4.3)
129129
* GNU C compiler (gcc, tested versions include 5.4.0, 7.3.0, 8.3.0, 10.2.1, 12.2.0, 15.3.0)
130130
or clang (tested versions include 14.0.3, 17.0.3, 19.1.1, 22.1.1)

0 commit comments

Comments
 (0)