CMake: Use components to install doc guides
authorJoão Valverde <j@v6e.pt>
Sun, 14 May 2023 00:37:03 +0000 (01:37 +0100)
committerJoão Valverde <j@v6e.pt>
Sun, 14 May 2023 01:35:35 +0000 (02:35 +0100)
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.

CMakeLists.txt
cmake/modules/FileInstall.cmake [deleted file]
cmake/modules/FindXSLTPROC.cmake
docbook/CMakeLists.txt
packaging/rpm/wireshark.spec.in

index 375970af1830c746bcee6854b8aaa5da0a9c279d..a3248d4203ee9d9f8430547ffde57ff8ebe85b22 100644 (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
diff --git a/cmake/modules/FileInstall.cmake b/cmake/modules/FileInstall.cmake
deleted file mode 100644 (file)
index 3358aa2..0000000
+++ /dev/null
@@ -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()
index ff4120baed2d5ba10c3ffce954336f97f46c3336..b55462242d6a14b8cd5e65675fefff83fea900cd 100644 (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()
 
index 7de5431ec6db718e15cf712fef5d1c4f755a53a1..a30b640e57dae2b5aad244071333fb91eb8ca9bf 100644 (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 )
index 9f194440e8a821f6956ff7861a3dd90717ce026f..0d37151378f4088c4fb97061b62f76edfbae9acd 100644 (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