Changeset View
Changeset View
Standalone View
Standalone View
cmake/FindQHelpGenerator.cmake
- This file was added.
| 1 | #.rst: | ||||
|---|---|---|---|---|---|
| 2 | # FindQHelpGenerator | ||||
| 3 | # ------------------ | ||||
| 4 | # | ||||
| 5 | # Try to find the Qt help generator. | ||||
| 6 | # Based on FindQCollectionGenerator.cmake | ||||
| 7 | # | ||||
| 8 | # This will define the following variables: | ||||
| 9 | # | ||||
| 10 | # ``QHelpGenerator_FOUND`` | ||||
| 11 | # True if (the requested version of) Sphinx is available | ||||
| 12 | # ``QHelpGenerator_VERSION`` | ||||
| 13 | # The version of the Qt help generator. Note that this not the | ||||
| 14 | # same as the version of Qt it is provided by. | ||||
| 15 | # ``QHelpGenerator_QT_VERSION`` | ||||
| 16 | # The version of Qt that the Qt help generator is from. | ||||
| 17 | # ``QHelpGenerator_EXECUTABLE`` | ||||
| 18 | # The path to the Qt help generator executable. | ||||
| 19 | # | ||||
| 20 | # If ``QHelpGenerator_FOUND`` is TRUE, it will also define the following | ||||
| 21 | # imported target: | ||||
| 22 | # | ||||
| 23 | # ``QHelpGenerator::Generator`` | ||||
| 24 | # The Qt help generator. | ||||
| 25 | # | ||||
| 26 | # In general we recommend using the imported target, as it is easier to use. | ||||
| 27 | # | ||||
| 28 | | ||||
| 29 | #============================================================================= | ||||
| 30 | # Copyright 2015 Alex Merry <alex.merry@kde.org> | ||||
| 31 | # | ||||
| 32 | # Redistribution and use in source and binary forms, with or without | ||||
| 33 | # modification, are permitted provided that the following conditions | ||||
| 34 | # are met: | ||||
| 35 | # | ||||
| 36 | # 1. Redistributions of source code must retain the copyright | ||||
| 37 | # notice, this list of conditions and the following disclaimer. | ||||
| 38 | # 2. Redistributions in binary form must reproduce the copyright | ||||
| 39 | # notice, this list of conditions and the following disclaimer in the | ||||
| 40 | # documentation and/or other materials provided with the distribution. | ||||
| 41 | # 3. The name of the author may not be used to endorse or promote products | ||||
| 42 | # derived from this software without specific prior written permission. | ||||
| 43 | # | ||||
| 44 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||||
| 45 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||||
| 46 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||||
| 47 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||||
| 48 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||||
| 49 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
| 50 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
| 51 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
| 52 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||||
| 53 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
| 54 | #============================================================================= | ||||
| 55 | | ||||
| 56 | find_program(QHelpGenerator_EXECUTABLE | ||||
| 57 | NAMES | ||||
| 58 | qhelpgenerator-qt5 | ||||
| 59 | qhelpgenerator | ||||
| 60 | DOC "Qt help generator" | ||||
| 61 | ) | ||||
| 62 | | ||||
| 63 | if (QHelpGenerator_EXECUTABLE) | ||||
| 64 | if(NOT TARGET QHelpGenerator::Generator) | ||||
| 65 | add_executable(QHelpGenerator::Generator IMPORTED) | ||||
| 66 | set_target_properties(QHelpGenerator::Generator PROPERTIES | ||||
| 67 | IMPORTED_LOCATION "${QHelpGenerator_EXECUTABLE}" | ||||
| 68 | ) | ||||
| 69 | endif() | ||||
| 70 | | ||||
| 71 | execute_process( | ||||
| 72 | COMMAND "${QHelpGenerator_EXECUTABLE}" -v | ||||
| 73 | OUTPUT_VARIABLE _QHelpGenerator_version_raw | ||||
| 74 | ERROR_VARIABLE _QHelpGenerator_version_raw | ||||
| 75 | ) | ||||
| 76 | if (_QHelpGenerator_version_raw MATCHES "^Qt Help Generator version ([0-9]+(\\.[0-9]+)*) \\(Qt ([0-9]+(\\.[0-9]+)*)\\)") | ||||
| 77 | set(QHelpGenerator_VERSION "${CMAKE_MATCH_1}") | ||||
| 78 | set(QHelpGenerator_QT_VERSION "${CMAKE_MATCH_3}") | ||||
| 79 | endif() | ||||
| 80 | unset(_QHelpGenerator_version_raw) | ||||
| 81 | endif() | ||||
| 82 | | ||||
| 83 | include(FindPackageHandleStandardArgs) | ||||
| 84 | find_package_handle_standard_args(QHelpGenerator | ||||
| 85 | FOUND_VAR | ||||
| 86 | QHelpGenerator_FOUND | ||||
| 87 | REQUIRED_VARS | ||||
| 88 | QHelpGenerator_EXECUTABLE | ||||
| 89 | VERSION_VAR | ||||
| 90 | QHelpGenerator_VERSION | ||||
| 91 | ) | ||||
| 92 | | ||||
| 93 | mark_as_advanced(QHelpGenerator_EXECUTABLE) | ||||