Skip to content

Commit

Permalink
Fix manpage installation when GZ_CLI_EXECUTABLE_NAME is used (#3370)
Browse files Browse the repository at this point in the history
Signed-off-by: Jose Luis Rivero <jrivero@osrfoundation.org>
  • Loading branch information
j-rivero authored Feb 21, 2024
1 parent 3a9efee commit 9442fa6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions cmake/Man.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,34 @@ if (NOT GZIP)
else (NOT GZIP)
message (STATUS "Looking for gzip to generate manpages - found")

# macro can also be called with a third argument that contains a modified name
# of the manpage to be installed.
macro(roffman _source _section)
set(_extra_macro_args ${ARGN})
list(LENGTH _extra_macro_args _num_extra_macro_args)

if (_num_extra_macro_args EQUAL 0)
set(_destination _source)
elseif(_num_extra_macro_args EQUAL 1)
set(_destination ${_extra_macro_args})
else()
message(FATAL_ERROR "roffman macro called with unexpected number of extra arguments '${ARGN}'")
endif()

add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_source}.${_section}.gz
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_destination}.${_section}.gz
COMMAND ${GZIP} -c ${CMAKE_CURRENT_SOURCE_DIR}/${_source}.${_section}.roff
> ${CMAKE_CURRENT_BINARY_DIR}/${_source}.${_section}.gz
> ${CMAKE_CURRENT_BINARY_DIR}/${_destination}.${_section}.gz
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_source}.${_section}.roff
)

set(MANPAGE_TARGET "man-${_source}")

add_custom_target(${MANPAGE_TARGET}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_source}.${_section}.gz)
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_destination}.${_section}.gz)
add_dependencies(man ${MANPAGE_TARGET})

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_source}.${_section}.gz
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_destination}.${_section}.gz
DESTINATION share/man/man${_section}
)
endmacro(roffman _source _section)
Expand Down
2 changes: 1 addition & 1 deletion tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ endif()
gz_install_executable(${GZ_CLI_EXECUTABLE_NAME})

if (NOT WIN32)
roffman(${GZ_CLI_EXECUTABLE_NAME} 1)
roffman(gz 1 ${GZ_CLI_EXECUTABLE_NAME})
endif()

install (PROGRAMS gzprop DESTINATION ${BIN_INSTALL_DIR})
Expand Down

0 comments on commit 9442fa6

Please sign in to comment.