diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2018-12-02 05:55:59 +0000 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2018-12-02 22:00:38 +0000 |
commit | 8992760c68f3e508a0e5a25307c246a75f7c2ae2 (patch) | |
tree | ff099ba2de2c3e3b5477c3484c8c4ef07eb519d8 | |
parent | 67720f7fc325792b4ad16aeb0cab8a00b94262f4 (diff) |
CMake: Fix Windows help install target
We can't install from DATAFILE_DIR on this platform, we
must use CMAKE_BINARY_DIR.
Do that and try to keep this thing intact.
Ping-Bug: 15301
Change-Id: I5c0b787f8b1a148dda52f26242ab681e3c3a0d44
Reviewed-on: https://code.wireshark.org/review/30879
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
-rw-r--r-- | CMakeLists.txt | 97 | ||||
-rw-r--r-- | help/CMakeLists.txt | 71 |
2 files changed, 93 insertions, 75 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 983143da7e..8eb6aa9725 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,6 +156,26 @@ if(NOT LIBRARY_OUTPUT_PATH) "Single output directory for building all libraries.") endif() +# Location of our data files. This should be set to a value that allows +# running from the build directory on Windows, on macOS when building an +# application bundle, and on UNIX in general if +# WIRESHARK_RUN_FROM_BUILD_DIRECTORY is set. +if(ENABLE_APPLICATION_BUNDLE) + if(CMAKE_CFG_INTDIR STREQUAL ".") + set(_datafile_dir "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/share/wireshark") + else() + # Xcode + set(_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/Wireshark.app/Contents/Resources/share/wireshark") + endif() +elseif(NOT CMAKE_CFG_INTDIR STREQUAL ".") + # Visual Studio, Xcode, etc. + set(_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}") +else() + # Makefile, Ninja, etc. + set(_datafile_dir "${CMAKE_BINARY_DIR}/run") +endif() +set(DATAFILE_DIR ${_datafile_dir} CACHE INTERNAL "Build time data file location.") + # # The release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG for # the Unix Makefile generator. @@ -1342,35 +1362,12 @@ add_subdirectory( doc ) add_subdirectory( docbook EXCLUDE_FROM_ALL ) add_subdirectory( epan ) add_subdirectory( extcap ) +add_subdirectory( help ) add_subdirectory( randpkt_core ) add_subdirectory( tools/lemon ) add_subdirectory( ui ) add_subdirectory( wiretap ) add_subdirectory( writecap ) - -# Location of our data files. This should be set to a value that allows -# running from the build directory on Windows, on macOS when building an -# application bundle, and on UNIX in general if -# WIRESHARK_RUN_FROM_BUILD_DIRECTORY is set. -if(ENABLE_APPLICATION_BUNDLE) - if(CMAKE_CFG_INTDIR STREQUAL ".") - set(_datafile_dir "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/share/wireshark") - else() - # Xcode - set(_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/Wireshark.app/Contents/Resources/share/wireshark") - endif() -elseif(NOT CMAKE_CFG_INTDIR STREQUAL ".") - # Visual Studio, Xcode, etc. - set(_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}") -else() - # Makefile, Ninja, etc. - set(_datafile_dir "${CMAKE_BINARY_DIR}/run") -endif() - -set(DATAFILE_DIR ${_datafile_dir} CACHE INTERNAL "Build time data file location.") - -# wsutil must be added after DATAFILE_DIR is set such that filesystem.c can -# learn about the directory location. add_subdirectory( wsutil ) if(NOT WIN32) @@ -1609,15 +1606,6 @@ set(INSTALL_DIRS wimaxasncp ) -# FIXME: The help files are textfified on Windows into the staging dir. -# The DATAFILE_DIR depends on CMAKE_CFG_INTDIR therefore it cannot be -# added to an install() command with build systems supporting multiple -# configurations in the build tree (e.g.: Visual Studio). -if(NOT WIN32) - list(APPEND INSTALL_DIRS help) -endif() - - set(INSTALL_FILES cfilters colorfilters @@ -1843,9 +1831,7 @@ set(copy_data_files_depends) # glob patterns relative to the source directory that should be copied to # ${DATAFILE_DIR} (including directory prefixes) -set(DATA_FILES_SRC - "help/toc" -) +set(DATA_FILES_SRC) if(WIN32) foreach(_text_file ${TEXTIFY_FILES}) @@ -1887,45 +1873,6 @@ foreach(_install_file ${INSTALL_FILES}) list(APPEND copy_data_files_depends "${_output_file}") endforeach() -# faq.txt is handled separately below. -set(_help_source_files - help/capture_filters.txt - help/capturing.txt - help/display_filters.txt - help/getting_started.txt - help/overview.txt -) - -if(WIN32) - file(TO_NATIVE_PATH "${DATAFILE_DIR}/help" _help_dest_dir) - foreach(_help_file IN LISTS _help_source_files) - add_custom_command(OUTPUT "${DATAFILE_DIR}/${_help_file}" - COMMAND ${CMAKE_COMMAND} -E make_directory "${DATAFILE_DIR}/help" - COMMAND ${POWERSHELL_COMMAND} "${CMAKE_SOURCE_DIR}/tools/textify.ps1" - -Destination "${_help_dest_dir}" - "${CMAKE_SOURCE_DIR}/${_help_file}" - DEPENDS - "${CMAKE_SOURCE_DIR}/${_help_file}" - ) - list(APPEND copy_data_files_depends "${DATAFILE_DIR}/${_help_file}") - endforeach() -else() - list(APPEND DATA_FILES_SRC ${_help_source_files}) -endif(WIN32) - -# Create help/faq.txt when missing -add_custom_command(OUTPUT "${DATAFILE_DIR}/help/faq.txt" - COMMAND ${CMAKE_COMMAND} -E make_directory "${DATAFILE_DIR}/help" - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/help/faq.py -b > faq.tmp.html - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/html2text.py - faq.tmp.html > "${DATAFILE_DIR}/help/faq.txt" - COMMAND ${CMAKE_COMMAND} -E remove faq.tmp.html - DEPENDS - "${CMAKE_SOURCE_DIR}/help/faq.py" - "${CMAKE_SOURCE_DIR}/tools/html2text.py" -) -list(APPEND copy_data_files_depends "${DATAFILE_DIR}/help/faq.txt") - # Install LUA files in staging directory such that LUA can used when Wireshark # is ran from the build directory. For install targets, see # epan/wslua/CMakeLists.txt diff --git a/help/CMakeLists.txt b/help/CMakeLists.txt new file mode 100644 index 0000000000..ddf1f068d2 --- /dev/null +++ b/help/CMakeLists.txt @@ -0,0 +1,71 @@ + +set(copy_help_files_depends) + +set(HELP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/toc) + +set(_textify_help_files + capture_filters.txt + capturing.txt + display_filters.txt + getting_started.txt + overview.txt +) + +foreach(_file ${_textify_help_files}) + if(WIN32) + list(APPEND HELP_FILES ${CMAKE_CURRENT_BINARY_DIR}/${_file}) + else() + list(APPEND HELP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${_file}) + endif() +endforeach() + +list(APPEND HELP_FILES ${CMAKE_CURRENT_BINARY_DIR}/faq.txt) + +if(WIN32) + foreach(_help_file ${_textify_help_files}) + file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" _help_dest_dir) + add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_help_file}" + COMMAND ${POWERSHELL_COMMAND} "${CMAKE_SOURCE_DIR}/tools/textify.ps1" + -Destination "${_help_dest_dir}" + "${CMAKE_CURRENT_SOURCE_DIR}/${_help_file}" + DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/${_help_file}" + ) + endforeach() +endif() + +# Create help/faq.txt when missing +add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/faq.txt" + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/faq.py -b > faq.tmp.html + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/html2text.py + faq.tmp.html > "${CMAKE_CURRENT_BINARY_DIR}/faq.txt" + COMMAND ${CMAKE_COMMAND} -E remove faq.tmp.html + DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/faq.py" + "${CMAKE_SOURCE_DIR}/tools/html2text.py" +) + +foreach(_help_file ${HELP_FILES}) + get_filename_component(_name ${_help_file} NAME) + set(_src_file ${_help_file}) + set(_dst_file "${DATAFILE_DIR}/help/${_name}") + add_custom_command(OUTPUT "${_dst_file}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${_src_file}" + "${_dst_file}" + DEPENDS + "${_src_file}" + ) + list(APPEND copy_help_files_depends "${_dst_file}") +endforeach() + +if(WIN32) + set(HELP_FILES_DATADIR "help") +else() + set(HELP_FILES_DATADIR "${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}/help") +endif() + +add_custom_target(copy_help_files ALL DEPENDS ${copy_help_files_depends} ) +set_target_properties(copy_help_files PROPERTIES FOLDER "Copy Tasks") + +install(FILES ${HELP_FILES} DESTINATION ${HELP_FILES_DATADIR}) |