Skip to content

Commit acda64c

Browse files
author
Allen Winter
committed
cmake/ECMQueryQmake.cmake - restore
1 parent 4bc8ad9 commit acda64c

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

cmake/ECMQueryQmake.cmake

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

0 commit comments

Comments
 (0)