Move the macros for invoking ctest to a shared location.

They are still internal, but all Qt5 modules will be able to use
them then.

Change-Id: I42ab656115b0976ca959293dfd664ec071f35dbf
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
Stephen Kelly 2012-06-29 08:32:01 +02:00 committed by Qt by Nokia
parent 7327ae8c17
commit 91720b5bc2
4 changed files with 62 additions and 42 deletions

View File

@ -0,0 +1,44 @@
macro(expect_pass _dir)
string(REPLACE "(" "_" testname "${_dir}")
string(REPLACE ")" "_" testname "${testname}")
add_test(${testname} ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMAKE_CURRENT_SOURCE_DIR}/${_dir}"
"${CMAKE_CURRENT_BINARY_DIR}/${_dir}"
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-options -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
)
endmacro()
macro(expect_fail _dir)
string(REPLACE "(" "_" testname "${_dir}")
string(REPLACE ")" "_" testname "${testname}")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/${_dir}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/CMakeLists.txt"
"
cmake_minimum_required(VERSION 2.8)
project(${_dir}_build)
try_compile(Result \${CMAKE_CURRENT_BINARY_DIR}/${_dir}
\${CMAKE_CURRENT_SOURCE_DIR}/${_dir}
${_dir}
OUTPUT_VARIABLE Out
)
message(\"\${Out}\")
if (Result)
message(SEND_ERROR \"Succeeded build which should fail\")
endif()
"
)
add_test(${testname} ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}"
"${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/build"
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-options -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
)
endmacro()

View File

@ -65,3 +65,7 @@ set_target_properties(Qt5::WinMain PROPERTIES
)
!!ENDIF
!!ENDIF
get_filename_component(_Qt5CoreConfigDir ${CMAKE_CURRENT_LIST_FILE} PATH)
set(_Qt5CTestMacros \"${_Qt5CoreConfigDir}/Qt5CTestMacros.cmake\")

View File

@ -71,3 +71,15 @@ lrelease_dir.name = lrelease_location
lrelease_dir.variable = QMAKE_LRELEASE
QMAKE_PKGCONFIG_VARIABLES += lupdate_dir lrelease_dir
ctest_macros_file.input = $$PWD/Qt5CTestMacros.cmake
ctest_macros_file.output = $$DESTDIR/cmake/Qt5Core/Qt5CTestMacros.cmake
ctest_macros_file.config = verbatim
QMAKE_SUBSTITUTES += ctest_macros_file
ctest_qt5_module_files.files += $$ctest_macros_file.output
ctest_qt5_module_files.path = $$[QT_INSTALL_LIBS]/cmake/Qt5Core
INSTALLS += ctest_qt5_module_files

View File

@ -43,49 +43,9 @@ project(qmake_cmake_files)
enable_testing()
macro(expect_pass _dir)
string(REPLACE "(" "_" testname "${_dir}")
string(REPLACE ")" "_" testname "${testname}")
add_test(${testname} ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMAKE_CURRENT_SOURCE_DIR}/${_dir}"
"${CMAKE_CURRENT_BINARY_DIR}/${_dir}"
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-options -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
)
endmacro()
find_package(Qt5Core REQUIRED)
macro(expect_fail _dir)
string(REPLACE "(" "_" testname "${_dir}")
string(REPLACE ")" "_" testname "${testname}")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/${_dir}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/CMakeLists.txt"
"
cmake_minimum_required(VERSION 2.8)
project(${_dir}_build)
try_compile(Result \${CMAKE_CURRENT_BINARY_DIR}/${_dir}
\${CMAKE_CURRENT_SOURCE_DIR}/${_dir}
${_dir}
OUTPUT_VARIABLE Out
)
message(\"\${Out}\")
if (Result)
message(SEND_ERROR \"Succeeded build which should fail\")
endif()
"
)
add_test(${testname} ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}"
"${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/build"
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-options -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
)
endmacro()
include("${_Qt5CTestMacros}")
if(NOT ${CMAKE_VERSION} VERSION_LESS 2.8.8)
# Requires INCLUDE_DIRECTORIES target property in CMake 2.8.8