summaryrefslogtreecommitdiffstats
path: root/cmake/QtConfig.cmake.in
diff options
context:
space:
mode:
authorKevin Funk <kevin.funk@kdab.com>2019-06-04 17:08:47 +0200
committerKevin Funk <kevin.funk@kdab.com>2019-06-05 12:53:28 +0000
commit99539a289491a2a709c2a63cd91eac155a1699da (patch)
treed928d6c6e123c6588261bea9358354fe1e1a7400 /cmake/QtConfig.cmake.in
parentace549587073d387823815b02ec85a28da408844 (diff)
Allow to build examples as standalone project
Create CMake config files which can be used from the very same CMake project. These CMake config files simply do not create any targets, controlled via the QT_NO_CREATE_TARGETS. This patch also allows to build qtbase.git:examples as a standalone project, against an already-built Qt. Ran this: ag -s "QT " examples -l -0 | xargs -0 -n 1 .../util/cmake/pro2cmake.py --is-example Task-number: QTBUG-74713 Change-Id: I44cce5a4048618b30f890c5b789592c227a8b47d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtConfig.cmake.in')
-rw-r--r--cmake/QtConfig.cmake.in13
1 files changed, 10 insertions, 3 deletions
diff --git a/cmake/QtConfig.cmake.in b/cmake/QtConfig.cmake.in
index db9ac360b5..0ea33214eb 100644
--- a/cmake/QtConfig.cmake.in
+++ b/cmake/QtConfig.cmake.in
@@ -7,9 +7,16 @@ endif()
get_filename_component(_qt_cmake_dir "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
-include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Targets.cmake")
-
-include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@VersionlessTargets.cmake")
+if (NOT QT_NO_CREATE_TARGETS)
+ include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Targets.cmake")
+ include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@VersionlessTargets.cmake")
+else()
+ # For examples using `find_package(...)` inside their CMakeLists.txt files:
+ # Make CMake's AUTOGEN detect this Qt version properly
+ set_directory_properties(PROPERTIES
+ QT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
+ QT_VERSION_MINOR @PROJECT_VERSION_MINOR@)
+endif()
# if (NOT @INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS)
# set(@INSTALL_CMAKE_NAMESPACE@_NOT_FOUND_MESSAGE "The Qt package requires at least one component")