Changeset View
Changeset View
Standalone View
Standalone View
cmake/modules/KDbQueryQmake.cmake
- This file was added.
1 | # Copied from ECM 5.28.0, ECMQueryQmake.cmake | ||||
---|---|---|---|---|---|
2 | | ||||
3 | # Redistribution and use in source and binary forms, with or without | ||||
4 | # modification, are permitted provided that the following conditions | ||||
5 | # are met: | ||||
6 | # | ||||
7 | # 1. Redistributions of source code must retain the copyright | ||||
8 | # notice, this list of conditions and the following disclaimer. | ||||
9 | # 2. Redistributions in binary form must reproduce the copyright | ||||
10 | # notice, this list of conditions and the following disclaimer in the | ||||
11 | # documentation and/or other materials provided with the distribution. | ||||
12 | # 3. The name of the author may not be used to endorse or promote products | ||||
13 | # derived from this software without specific prior written permission. | ||||
14 | # | ||||
15 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||||
16 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||||
17 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||||
18 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||||
19 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||||
20 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
21 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
22 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
23 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||||
24 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
25 | | ||||
26 | find_package(Qt5Core QUIET) | ||||
27 | | ||||
28 | if (Qt5Core_FOUND) | ||||
29 | set(_qmake_executable_default "qmake-qt5") | ||||
30 | endif () | ||||
31 | if (TARGET Qt5::qmake) | ||||
32 | get_target_property(_qmake_executable_default Qt5::qmake LOCATION) | ||||
33 | endif() | ||||
34 | set(QMAKE_EXECUTABLE ${_qmake_executable_default} | ||||
35 | CACHE FILEPATH "Location of the Qt5 qmake executable") | ||||
36 | | ||||
37 | # This is not public API (yet)! | ||||
38 | function(query_qmake result_variable qt_variable) | ||||
39 | if(NOT QMAKE_EXECUTABLE) | ||||
40 | set(${result_variable} "" PARENT_SCOPE) | ||||
41 | message(WARNING "Should specify a qmake Qt5 binary. Can't check ${qt_variable}") | ||||
42 | return() | ||||
43 | endif() | ||||
44 | execute_process( | ||||
45 | COMMAND ${QMAKE_EXECUTABLE} -query "${qt_variable}" | ||||
46 | RESULT_VARIABLE return_code | ||||
47 | OUTPUT_VARIABLE output | ||||
48 | ) | ||||
49 | if(return_code EQUAL 0) | ||||
50 | string(STRIP "${output}" output) | ||||
51 | file(TO_CMAKE_PATH "${output}" output_path) | ||||
52 | set(${result_variable} "${output_path}" PARENT_SCOPE) | ||||
53 | else() | ||||
54 | message(WARNING "Failed call: ${QMAKE_EXECUTABLE} -query \"${qt_variable}\"") | ||||
55 | message(FATAL_ERROR "QMake call failed: ${return_code}") | ||||
56 | endif() | ||||
57 | endfunction() |