diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cbca5c297..c755b156c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,26 +156,6 @@ 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. @@ -1390,12 +1370,35 @@ 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) @@ -1634,6 +1637,15 @@ 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 @@ -1859,7 +1871,9 @@ 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) +set(DATA_FILES_SRC + "help/toc" +) if(WIN32) foreach(_text_file ${TEXTIFY_FILES}) @@ -1901,6 +1915,45 @@ 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 deleted file mode 100644 index 764feeea02..0000000000 --- a/help/CMakeLists.txt +++ /dev/null @@ -1,65 +0,0 @@ - -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() - -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 "${CMAKE_INSTALL_DATADIR}/help")