From 99539a289491a2a709c2a63cd91eac155a1699da Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Tue, 4 Jun 2019 17:08:47 +0200 Subject: 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 --- cmake/QtConfig.cmake.in | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'cmake/QtConfig.cmake.in') 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") -- cgit v1.2.3