From af61b5ca5cd92dbf21ee42e0a74f618b3b578ddd Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 25 Jun 2020 20:45:55 +0200 Subject: [PATCH] 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 --- tests/auto/tools/qmake/CMakeLists.txt | 13 ------------- tests/auto/tools/qmake/qmake.pro | 6 ------ .../tools/qmake/testdata/resources/resources.pro | 1 + tests/auto/tools/qmake/tst_qmake.cpp | 14 +++----------- 4 files changed, 4 insertions(+), 30 deletions(-) diff --git a/tests/auto/tools/qmake/CMakeLists.txt b/tests/auto/tools/qmake/CMakeLists.txt index 994d5d47d16..62db9257b80 100644 --- a/tests/auto/tools/qmake/CMakeLists.txt +++ b/tests/auto/tools/qmake/CMakeLists.txt @@ -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 diff --git a/tests/auto/tools/qmake/qmake.pro b/tests/auto/tools/qmake/qmake.pro index ac52fb81fa1..0e8ebcc7cce 100644 --- a/tests/auto/tools/qmake/qmake.pro +++ b/tests/auto/tools/qmake/qmake.pro @@ -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/* diff --git a/tests/auto/tools/qmake/testdata/resources/resources.pro b/tests/auto/tools/qmake/testdata/resources/resources.pro index f024fe56170..8ced5048ae4 100644 --- a/tests/auto/tools/qmake/testdata/resources/resources.pro +++ b/tests/auto/tools/qmake/testdata/resources/resources.pro @@ -1,4 +1,5 @@ TEMPLATE = app +CONFIG -= debug_and_release SOURCES = main.cpp pro_file.files = resources.pro diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index 7f98a0f5a00..2b9ecddf2ba 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -37,14 +37,6 @@ #include #include -#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();