Run the main executable created in the autogen tests.

Don't try to show the windows, which would require a gui capable test
machine, and that's not guaranteed.

Automatically link to qtmain.a on Windows to avoid a policy warning. Set
policy CMP0020 to NEW by increasing the required version.

Don't attempt to run the test when using Windows.
This commit is contained in:
Stephen Kelly 2013-10-11 20:16:43 +02:00
parent e485ba1219
commit 18fb7588df
3 changed files with 16 additions and 8 deletions

View File

@ -1029,6 +1029,15 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
) )
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt")
# On Windows there is no RPATH, so while Qt might be available for building,
# the required dlls may not be in the PATH, so we can't run the executables
# on that platform.
if(WIN32)
set(run_autogen_test ${CMAKE_CTEST_COMMAND} -V)
else()
set(run_autogen_test QtAutogen)
endif()
find_package(Qt5Widgets QUIET NO_MODULE) find_package(Qt5Widgets QUIET NO_MODULE)
if(Qt5Widgets_FOUND) if(Qt5Widgets_FOUND)
add_test(Qt5Autogen ${CMAKE_CTEST_COMMAND} add_test(Qt5Autogen ${CMAKE_CTEST_COMMAND}
@ -1040,7 +1049,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5Autogen" --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5Autogen"
--force-new-ctest-process --force-new-ctest-process
--build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5 --build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5
--test-command ${CMAKE_CTEST_COMMAND} -V --test-command ${run_autogen_test}
) )
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5Autogen") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5Autogen")
endif() endif()
@ -1054,7 +1063,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Autogen" --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Autogen"
--force-new-ctest-process --force-new-ctest-process
--build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4 --build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4
--test-command ${CMAKE_CTEST_COMMAND} -V --test-command ${run_autogen_test}
) )
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Autogen") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Autogen")

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8.11)
project(QtAutogen) project(QtAutogen)
@ -40,10 +40,10 @@ add_library(codeeditorLib STATIC codeeditor.cpp)
add_library(privateSlot OBJECT private_slot.cpp) add_library(privateSlot OBJECT private_slot.cpp)
add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp add_executable(QtAutogen main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp
xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot>) xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot>)
set_target_properties(foo codeeditorLib privateSlot PROPERTIES AUTOMOC TRUE) set_target_properties(QtAutogen codeeditorLib privateSlot PROPERTIES AUTOMOC TRUE)
include(GenerateExportHeader) include(GenerateExportHeader)
# The order is relevant here. B depends on A, and B headers depend on A # The order is relevant here. B depends on A, and B headers depend on A
@ -59,7 +59,7 @@ set_target_properties(libC PROPERTIES AUTOMOC TRUE)
generate_export_header(libC) generate_export_header(libC)
target_link_libraries(libC LINK_PUBLIC libB) target_link_libraries(libC LINK_PUBLIC libB)
target_link_libraries(foo codeeditorLib ${QT_LIBRARIES} libC) target_link_libraries(QtAutogen codeeditorLib ${QT_LIBRARIES} libC)
add_library(empty STATIC empty.cpp) add_library(empty STATIC empty.cpp)
set_target_properties(empty PROPERTIES AUTOMOC TRUE) set_target_properties(empty PROPERTIES AUTOMOC TRUE)

View File

@ -56,10 +56,9 @@ int main(int argv, char **args)
CodeEditor editor; CodeEditor editor;
editor.setWindowTitle(QObject::tr("Code Editor Example")); editor.setWindowTitle(QObject::tr("Code Editor Example"));
editor.show();
Window w; Window w;
w.show(); w.setWindowTitle(QObject::tr("Window Example"));
Foo foo; Foo foo;
foo.doFoo(); foo.doFoo();