mirror of
https://github.com/reactos/CMake.git
synced 2024-11-28 14:01:21 +00:00
Autogen: Tests: Separate RerunMocBasic test
This commit is contained in:
parent
4988746e76
commit
54b4ff2aee
@ -31,3 +31,5 @@ endif()
|
||||
ADD_AUTOGEN_TEST(SameName sameName)
|
||||
ADD_AUTOGEN_TEST(StaticLibraryCycle slc)
|
||||
ADD_AUTOGEN_TEST(Complex QtAutogen)
|
||||
# Rerun tests
|
||||
ADD_AUTOGEN_TEST(RerunMocBasic)
|
||||
|
65
Tests/QtAutogen/RerunMocBasic/CMakeLists.txt
Normal file
65
Tests/QtAutogen/RerunMocBasic/CMakeLists.txt
Normal file
@ -0,0 +1,65 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(RerunMocBasic)
|
||||
include("../AutogenTest.cmake")
|
||||
|
||||
# Dummy executable to generate a clean target
|
||||
add_executable(dummy dummy.cpp)
|
||||
|
||||
set(timeformat "%Y%j%H%M%S")
|
||||
set(mocBasicSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/MocBasic")
|
||||
set(mocBasicBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocBasic")
|
||||
|
||||
# Initial build
|
||||
configure_file("${mocBasicSrcDir}/test1a.h.in" "${mocBasicBinDir}/test1.h" COPYONLY)
|
||||
try_compile(MOC_RERUN
|
||||
"${mocBasicBinDir}"
|
||||
"${mocBasicSrcDir}"
|
||||
MocBasic
|
||||
CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
|
||||
"-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
|
||||
OUTPUT_VARIABLE output
|
||||
)
|
||||
if (NOT MOC_RERUN)
|
||||
message(SEND_ERROR "Initial build of mocBasic failed. Output: ${output}")
|
||||
endif()
|
||||
# Get name of the output binary
|
||||
file(STRINGS "${mocBasicBinDir}/mocBasic.txt" mocBasicList ENCODING UTF-8)
|
||||
list(GET mocBasicList 0 mocBasicBin)
|
||||
|
||||
message("Changing the header content for a MOC rerun")
|
||||
# - Acquire binary timestamps before the build
|
||||
file(TIMESTAMP "${mocBasicBin}" timeBefore "${timeformat}")
|
||||
# - Ensure that the timestamp will change
|
||||
# - Change header file content and rebuild
|
||||
# - Rebuild
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
configure_file("${mocBasicSrcDir}/test1b.h.in" "${mocBasicBinDir}/test1.h" COPYONLY)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result )
|
||||
if (result)
|
||||
message(SEND_ERROR "Second build of mocBasic failed.")
|
||||
endif()
|
||||
# - Acquire binary timestamps after the build
|
||||
file(TIMESTAMP "${mocBasicBin}" timeAfter "${timeformat}")
|
||||
# - Test if timestamps changed
|
||||
if (NOT timeAfter GREATER timeBefore)
|
||||
message(SEND_ERROR "File (${mocBasicBin}) should have changed!")
|
||||
endif()
|
||||
|
||||
|
||||
message("Changing nothing for a MOC rerun")
|
||||
# - Acquire binary timestamps before the build
|
||||
file(TIMESTAMP "${mocBasicBin}" timeBefore "${timeformat}")
|
||||
# - Ensure that the timestamp would change
|
||||
# - Change nothing
|
||||
# - Rebuild
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result )
|
||||
if (result)
|
||||
message(SEND_ERROR "Third build of mocBasic failed.")
|
||||
endif()
|
||||
# - Acquire binary timestamps after the build
|
||||
file(TIMESTAMP "${mocBasicBin}" timeAfter "${timeformat}")
|
||||
# - Test if timestamps changed
|
||||
if (timeAfter GREATER timeBefore)
|
||||
message(SEND_ERROR "File (${mocBasicBin}) should not have changed!")
|
||||
endif()
|
24
Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt
Normal file
24
Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(MocBasic)
|
||||
include("../../AutogenTest.cmake")
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
# Generated source file
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
|
||||
COMMAND ${CMAKE_COMMAND} -E sleep 2
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
|
||||
)
|
||||
|
||||
add_executable(mocBasic
|
||||
${CMAKE_CURRENT_BINARY_DIR}/test1.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/main.cpp
|
||||
res1.qrc
|
||||
)
|
||||
target_include_directories(mocBasic PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_link_libraries(mocBasic ${QT_QTCORE_TARGET})
|
||||
# Write target name to text file
|
||||
add_custom_command(TARGET mocBasic POST_BUILD COMMAND
|
||||
${CMAKE_COMMAND} -E echo "$<TARGET_FILE:mocBasic>" > mocBasic.txt
|
||||
)
|
@ -1,5 +1,7 @@
|
||||
#include "test1.h"
|
||||
|
||||
extern int qInitResources_res1();
|
||||
|
||||
class Test2 : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -9,6 +11,9 @@ public slots:
|
||||
|
||||
int main()
|
||||
{
|
||||
// Fails to link if the rcc generated symbol is not present.
|
||||
qInitResources_res1();
|
||||
|
||||
Test1 test1;
|
||||
Test2 test2;
|
||||
|
5
Tests/QtAutogen/RerunMocBasic/dummy.cpp
Normal file
5
Tests/QtAutogen/RerunMocBasic/dummy.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
int main(int argv, char** args)
|
||||
{
|
||||
return 0;
|
||||
}
|
@ -6,7 +6,7 @@ project(QtAutogenRerun)
|
||||
if(QT_QMAKE_EXECUTABLE)
|
||||
get_filename_component(Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH)
|
||||
get_filename_component(Qt_PREFIX_DIR "${Qt_BIN_DIR}" PATH)
|
||||
set(CMAKE_PREFIX_PATH ${Qt_PREFIX_DIR})
|
||||
list(APPEND CMAKE_PREFIX_PATH ${Qt_PREFIX_DIR})
|
||||
endif()
|
||||
|
||||
if (QT_TEST_VERSION STREQUAL 4)
|
||||
@ -39,9 +39,6 @@ endif()
|
||||
# Dummy executable to generate clean target
|
||||
add_executable(dummy dummy.cpp)
|
||||
|
||||
# -- Test
|
||||
include("mocRerun.cmake")
|
||||
|
||||
# -- Test
|
||||
# Tests Q_PLUGIN_METADATA json file change detection
|
||||
if (NOT QT_TEST_VERSION STREQUAL 4)
|
||||
|
@ -1,60 +0,0 @@
|
||||
|
||||
set(timeformat "%Y%j%H%M%S")
|
||||
set(mocRerunSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/mocRerun")
|
||||
set(mocRerunBinDir "${CMAKE_CURRENT_BINARY_DIR}/mocRerun")
|
||||
|
||||
# Initial build
|
||||
configure_file("${mocRerunSrcDir}/test1a.h.in" "${mocRerunBinDir}/test1.h" COPYONLY)
|
||||
try_compile(MOC_RERUN
|
||||
"${mocRerunBinDir}"
|
||||
"${mocRerunSrcDir}"
|
||||
mocRerun
|
||||
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 mocRerun failed. Output: ${output}")
|
||||
endif()
|
||||
# Get name of the output binary
|
||||
file(STRINGS "${mocRerunBinDir}/mocRerun.txt" mocRerunList ENCODING UTF-8)
|
||||
list(GET mocRerunList 0 mocRerunBin)
|
||||
|
||||
message("Changing the header content for a MOC rerun")
|
||||
# - Acquire binary timestamps before the build
|
||||
file(TIMESTAMP "${mocRerunBin}" timeBefore "${timeformat}")
|
||||
# - Ensure that the timestamp will change
|
||||
# - Change header file content and rebuild
|
||||
# - Rebuild
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
configure_file("${mocRerunSrcDir}/test1b.h.in" "${mocRerunBinDir}/test1.h" COPYONLY)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocRerunBinDir}" RESULT_VARIABLE result )
|
||||
if (result)
|
||||
message(SEND_ERROR "Second build of mocRerun failed.")
|
||||
endif()
|
||||
# - Acquire binary timestamps after the build
|
||||
file(TIMESTAMP "${mocRerunBin}" timeAfter "${timeformat}")
|
||||
# - Test if timestamps changed
|
||||
if (NOT timeAfter GREATER timeBefore)
|
||||
message(SEND_ERROR "File (${mocRerunBin}) should have changed!")
|
||||
endif()
|
||||
|
||||
|
||||
message("Changing nothing for a MOC rerun")
|
||||
# - Acquire binary timestamps before the build
|
||||
file(TIMESTAMP "${mocRerunBin}" timeBefore "${timeformat}")
|
||||
# - Ensure that the timestamp would change
|
||||
# - Change nothing
|
||||
# - Rebuild
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocRerunBinDir}" RESULT_VARIABLE result )
|
||||
if (result)
|
||||
message(SEND_ERROR "Third build of mocRerun failed.")
|
||||
endif()
|
||||
# - Acquire binary timestamps after the build
|
||||
file(TIMESTAMP "${mocRerunBin}" timeAfter "${timeformat}")
|
||||
# - Test if timestamps changed
|
||||
if (timeAfter GREATER timeBefore)
|
||||
message(SEND_ERROR "File (${mocRerunBin}) should not have changed!")
|
||||
endif()
|
@ -1,33 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.9)
|
||||
cmake_policy(SET CMP0071 NEW)
|
||||
project(mocRerun 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)
|
||||
|
||||
# Generated source file
|
||||
add_custom_command(OUTPUT main.cpp
|
||||
COMMAND ${CMAKE_COMMAND} -E sleep 2
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/main.cpp)
|
||||
|
||||
add_executable(mocRerun
|
||||
${CMAKE_CURRENT_BINARY_DIR}/test1.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/main.cpp
|
||||
res1.qrc)
|
||||
target_include_directories(mocRerun PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_link_libraries(mocRerun ${QT_CORE_TARGET})
|
||||
# Write target name to text file
|
||||
add_custom_command(TARGET mocRerun POST_BUILD COMMAND
|
||||
${CMAKE_COMMAND} -E echo "$<TARGET_FILE:mocRerun>" > mocRerun.txt)
|
Loading…
Reference in New Issue
Block a user