CMake: Use components to install doc guides

Use CMake components to install the guides, instead of
a custom target and script.

We have to inconveniently place the install() command in the
top-level CMakeLists.txt file, instead of docbook/CMakeLists.txt,
so that we can use
    cmake --install <builddir> --component UserGuide
insead of
    cmake --install <builddir>/docbook --component UserGuide

so that it can be used in the wireshark.spec file without too
many contortions.
This commit is contained in:
João Valverde 2023-05-14 01:37:03 +01:00
parent fb43a57db2
commit a88af3a866
5 changed files with 18 additions and 61 deletions

View File

@ -1343,6 +1343,7 @@ endif()
ws_find_package(WinSparkle ENABLE_WINSPARKLE HAVE_SOFTWARE_UPDATE)
find_package( Asciidoctor 1.5 )
find_package( XSLTPROC )
find_package(DOXYGEN)
@ -3862,6 +3863,21 @@ install(
${CMAKE_INSTALL_DOCDIR}
)
if(ASCIIDOCTOR_FOUND AND XSLTPROC_EXECUTABLE)
install(
DIRECTORY "${CMAKE_BINARY_DIR}/docbook/wsug_html_chunked"
DESTINATION "${CMAKE_INSTALL_DOCDIR}"
COMPONENT "UserGuide"
EXCLUDE_FROM_ALL
)
install(
DIRECTORY "${CMAKE_BINARY_DIR}/docbook/wsdg_html_chunked"
DESTINATION "${CMAKE_INSTALL_DOCDIR}"
COMPONENT "DeveloperGuide"
EXCLUDE_FROM_ALL
)
endif()
set(SHARK_PUBLIC_HEADERS
cfile.h
cli_main.h

View File

@ -1,33 +0,0 @@
# FileInstall - Install files and directories separately from the
# "install" command.
#
# Usage:
# cmake -P /path/to/FileInstall.cmake [source ...] [destination]
# Params are
# cmake -P /path/to/hhc.cmake "/path/to/hhc.exe" project.hhp
math(EXPR _dest_idx "${CMAKE_ARGC} - 1")
set(_destination ${CMAKE_ARGV${_dest_idx}})
set(_sources)
math(EXPR _last_src "${CMAKE_ARGC} - 2")
foreach(_src_idx RANGE 3 ${_last_src})
set(_sources ${_sources} ${CMAKE_ARGV${_src_idx}})
endforeach(_src_idx)
if (_sources AND _destination)
message (STATUS "Installing ${_sources} to ${_destination}")
file (INSTALL ${_sources}
DESTINATION ${_destination}
FILE_PERMISSIONS
OWNER_WRITE OWNER_READ
GROUP_READ
WORLD_READ
DIRECTORY_PERMISSIONS
OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ
)
else()
message (FATAL_ERROR "Missing arguments. Sources: ${_sources}. Destination: ${_destination}.")
endif()

View File

@ -93,7 +93,7 @@ MACRO(XML2HTML _target_dep _dir_pfx _mode _dbk_source _gfx_sources)
SET(_modeparams --stringparam chunker.output.encoding UTF-8 --stringparam chunk.quietly 1)
ELSE() # single-page
SET(_basedir ${_dir_pfx}_html)
SET(_stylesheet custom_layer_single_html.xsl)
SET(_stylesheet ${CMAKE_SOURCE_DIR}/docbook/custom_layer_single_html.xsl)
SET(_modeparams --output ${_basedir}/index.html)
ENDIF()

View File

@ -11,9 +11,6 @@
# - Make the build targets top-level on Windows, similar to the NSIS,
# WiX, and PortableApps targets?
find_package( Asciidoctor 1.5 )
find_package( XSLTPROC )
function(set_docbook_target_properties _target)
set_target_properties(${_target} PROPERTIES
FOLDER "Documentation"
@ -26,8 +23,6 @@ set(COMMON_FILES
common_src/typographic_conventions.adoc
)
set(GUIDE_INSTALL_DIRS)
set(WSUG_TITLE "Wireshark User's Guide")
set(WSUG_FILES
@ -381,7 +376,6 @@ if(ASCIIDOCTOR_FOUND AND XSLTPROC_EXECUTABLE)
)
set_docbook_target_properties(user_guide_html)
add_dependencies(user_guides user_guide_html)
list(APPEND GUIDE_INSTALL_DIRS ${CMAKE_CURRENT_BINARY_DIR}/wsug_html_chunked)
endif()
if(ASCIIDOCTOR_FOUND AND ASCIIDOCTOR_PDF_EXECUTABLE)
@ -433,7 +427,6 @@ if(ASCIIDOCTOR_FOUND AND XSLTPROC_EXECUTABLE)
)
set_docbook_target_properties(developer_guide_html)
add_dependencies(developer_guides developer_guide_html)
list(APPEND GUIDE_INSTALL_DIRS ${CMAKE_CURRENT_BINARY_DIR}/wsdg_html_chunked)
endif()
if(ASCIIDOCTOR_FOUND AND ASCIIDOCTOR_PDF_EXECUTABLE)
@ -460,20 +453,6 @@ if(ASCIIDOCTOR_FOUND AND ASCIIDOCTOR_EPUB_EXECUTABLE)
add_dependencies(developer_guides developer_guide_epub)
endif()
if (GUIDE_INSTALL_DIRS)
# The installation location and DOC_DIR in ui/help_url.c must
# match.
add_custom_target(install_guides
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_SOURCE_DIR}/cmake/modules/FileInstall.cmake
${GUIDE_INSTALL_DIRS}
${CMAKE_INSTALL_FULL_DOCDIR}
DEPENDS
user_guide_html developer_guide_html
)
set_docbook_target_properties(install_guides)
endif()
# release_notes: release-notes.html release-notes.txt
add_custom_target( release_notes_html DEPENDS release-notes.html )

View File

@ -350,13 +350,8 @@ development of Wireshark scripts and plugins.
%cmake_install
%cmake_install --component Development
%if %{with guides}
%if %{with ninja}
%ninja_install install_guides -C %{__cmake_builddir}
%else
make DESTDIR=$RPM_BUILD_ROOT install_guides -C %{__cmake_builddir}
%endif
%cmake_install --component UserGuide
%endif
# If we're being installed in an unusual prefix tell the loader where