Skip to content

Commit 5a3b9b6

Browse files
committed
Add CMake testing support
Disabled by default to keep behavior consistent with previous CMake'ified version.
1 parent f5178e1 commit 5a3b9b6

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

CMakeLists.txt

Lines changed: 35 additions & 3 deletions
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+

0 commit comments

Comments
 (0)