Skip to content

Commit 90ef60f

Browse files
committed
Add CMake testing support
Disabled by default to keep behavior consistent with previous CMake'ified version.
1 parent e802dcc commit 90ef60f

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

CMakeLists.txt

+35-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ cmake_minimum_required(VERSION 2.8)
1111
project(PythonQt)
1212
#-----------------------------------------------------------------------------
1313

14-
include(CTestUseLaunchers OPTIONAL)
15-
1614
#-----------------------------------------------------------------------------
1715
# Python libraries
1816

@@ -71,7 +69,9 @@ if(QT4_FOUND)
7169
endif()
7270
set(QT_USE_QT${qtlib_uppercase} ${PythonQt_Wrap_Qt${qtlib}})
7371
endforeach()
74-
72+
73+
set(QT_USE_QTTEST ${BUILD_TESTING})
74+
7575
include(${QT_USE_FILE})
7676
else()
7777
message(FATAL_ERROR "error: Qt4 was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable")
@@ -238,3 +238,35 @@ install(TARGETS PythonQt
238238
LIBRARY DESTINATION lib
239239
ARCHIVE DESTINATION lib)
240240
install(FILES ${headers} DESTINATION include/PythonQt)
241+
242+
#-----------------------------------------------------------------------------
243+
# Testing
244+
245+
option(BUILD_TESTING "Build the testing tree." OFF)
246+
include(CTest)
247+
248+
if(BUILD_TESTING)
249+
create_test_sourcelist(test_sources PythonQtCppTests.cpp
250+
tests/PythonQtTestMain.cpp
251+
)
252+
253+
list(APPEND test_sources
254+
tests/PythonQtTests.cpp
255+
tests/PythonQtTests.h
256+
)
257+
258+
QT4_WRAP_CPP(test_sources
259+
tests/PythonQtTests.h
260+
)
261+
262+
set_property(SOURCE tests/PythonQtTestMain.cpp PROPERTY COMPILE_DEFINITIONS "main=tests_PythonQtTestMain")
263+
264+
add_executable(PythonQtCppTests ${test_sources})
265+
target_link_libraries(PythonQtCppTests PythonQt)
266+
267+
add_test(
268+
NAME tests_PythonQtTestMain
269+
COMMAND ${Slicer_LAUNCH_COMMAND} $<TARGET_FILE:PythonQtCppTests> tests/PythonQtTestMain
270+
)
271+
endif()
272+

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ This repository contains three branches:
4848

4949
### patched-4
5050
* Based on patched-3 + [r245](http://sourceforge.net/p/pythonqt/code/245/)
51+
* List of features:
52+
* Add BUILD_TESTING option disabled by default to keep behavior consistent with previous version.
5153

5254
### patched-3
5355
* Backported:

0 commit comments

Comments
 (0)