Merge topic 'qt-autogen-always-run'
2bf22a4b QtAutogen: Add comment explaining why rcc cannot use PRE_BUILD 0e346427 QtAutogen: Always run autogen step even when rcc is enabled (#15608)
This commit is contained in:
commit
bddfe77d12
@ -439,6 +439,9 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
|
|||||||
this->ListQt4RccInputs(sf, depends);
|
this->ListQt4RccInputs(sf, depends);
|
||||||
}
|
}
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
// Cannot use PRE_BUILD because the resource files themselves
|
||||||
|
// may not be sources within the target so VS may not know the
|
||||||
|
// target needs to re-build at all.
|
||||||
usePRE_BUILD = false;
|
usePRE_BUILD = false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -465,31 +468,11 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
cmTarget* autogenTarget = 0;
|
cmTarget* autogenTarget = makefile->AddUtilityCommand(
|
||||||
if (!rcc_output.empty() && !isNinja)
|
|
||||||
{
|
|
||||||
std::vector<std::string> no_byproducts;
|
|
||||||
makefile->AddCustomCommandToOutput(rcc_output, no_byproducts,
|
|
||||||
depends, "",
|
|
||||||
commandLines, 0,
|
|
||||||
workingDirectory.c_str(),
|
|
||||||
false, false);
|
|
||||||
|
|
||||||
cmCustomCommandLines no_commands;
|
|
||||||
autogenTarget = makefile->AddUtilityCommand(
|
|
||||||
autogenTargetName, true,
|
|
||||||
workingDirectory.c_str(), rcc_output,
|
|
||||||
no_commands, false, autogenComment.c_str());
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
autogenTarget = makefile->AddUtilityCommand(
|
|
||||||
autogenTargetName, true,
|
autogenTargetName, true,
|
||||||
workingDirectory.c_str(),
|
workingDirectory.c_str(),
|
||||||
/*byproducts=*/rcc_output, depends,
|
/*byproducts=*/rcc_output, depends,
|
||||||
commandLines, false, autogenComment.c_str());
|
commandLines, false, autogenComment.c_str());
|
||||||
}
|
|
||||||
|
|
||||||
// Set target folder
|
// Set target folder
|
||||||
const char* autogenFolder = makefile->GetState()
|
const char* autogenFolder = makefile->GetState()
|
||||||
|
@ -167,3 +167,26 @@ file(TIMESTAMP "${qrc_file1}" file1_step1 "${timeformat}")
|
|||||||
if (NOT file1_step1 GREATER file1_before)
|
if (NOT file1_step1 GREATER file1_before)
|
||||||
message(SEND_ERROR "file1 (${qrc_file1}) should have changed in the first step!")
|
message(SEND_ERROR "file1 (${qrc_file1}) should have changed in the first step!")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
try_compile(MOC_RERUN
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/automoc_rerun"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/automoc_rerun"
|
||||||
|
automoc_rerun
|
||||||
|
CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
|
||||||
|
"-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
|
||||||
|
OUTPUT_VARIABLE output
|
||||||
|
)
|
||||||
|
if (NOT MOC_RERUN)
|
||||||
|
message(SEND_ERROR "Initial build of automoc_rerun failed. Output: ${output}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
configure_file(automoc_rerun/test1.h.in2 automoc_rerun/test1.h COPYONLY)
|
||||||
|
|
||||||
|
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/automoc_rerun"
|
||||||
|
RESULT_VARIABLE automoc_rerun_result
|
||||||
|
)
|
||||||
|
if (automoc_rerun_result)
|
||||||
|
message(SEND_ERROR "Second build of automoc_rerun failed.")
|
||||||
|
endif()
|
||||||
|
27
Tests/QtAutogen/automoc_rerun/CMakeLists.txt
Normal file
27
Tests/QtAutogen/automoc_rerun/CMakeLists.txt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.1)
|
||||||
|
project(automoc_rerun CXX)
|
||||||
|
|
||||||
|
if (QT_TEST_VERSION STREQUAL 4)
|
||||||
|
find_package(Qt4 REQUIRED)
|
||||||
|
set(QT_CORE_TARGET Qt4::QtCore)
|
||||||
|
else()
|
||||||
|
if (NOT QT_TEST_VERSION STREQUAL 5)
|
||||||
|
message(SEND_ERROR "Invalid Qt version specified.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(Qt5Core REQUIRED)
|
||||||
|
set(QT_CORE_TARGET Qt5::Core)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
set(CMAKE_AUTORCC ON)
|
||||||
|
|
||||||
|
configure_file(test1.h.in1 test1.h COPYONLY)
|
||||||
|
|
||||||
|
add_executable(test1
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/test1.h
|
||||||
|
test1.cpp
|
||||||
|
res1.qrc
|
||||||
|
)
|
||||||
|
target_include_directories(test1 PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
target_link_libraries(test1 ${QT_CORE_TARGET})
|
1
Tests/QtAutogen/automoc_rerun/input.txt
Normal file
1
Tests/QtAutogen/automoc_rerun/input.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Res1 input.
|
5
Tests/QtAutogen/automoc_rerun/res1.qrc
Normal file
5
Tests/QtAutogen/automoc_rerun/res1.qrc
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>input.txt</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
5
Tests/QtAutogen/automoc_rerun/test1.cpp
Normal file
5
Tests/QtAutogen/automoc_rerun/test1.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#include "test1.h"
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
8
Tests/QtAutogen/automoc_rerun/test1.h.in1
Normal file
8
Tests/QtAutogen/automoc_rerun/test1.h.in1
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include <QObject>
|
||||||
|
class test1 : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public slots:
|
||||||
|
void onTst1() {}
|
||||||
|
void onTst2() {}
|
||||||
|
};
|
7
Tests/QtAutogen/automoc_rerun/test1.h.in2
Normal file
7
Tests/QtAutogen/automoc_rerun/test1.h.in2
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include <QObject>
|
||||||
|
class test1 : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public slots:
|
||||||
|
void onTst1() {}
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user