qt5base-lts/cmake/QtConfig.cmake.in
Alexandru Croitor c097256ee4 Encapsulate commands for building other repos into two macros
Currently to build qtsvg we have some copy-pasted code to set up
the paths for QtSetup and QtPostProcess to be found.

To make it cleaner, introduce two new macros called
qt_build_repo_begin and qt_build_repo_end(). The first one
should be called in a child repo like qtsvg, right after
a find_package(Qt5) call, and the second one at the end of the
repo top-level CMakeLists.txt file.

In order for the macros to work, extract some of the variables
which were set in Qt5Config into Qt5CoreConfig instead. This
makes sure that it works also for find_package(Qt5Core) calls.

Task-number: QTBUG-75580
Change-Id: I85267c6bd86f9291ec2e170fddab1006ab684b5c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-15 11:40:03 +00:00

43 lines
1.7 KiB
CMake

@PACKAGE_INIT@
# Slightly amended version of ./src/corelib/Qt5Config.cmake.in
if (CMAKE_VERSION VERSION_LESS 3.1.0)
message(FATAL_ERROR "Qt requires at least CMake version 3.1.0")
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 @INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS)
# set(@INSTALL_CMAKE_NAMESPACE@_NOT_FOUND_MESSAGE "The Qt package requires at least one component")
# set(@INSTALL_CMAKE_NAMESPACE@_FOUND False)
# return()
# endif()
foreach(module ${@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS})
find_package(@INSTALL_CMAKE_NAMESPACE@${module}
${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_QUIET}
${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_REQUIRED}
PATHS ${_qt_cmake_dir} NO_DEFAULT_PATH
)
if (NOT @INSTALL_CMAKE_NAMESPACE@${module}_FOUND)
string(CONFIGURE ${_qt5_module_location_template} _expected_module_location @ONLY)
if (@INSTALL_CMAKE_NAMESPACE@_FIND_REQUIRED_${module})
set(_Qt_NOTFOUND_MESSAGE "${_Qt_NOTFOUND_MESSAGE}Failed to find Qt component \"${module}\" config file at \"${_expected_module_location}\"\n")
elseif(NOT Qt_FIND_QUIETLY)
message(WARNING "Failed to find Qt component \"${module}\" config file at \"${_expected_module_location}\"")
endif()
unset(_expected_module_location)
endif()
endforeach()
if (_Qt_NOTFOUND_MESSAGE)
set(@INSTALL_CMAKE_NAMESPACE@_NOT_FOUND_MESSAGE "${_Qt_NOTFOUND_MESSAGE}")
set(@INSTALL_CMAKE_NAMESPACE@_FOUND False)
endif()