Add an umbrella cmake config file for Qt 5.

Change-Id: I96b6e96539a84a5919992afbaee757fa080b7ae0
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Alexander Neundorf <neundorf@kde.org>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
bb10
Stephen Kelly 2013-01-11 14:53:25 +01:00 committed by The Qt Project
parent cd1e21cf09
commit 314e5ce5ee
6 changed files with 109 additions and 3 deletions

View File

@ -0,0 +1,43 @@
if (CMAKE_VERSION VERSION_LESS 2.8.9)
message(FATAL_ERROR \"Qt5 requires at least CMake version 2.8.9\")
endif()
if (NOT Qt5_FIND_COMPONENTS)
set(Qt5_NOT_FOUND_MESSAGE \"The Qt5 package requires at least one component\")
set(Qt5_FOUND False)
return()
endif()
set(_Qt5_FIND_PARTS_REQUIRED)
if (Qt5_FIND_REQUIRED)
set(_Qt5_FIND_PARTS_REQUIRED REQUIRED)
endif()
set(_Qt5_FIND_PARTS_QUIET)
if (Qt5_FIND_QUIETLY)
set(_Qt5_FIND_PARTS_QUIET QUIET)
endif()
get_filename_component(_qt5_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
set(_Qt5_NOTFOUND_MESSAGE)
foreach(module ${Qt5_FIND_COMPONENTS})
find_package(Qt5${module}
${_Qt5_FIND_PARTS_QUIET}
${_Qt5_FIND_PARTS_REQUIRED}
PATHS \"${_qt5_install_prefix}\" NO_DEFAULT_PATH
)
if (NOT Qt5${module}_FOUND)
if (Qt5_FIND_REQUIRED_${module})
set(_Qt5_NOTFOUND_MESSAGE \"${_Qt5_NOTFOUND_MESSAGE}Failed to find Qt5 component \\\"${module}\\\" config file at \\\"${_qt5_install_prefix}/lib/cmake/Qt5${module}/Qt5${module}Config.cmake\\\"\\n\")
elseif(NOT Qt5_FIND_QUIETLY)
message(WARNING \"Failed to find Qt5 component \\\"${module}\\\" config file at \\\"${_qt5_install_prefix}/lib/cmake/Qt5${module}/Qt5${module}Config.cmake\\\"\")
endif()
endif()
endforeach()
if (_Qt5_NOTFOUND_MESSAGE)
set(Qt5_NOT_FOUND_MESSAGE \"${_Qt5_NOTFOUND_MESSAGE}\")
set(Qt5_FOUND False)
endif()

View File

@ -60,10 +60,16 @@ ctest_macros_file.input = $$PWD/Qt5CTestMacros.cmake
ctest_macros_file.output = $$DESTDIR/cmake/Qt5Core/Qt5CTestMacros.cmake
ctest_macros_file.CONFIG = verbatim
QMAKE_SUBSTITUTES += ctest_macros_file
cmake_umbrella_config_file.input = $$PWD/Qt5Config.cmake.in
cmake_umbrella_config_file.output = $$DESTDIR/cmake/Qt5/Qt5Config.cmake
cmake_qt5_umbrella_module_files.files = $$cmake_umbrella_config_file.output
cmake_qt5_umbrella_module_files.path = $$[QT_INSTALL_LIBS]/cmake/Qt5
QMAKE_SUBSTITUTES += ctest_macros_file cmake_umbrella_config_file
ctest_qt5_module_files.files += $$ctest_macros_file.output
ctest_qt5_module_files.path = $$[QT_INSTALL_LIBS]/cmake/Qt5Core
INSTALLS += ctest_qt5_module_files
INSTALLS += ctest_qt5_module_files cmake_qt5_umbrella_module_files

View File

@ -51,9 +51,11 @@ if(NOT ${CMAKE_VERSION} VERSION_LESS 2.8.9)
# Requires INCLUDE_DIRECTORIES target property in CMake 2.8.8
# and POSITION_INDEPENDENT_CODE target property in 2.8.9
expect_pass(test_use_modules_function)
expect_pass(test_umbrella_config)
else()
message("CMake version older than 2.8.9 (Found ${CMAKE_VERSION}). Not running test \"test_use_modules_function\"")
message("CMake version older than 2.8.9 (Found ${CMAKE_VERSION}). Not running test \"test_use_modules_function\" or \"test_umbrella_config\"")
endif()
expect_pass(test_wrap_cpp_and_resources)
expect_pass(test_dependent_modules)
expect_fail(test_add_resource_options)

View File

@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 2.8)
project(test_umbrella_config)
add_subdirectory(components_found)
if (Qt5_FOUND)
message(SEND_ERROR "Qt5_FOUND variable leaked!")
endif()
if (Qt5Core_FOUND)
message(SEND_ERROR "Qt5Core_FOUND variable leaked!")
endif()
if (TARGET Qt5::Core)
message(SEND_ERROR "Qt5::Core target leaked!")
endif()
add_subdirectory(components_not_found)

View File

@ -0,0 +1,18 @@
# The module finds its dependencies
find_package(Qt5
COMPONENTS Core
OPTIONAL_COMPONENTS DoesNotExist
)
if (NOT Qt5_FOUND)
message(SEND_ERROR "Qt5 umbrella package not found!")
endif()
if (NOT Qt5Core_FOUND)
message(SEND_ERROR "Qt5Core package not found!")
endif()
if (Qt5DoesNotExist_FOUND)
message(SEND_ERROR "Non-existent package found!")
endif()

View File

@ -0,0 +1,17 @@
# The module finds its dependencies
find_package(Qt5
COMPONENTS Core DoesNotExist
)
if (Qt5_FOUND)
message(SEND_ERROR "Qt5 umbrella package found, though it should not be!")
endif()
if (NOT Qt5Core_FOUND)
message(SEND_ERROR "Qt5Core package not found!")
endif()
if (Qt5DoesNotExist_FOUND)
message(SEND_ERROR "Non-existent package found!")
endif()