mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-11-30 04:04:03 -05:00
After installing the Perl modules from the source tree, the install copied every .pm in the build tree's lib/ over them, though only Base, Config, Memory, ConfigData and ONVIF are generated there. Copies of other modules left in a build directory by an older build replaced current ones on install: a stale ZoneMinder/Server.pm without systemdRunning() left zoneminder.service failing in zmpkg.pl. The five generated modules are now named one by one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
96 lines
3.8 KiB
CMake
96 lines
3.8 KiB
CMake
# CMakeLists.txt for the ZoneMinder Perl modules.
|
|
|
|
# Create configured .pm files from .pm.in templates
|
|
configure_file(lib/ZoneMinder/Base.pm.in
|
|
"${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Base.pm" @ONLY)
|
|
configure_file(lib/ZoneMinder/Config.pm.in
|
|
"${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Config.pm" @ONLY)
|
|
configure_file(lib/ZoneMinder/Memory.pm.in
|
|
"${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Memory.pm" @ONLY)
|
|
configure_file(lib/ZoneMinder/ConfigData.pm.in
|
|
"${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/ConfigData.pm" @ONLY)
|
|
configure_file(lib/ZoneMinder/ONVIF.pm.in
|
|
"${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/ONVIF.pm" @ONLY)
|
|
|
|
# Install static .pm files from source tree
|
|
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/lib/"
|
|
DESTINATION "${ZM_PERL_INSTALL_PATH}"
|
|
FILES_MATCHING PATTERN "*.pm")
|
|
|
|
# Install the configured .pm files from the build tree. They are named one by
|
|
# one: anything else left in the build tree's lib/, such as copies from an
|
|
# older build, would otherwise replace the source tree's modules just installed.
|
|
install(FILES
|
|
"${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Base.pm"
|
|
"${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Config.pm"
|
|
"${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Memory.pm"
|
|
"${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/ConfigData.pm"
|
|
"${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/ONVIF.pm"
|
|
DESTINATION "${ZM_PERL_INSTALL_PATH}/ZoneMinder")
|
|
|
|
# Generate man3 pages for modules with verified documentation.
|
|
# Only modules whose POD was audited and confirmed accurate are listed.
|
|
# Memory.pm is generated from .pm.in so its source is in the build tree.
|
|
if(BUILD_MAN)
|
|
find_program(POD2MAN pod2man)
|
|
find_program(GZIP gzip)
|
|
if(POD2MAN AND GZIP)
|
|
set(_man3_modules
|
|
ZoneMinder/Memory.pm
|
|
ZoneMinder/Logger.pm
|
|
ZoneMinder/Control/Dahua.pm
|
|
ZoneMinder/Control/Reolink_HTTP.pm
|
|
ZoneMinder/Control/Amcrest_HTTP.pm
|
|
ZoneMinder/Control/Trendnet.pm
|
|
ZoneMinder/Control/Instar720p.pm
|
|
ZoneMinder/Control/FoscamHD.pm
|
|
ZoneMinder/Control/IPSpeaker.pm
|
|
ZoneMinder/Control/AMLink.pm)
|
|
|
|
# Build output uses "/" (safe for GNU make); installed name uses "::" (Perl convention).
|
|
# GNU make treats "::" as double-colon rule syntax, so build-time filenames must avoid it.
|
|
set(_man3_outputs)
|
|
foreach(_pm_rel IN LISTS _man3_modules)
|
|
# Derive Perl man page name: ZoneMinder/Control/Dahua.pm -> ZoneMinder::Control::Dahua
|
|
string(REPLACE "/" "::" _man_name "${_pm_rel}")
|
|
string(REPLACE ".pm" "" _man_name "${_man_name}")
|
|
|
|
# Build-time filename uses "/" separators (make-safe)
|
|
string(REPLACE ".pm" "" _build_stem "${_pm_rel}")
|
|
|
|
# Memory.pm is generated by configure_file; others are static source files
|
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lib/${_pm_rel}")
|
|
set(_pm_src "${CMAKE_CURRENT_SOURCE_DIR}/lib/${_pm_rel}")
|
|
else()
|
|
set(_pm_src "${CMAKE_CURRENT_BINARY_DIR}/lib/${_pm_rel}")
|
|
endif()
|
|
|
|
set(_man_dir "${CMAKE_CURRENT_BINARY_DIR}/man3")
|
|
set(_man_out "${_man_dir}/${_build_stem}.3pm")
|
|
set(_man_gz "${_man_out}.gz")
|
|
|
|
get_filename_component(_man_out_dir "${_man_out}" DIRECTORY)
|
|
file(MAKE_DIRECTORY "${_man_out_dir}")
|
|
|
|
add_custom_command(OUTPUT "${_man_out}"
|
|
DEPENDS "${_pm_src}"
|
|
COMMAND ${POD2MAN} --section 3pm --center "${CMAKE_PROJECT_NAME}"
|
|
--release --stderr --name "${_man_name}"
|
|
"${_pm_src}" > "${_man_out}")
|
|
|
|
add_custom_command(OUTPUT "${_man_gz}"
|
|
DEPENDS "${_man_out}"
|
|
COMMAND ${GZIP} -n --best -c "${_man_out}" > "${_man_gz}")
|
|
|
|
list(APPEND _man3_outputs "${_man_gz}")
|
|
|
|
# Install with Perl :: convention in filename
|
|
install(FILES "${_man_gz}"
|
|
DESTINATION "${ZM_MANPAGE_DEST_PREFIX}/man3"
|
|
RENAME "${_man_name}.3pm.gz")
|
|
endforeach()
|
|
|
|
add_custom_target(perl-man3 ALL DEPENDS ${_man3_outputs})
|
|
endif()
|
|
endif()
|