diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2013-01-11 14:53:25 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-24 20:37:34 +0100 |
commit | 314e5ce5ee03baebff4731c44c0aca871135603d (patch) | |
tree | e4b61c3c9d7d50db6ce0a237cf8eed6e26078992 | |
parent | cd1e21cf09c2512b58723ad527dcc1aad102787b (diff) |
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>
-rw-r--r-- | src/corelib/Qt5Config.cmake.in | 43 | ||||
-rw-r--r-- | src/corelib/corelib.pro | 10 | ||||
-rw-r--r-- | tests/auto/cmake/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/auto/cmake/test_umbrella_config/CMakeLists.txt | 20 | ||||
-rw-r--r-- | tests/auto/cmake/test_umbrella_config/components_found/CMakeLists.txt | 18 | ||||
-rw-r--r-- | tests/auto/cmake/test_umbrella_config/components_not_found/CMakeLists.txt | 17 |
6 files changed, 109 insertions, 3 deletions
diff --git a/src/corelib/Qt5Config.cmake.in b/src/corelib/Qt5Config.cmake.in new file mode 100644 index 0000000000..408dd64496 --- /dev/null +++ b/src/corelib/Qt5Config.cmake.in @@ -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() diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index bf2fd3c84a..2bac1bcbef 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -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 diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 46dcdcca2b..b2639f5e0b 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -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) diff --git a/tests/auto/cmake/test_umbrella_config/CMakeLists.txt b/tests/auto/cmake/test_umbrella_config/CMakeLists.txt new file mode 100644 index 0000000000..a8fc2b53ed --- /dev/null +++ b/tests/auto/cmake/test_umbrella_config/CMakeLists.txt @@ -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) diff --git a/tests/auto/cmake/test_umbrella_config/components_found/CMakeLists.txt b/tests/auto/cmake/test_umbrella_config/components_found/CMakeLists.txt new file mode 100644 index 0000000000..91cb623deb --- /dev/null +++ b/tests/auto/cmake/test_umbrella_config/components_found/CMakeLists.txt @@ -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() diff --git a/tests/auto/cmake/test_umbrella_config/components_not_found/CMakeLists.txt b/tests/auto/cmake/test_umbrella_config/components_not_found/CMakeLists.txt new file mode 100644 index 0000000000..424c3e3445 --- /dev/null +++ b/tests/auto/cmake/test_umbrella_config/components_not_found/CMakeLists.txt @@ -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() |