CMake: Fix tst_qmake::resources() on Windows

This test calls qmake on a project that generates a .qrc file. On
Windows, where debug_and_release is on by default, the generated qrc
file ends up in a "debug" or "release" subdirectory. On other
platforms the file is generated directly in the build dir.

To guess the right location, the preprocessor defines RELEASE_BUILD
and DEBUG_BUILD were passed to tst_qmake.cpp by the test's .pro file.
While the mapping from debug_and_release was fine for the .pro file,
it was commented out in the automatically converted CMakeLists.txt.

Instead of trying to fix the condition, we're going the easier route
that's used in all other .pro files of tst_qmake: make sure that
debug_and_release doesn't get in the way. In other tests this is done
by setting
    DESTDIR = ./
which doesn't work for the generated qrc file. That's why we simply do
    CONFIG -= debug_and_release
to make sure that everything is generated directly in the build dir.

Change-Id: I557ac4e21d7b385004d369fae8a3f727d76d4d88
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2020-06-25 20:45:55 +02:00
parent b40f36603d
commit af61b5ca5c
4 changed files with 4 additions and 30 deletions

View File

@ -27,16 +27,3 @@ extend_target(tst_qmake CONDITION CMAKE_CROSSCOMPILING
DEFINES
QMAKE_CROSS_COMPILED
)
# special case begin
# remove this because it's not needed
#extend_target(tst_qmake CONDITION CMAKE_BUILD_TYPE STREQUAL Debug AND debug_and_release
#DEFINES
#DEBUG_BUILD
#)
#extend_target(tst_qmake CONDITION debug_and_release AND NOT CMAKE_BUILD_TYPE STREQUAL Debug
#DEFINES
#RELEASE_BUILD
#)
# special case end

View File

@ -7,11 +7,5 @@ SOURCES += tst_qmake.cpp testcompiler.cpp
QT = core testlib
cross_compile: DEFINES += QMAKE_CROSS_COMPILED
debug_and_release {
CONFIG(debug, debug|release): \
DEFINES += DEBUG_BUILD
else: \
DEFINES += RELEASE_BUILD
}
TESTDATA += testdata/*

View File

@ -1,4 +1,5 @@
TEMPLATE = app
CONFIG -= debug_and_release
SOURCES = main.cpp
pro_file.files = resources.pro

View File

@ -37,14 +37,6 @@
#include <QStandardPaths>
#include <QTemporaryDir>
#if defined(DEBUG_BUILD)
# define DIR_INFIX "debug/"
#elif defined(RELEASE_BUILD)
# define DIR_INFIX "release/"
#else
# define DIR_INFIX ""
#endif
class tst_qmake : public QObject
{
Q_OBJECT
@ -725,7 +717,7 @@ void tst_qmake::resources()
QVERIFY(test_compiler.qmake(workDir, "resources"));
{
QFile qrcFile(workDir + '/' + DIR_INFIX "qmake_pro_file.qrc");
QFile qrcFile(workDir + '/' + "qmake_pro_file.qrc");
QVERIFY2(qrcFile.exists(), qPrintable(qrcFile.fileName()));
QVERIFY(qrcFile.open(QFile::ReadOnly));
QByteArray qrcXml = qrcFile.readAll();
@ -734,7 +726,7 @@ void tst_qmake::resources()
}
{
QFile qrcFile(workDir + '/' + DIR_INFIX "qmake_subdir.qrc");
QFile qrcFile(workDir + '/' + "qmake_subdir.qrc");
QVERIFY(qrcFile.exists());
QVERIFY(qrcFile.open(QFile::ReadOnly));
QByteArray qrcXml = qrcFile.readAll();
@ -742,7 +734,7 @@ void tst_qmake::resources()
}
{
QFile qrcFile(workDir + '/' + DIR_INFIX "qmake_qmake_immediate.qrc");
QFile qrcFile(workDir + '/' + "qmake_qmake_immediate.qrc");
QVERIFY(qrcFile.exists());
QVERIFY(qrcFile.open(QFile::ReadOnly));
QByteArray qrcXml = qrcFile.readAll();