Warning, /frameworks/extra-cmake-modules/tests/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 #=============================================================================
0002 # SPDX-FileCopyrightText: 2011 Alex Neundorf <neundorf@kde.org>
0003 # SPDX-FileCopyrightText: 2014-2015 Alex Merry <alex.merry@kde.org>
0004 #
0005 # SPDX-License-Identifier: BSD-3-Clause
0006 #=============================================================================
0007 
0008 # We need to set a language to find CMake packages installed in
0009 # architecture-dependent locations (like /usr/lib64).
0010 # We only set this for the tests, making sure it does not interfere
0011 # with other files (as ECM itself is architecture-independent).
0012 project(ECMTests C CXX)
0013 include(../modules/QtVersionOption.cmake)
0014 
0015 find_package(Qt${QT_MAJOR_VERSION} COMPONENTS Core LinguistTools Quick CONFIG)
0016 set_package_properties(
0017     Qt${QT_MAJOR_VERSION}LinguistTools
0018     PROPERTIES
0019         URL "https://www.qt.io/"
0020         DESCRIPTION "Qt linguist tools."
0021         TYPE OPTIONAL
0022         PURPOSE "Required to run tests for the ECMPoQmTools module."
0023 )
0024 
0025 set_package_properties(
0026     Qt${QT_MAJOR_VERSION}Core
0027     PROPERTIES
0028         URL "https://www.qt.io/"
0029         DESCRIPTION "Qt core library."
0030         TYPE OPTIONAL
0031         PURPOSE "Required to run tests for the ECMQtDeclareLoggingCategory module, and for some tests of the KDEInstallDirs module."
0032 )
0033 
0034 add_subdirectory(ECMAddTests)
0035 add_subdirectory(ECMGenerateExportHeaderTest)
0036 add_subdirectory(ECMGenerateHeadersTest)
0037 add_subdirectory(ECMSetupVersionTest)
0038 add_subdirectory(ECMGeneratePkgConfigFile)
0039 
0040 if (TARGET Qt6::Core)
0041     set(QT_VERSION_OPT "-DBUILD_WITH_QT6=ON")
0042 else()
0043     set(QT_VERSION_OPT "-DBUILD_WITH_QT6=OFF")
0044 endif()
0045 
0046 # a macro for tests that have a simple format where the name matches the
0047 # directory and project
0048 macro(add_test_variant NAME BASE COMMAND)
0049     string(REPLACE "." "/" src_dir "${BASE}")
0050     string(REPLACE "." "/" build_dir "${NAME}")
0051     string(REGEX REPLACE "[^.]*\\." "" proj "${NAME}")
0052     if (NOT ${NAME}_EXTRA_OPTIONS)
0053         set(_build_opts --build-options ${QT_VERSION_OPT})
0054     else()
0055         set(_build_opts ${${NAME}_EXTRA_OPTIONS} ${QT_VERSION_OPT})
0056     endif()
0057     add_test(${NAME} ${CMAKE_CTEST_COMMAND}
0058         --build-and-test
0059         "${CMAKE_CURRENT_SOURCE_DIR}/${src_dir}"
0060         "${CMAKE_CURRENT_BINARY_DIR}/${build_dir}"
0061         --build-two-config
0062         --build-generator ${CMAKE_GENERATOR}
0063         --build-makeprogram ${CMAKE_MAKE_PROGRAM}
0064         --build-project ${proj}
0065         ${_build_opts}
0066         --test-command ${COMMAND} ${ARGN})
0067 endmacro()
0068 macro(add_test_macro NAME)
0069     add_test_variant("${NAME}" "${NAME}" ${ARGN})
0070 endmacro()
0071 
0072 list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/find-modules)
0073 
0074 add_subdirectory(ECMCheckOutboundLicenseTest)
0075 
0076 # Skip if PyQt not available
0077 find_file(SIP_Qt5Core_Mod_FILE
0078     NAMES QtCoremod.sip
0079     PATH_SUFFIXES share/sip/PyQt5/QtCore
0080 )
0081 
0082 if(NOT SIP_Qt5Core_Mod_FILE)
0083     message(STATUS "WARNING: skipping tests that require PyQt")
0084 else()
0085   find_package(PythonModuleGeneration)
0086   foreach(pyversion 2 3)
0087     if (GPB_PYTHON${pyversion}_COMMAND)
0088       if (pythonCommands)
0089         list(APPEND pythonCommands " && ")
0090       endif()
0091       set(pythonCommands
0092         ${GPB_PYTHON${pyversion}_COMMAND}
0093         "${CMAKE_CURRENT_SOURCE_DIR}/GenerateSipBindings/testscript.py"
0094         "${CMAKE_CURRENT_BINARY_DIR}/GenerateSipBindings/py${pyversion}"
0095       )
0096     endif()
0097   endforeach()
0098   if (pythonCommands)
0099     add_test_macro(GenerateSipBindings ${pythonCommands})
0100  else()
0101     message(STATUS "WARNING: skipping GenerateSipBindings test")
0102   endif()
0103 endif()
0104 
0105 add_test_macro(ExecuteCoreModules dummy)
0106 add_test_macro(ExecuteKDEModules dummy)
0107 add_test_macro(KDEFetchTranslations dummy)
0108 
0109 add_test_variant(KDEInstallDirsTest.vars_in_sync_no_args
0110                  KDEInstallDirsTest.vars_in_sync dummy)
0111 add_test_macro(KDEInstallDirsTest.not_cache_variable dummy)
0112 
0113 set(KDEInstallDirsTest.vars_in_sync_kde_arg_EXTRA_OPTIONS
0114     --build-options -DKDE_INSTALL_BINDIR=altbin
0115                     -DBINDIR_expected_value=altbin
0116                     -DCMAKE_WARN_DEPRECATED=TRUE
0117     )
0118 add_test_variant(KDEInstallDirsTest.vars_in_sync_kde_arg
0119                  KDEInstallDirsTest.vars_in_sync dummy)
0120 
0121 set(KDEInstallDirsTest.vars_in_sync_cmake_arg_EXTRA_OPTIONS
0122     --build-options -DCMAKE_INSTALL_BINDIR=altbin
0123                     -DBINDIR_expected_value=altbin
0124                     -DCMAKE_WARN_DEPRECATED=TRUE
0125     )
0126 add_test_variant(KDEInstallDirsTest.vars_in_sync_cmake_arg
0127                  KDEInstallDirsTest.vars_in_sync dummy)
0128 
0129 # KDEInstallDirs6 explicitly sets KDE_INSTALL_DIRS_NO_DEPRECATED to false,
0130 # hence this test makes no sense in that case
0131 if(TARGET Qt5::Core)
0132     set(KDEInstallDirsTest.vars_in_sync_oldstyle_arg_EXTRA_OPTIONS
0133         --build-options -DBIN_INSTALL_DIR=altbin
0134                         -DBINDIR_expected_value=altbin
0135                         -DCMAKE_WARN_DEPRECATED=TRUE
0136         )
0137     add_test_variant(KDEInstallDirsTest.vars_in_sync_oldstyle_arg
0138                      KDEInstallDirsTest.vars_in_sync dummy)
0139 endif()
0140 
0141 set(KDEInstallDirsTest.relative_or_absolute_usr_EXTRA_OPTIONS
0142     --build-options -DCMAKE_INSTALL_PREFIX=/usr
0143                     -DKDE_INSTALL_USE_QT_SYS_PATHS=FALSE
0144                     -DAUTOSTARTDIR_should_be_absolute=TRUE
0145                     -DCONFDIR_should_be_absolute=TRUE
0146                     -DSYSCONFDIR_should_be_absolute=TRUE
0147     )
0148 add_test_variant(KDEInstallDirsTest.relative_or_absolute_usr
0149                  KDEInstallDirsTest.relative_or_absolute dummy)
0150 
0151 if (TARGET Qt5::qmake OR TARGET Qt6::Core)
0152     set(KDEInstallDirsTest.relative_or_absolute_qt_EXTRA_OPTIONS
0153         --build-options -DCMAKE_INSTALL_PREFIX=/tmp
0154                         -DKDE_INSTALL_USE_QT_SYS_PATHS=TRUE
0155                         -DPLUGINDIR_should_be_absolute=TRUE
0156                         -DQMLDIR_should_be_absolute=TRUE
0157                         -DQTQCHDIR_should_be_absolute=TRUE
0158                         -DQTPLUGINDIR_should_be_absolute=TRUE
0159                         -DQTQUICKIMPORTSDIR_should_be_absolute=TRUE
0160         )
0161     add_test_variant(KDEInstallDirsTest.relative_or_absolute_qt
0162                      KDEInstallDirsTest.relative_or_absolute dummy)
0163 endif ()
0164 if (TARGET Qt${QT_MAJOR_VERSION}::Core)
0165     set(ECMQtDeclareLoggingCategoryTest_EXTRA_OPTIONS
0166         --build-target all
0167         --build-options
0168             "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/ECMQtDeclareLoggingCategoryTest/InstallDirectory"
0169     )
0170     add_test_macro(ECMQtDeclareLoggingCategoryTest
0171         ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMQtDeclareLoggingCategoryTest/check.cmake"
0172     )
0173 endif()
0174 
0175 add_test_macro(FindModules dummy)
0176 add_test_macro(UseFindModules dummy)
0177 
0178 set(ECMAddAppIconTest_EXTRA_OPTIONS
0179     --build-target all
0180     --build-options
0181         "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/ECMAddAppIconTest/InstallDirectory"
0182 )
0183 add_test_macro(ECMAddAppIconTest
0184     ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMAddAppIconTest/check_files.cmake"
0185 )
0186 
0187 set(ECMInstallIconsTest_EXTRA_OPTIONS
0188     --build-target install
0189     --build-options
0190         "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/ECMInstallIconsTest/InstallDirectory"
0191 )
0192 add_test_macro(ECMInstallIconsTest
0193     ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMInstallIconsTest/check_tree.cmake"
0194 )
0195 
0196 set(KDEPackageAppTemplatesTest_EXTRA_OPTIONS
0197     --build-target install
0198     --build-options
0199         "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/KDEPackageAppTemplatesTest/InstallDirectory"
0200 )
0201 add_test_macro(KDEPackageAppTemplatesTest
0202     ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/KDEPackageAppTemplatesTest/check.cmake"
0203 )
0204 
0205 if (TARGET Qt${QT_MAJOR_VERSION}::Core AND TARGET Qt${QT_MAJOR_VERSION}::lconvert)
0206     set(ECMPoQmToolsTest_EXTRA_OPTIONS
0207         --build-target install
0208         --build-options
0209             "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/ECMPoQmToolsTest/InstallDirectory"
0210     )
0211     add_test_macro(ECMPoQmToolsTest
0212         ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMPoQmToolsTest/check.cmake"
0213     )
0214 endif()
0215 
0216 set_package_properties(
0217     Qt${QT_MAJOR_VERSION}Quick
0218     PROPERTIES
0219         URL "https://www.qt.io/"
0220         DESCRIPTION "Qt Quick library."
0221         TYPE OPTIONAL
0222         PURPOSE "Required to run tests for the ECMQMLModules module."
0223 )
0224 if (TARGET Qt${QT_MAJOR_VERSION}::Quick)
0225     add_test_macro(ECMFindQmlModule dummy)
0226 
0227     set(ECMQmlModuleTest.static_full_EXTRA_OPTIONS
0228         --build-target install
0229         --build-options -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/ECMQmlModuleTest/static_full/install
0230                         -DBUILD_SHARED_LIBS=OFF
0231     )
0232     add_test_variant(ECMQmlModuleTest.static_full ECMQmlModuleTest
0233         ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMQmlModuleTest/static_full/check.cmake"
0234     )
0235     set(ECMQmlModuleTest.shared_full_EXTRA_OPTIONS
0236         --build-target install
0237         --build-options -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/ECMQmlModuleTest/shared_full/install
0238                         -DBUILD_SHARED_LIBS=ON
0239     )
0240     add_test_variant(ECMQmlModuleTest.shared_full ECMQmlModuleTest
0241         ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMQmlModuleTest/shared_full/check.cmake"
0242     )
0243     set(ECMQmlModuleTest.static_qmlonly_EXTRA_OPTIONS
0244         --build-target install
0245         --build-options -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/ECMQmlModuleTest/static_qmlonly/install
0246                         -DBUILD_SHARED_LIBS=OFF
0247                         -DQML_ONLY=ON
0248     )
0249     add_test_variant(ECMQmlModuleTest.static_qmlonly ECMQmlModuleTest
0250         ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMQmlModuleTest/static_qmlonly/check.cmake"
0251     )
0252     set(ECMQmlModuleTest.shared_qmlonly_EXTRA_OPTIONS
0253         --build-target install
0254         --build-options -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/ECMQmlModuleTest/shared_qmlonly/install
0255                         -DBUILD_SHARED_LIBS=ON
0256                         -DQML_ONLY=ON
0257     )
0258     add_test_variant(ECMQmlModuleTest.shared_qmlonly ECMQmlModuleTest
0259         ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMQmlModuleTest/shared_qmlonly/check.cmake"
0260     )
0261     set(ECMQmlModuleTest.shared_depends_EXTRA_OPTIONS
0262         --build-target install
0263         --build-options -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/ECMQmlModuleTest/shared_depends/install
0264                         -DBUILD_SHARED_LIBS=ON
0265                         -DDEPENDS=ON
0266     )
0267     add_test_variant(ECMQmlModuleTest.shared_depends ECMQmlModuleTest
0268         ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMQmlModuleTest/shared_depends/check.cmake"
0269     )
0270 endif()
0271 
0272 set(ECMConfiguredInstallTest_EXTRA_OPTIONS
0273     --build-target install
0274     --build-options
0275         "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/ECMConfiguredInstallTest/InstallDirectory"
0276 )
0277 add_test_macro(ECMConfiguredInstallTest
0278     ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMConfiguredInstallTest/check_tree.cmake"
0279 )
0280 
0281 set(ECMGenerateDBusServiceFileTest_EXTRA_OPTIONS
0282     --build-target install
0283     --build-options
0284         "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/ECMGenerateDBusServiceFileTest/InstallDirectory"
0285 )
0286 add_test_macro(ECMGenerateDBusServiceFileTest
0287     ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMGenerateDBusServiceFileTest/check_tree.cmake"
0288 )