CMake: Install the HTML guides.
authorGerald Combs <gerald@wireshark.org>
Sun, 11 Feb 2018 22:34:04 +0000 (14:34 -0800)
committerAnders Broman <a.broman58@gmail.com>
Tue, 13 Feb 2018 06:18:34 +0000 (06:18 +0000)
Add a "FileInstall.cmake" module that installs files and directories.
Use it to install the chunked HTML guides.

Install the guides into CMAKE_INSTALL_FULL_DOCDIR. By default this is
/usr/local/share/doc/Wireshark. Define DOC_DIR to match.

Add explicit file and directory permissions to the default install
targets.

Remove the PDF install target.

Bug: 14258
Change-Id: I4712a4047a54627b7520b5bf5f191e0761d19606
Reviewed-on: https://code.wireshark.org/review/25737
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
CMakeLists.txt
cmake/modules/FileInstall.cmake [new file with mode: 0644]
docbook/CMakeLists.txt
ui/CMakeLists.txt
ui/Makefile.am

index 239a96938f9146ccb4c084918ea2548813b595e1..22d1e8623edeb0d6144033942685cc034e6b74c5 100644 (file)
@@ -1415,11 +1415,6 @@ foreach(_plugin_src_dir ${PLUGIN_SRC_DIRS})
        add_subdirectory( ${_plugin_src_dir} )
 endforeach()
 
-
-# Basedir where to install guides
-set(DOC_DIR "$ENV{docdir}" CACHE FILEPATH "Installation directory for ug and dg pdfs.")
-message(STATUS "docdir: ${DOC_DIR}")
-
 if(ENABLE_PCAP_NG_DEFAULT)
        set(PCAP_NG_DEFAULT 1)
 endif()
@@ -3049,6 +3044,10 @@ set_source_files_properties(
 install(
        FILES
                ${INSTALL_FILES}
+       PERMISSIONS
+               OWNER_WRITE OWNER_READ
+               GROUP_READ
+               WORLD_READ
        DESTINATION
                ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
 )
@@ -3113,12 +3112,16 @@ install(
 install(
        DIRECTORY
                ${INSTALL_DIRS}
+       DESTINATION
+               ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
+       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
-       DESTINATION
-               ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
        PATTERN ".git" EXCLUDE
        PATTERN ".svn" EXCLUDE
        PATTERN "Makefile.*" EXCLUDE
@@ -3141,22 +3144,6 @@ install(
                ${CMAKE_INSTALL_MODULES_DIR}
 )
 
-if(DOC_DIR)
-       message(STATUS "Docdir install: ${DOC_DIR}")
-       INSTALL(
-               DIRECTORY
-                       ${CMAKE_BINARY_DIR}/docbook/
-               DIRECTORY_PERMISSIONS
-                       OWNER_EXECUTE OWNER_WRITE OWNER_READ
-                       GROUP_EXECUTE GROUP_READ
-                       WORLD_EXECUTE WORLD_READ
-               DESTINATION
-                       ${DOC_DIR}/guides
-               FILES_MATCHING
-               PATTERN "*.pdf"
-       )
-endif()
-
 # Test suite wrapper
 if(ENABLE_APPLICATION_BUNDLE)
        set(TEST_SH_BIN_DIR ${CMAKE_BINARY_DIR}/run)
diff --git a/cmake/modules/FileInstall.cmake b/cmake/modules/FileInstall.cmake
new file mode 100644 (file)
index 0000000..3358aa2
--- /dev/null
@@ -0,0 +1,33 @@
+# 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 56d0fa0268f33f484671e68be019b617481eae98..cfdeb25a2cf2047594152e1074306ae33becdc1a 100644 (file)
@@ -78,6 +78,7 @@ set(WSUG_TOOLS_HELP_COMMANDS
 # being able to build our documentation.
 set(WSUG_TOOLS_HELP_FILES)
 set(WSUG_TOOLS_PHONY_DEPS)
+set(GUIDE_INSTALL_DIRS)
 
 # General help output
 foreach(th_command ${WSUG_TOOLS_HELP_COMMANDS})
@@ -424,6 +425,7 @@ if(ASCIIDOCTOR_EXECUTABLE 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_EXECUTABLE)
@@ -475,6 +477,7 @@ if(ASCIIDOCTOR_EXECUTABLE 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_EXECUTABLE)
@@ -501,6 +504,20 @@ if(WIN32 AND ASCIIDOCTOR_EXECUTABLE)
        add_dependencies(developer_guides developer_guide_chm)
 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 f5ed7b199c8901987cc8557eebaa2f4d4782bf66..ea78f7830caa710de612ad84b6d199386e79e8b1 100644 (file)
@@ -107,6 +107,8 @@ if (HTML_HELP_COMPILER)
        target_link_libraries(ui Htmlhelp.lib)
 endif()
 
+add_definitions(-DDOC_DIR="${CMAKE_INSTALL_FULL_DOCDIR}")
+
 CHECKAPI(
        NAME
          ui-base
index e3b468c700362ce548ac158128d0a8627bab5c5f..c273d59aada2387c166e5cb29ff6d4c5b1a63d66 100644 (file)
@@ -22,6 +22,7 @@
 
 include $(top_srcdir)/Makefile.am.inc
 
+# The installation location and DOC_DIR in ui/help_url.c must match.
 AM_CPPFLAGS = $(INCLUDEDIRS) $(WS_CPPFLAGS) -DDOC_DIR=\"$(docdir)\" \
        $(GLIB_CFLAGS) $(PCAP_CFLAGS) $(LIBGCRYPT_CFLAGS) $(LIBGNUTLS_CFLAGS) $(PORTAUDIO_INCLUDES)