- refactor tests repeat-myself with a cmake macro

- enable cmake testing
This commit is contained in:
Duncan Mac-Vicar P 2011-03-31 20:26:51 +02:00
parent 9ac0397ff9
commit f22caca96b
2 changed files with 15 additions and 9 deletions

View file

@ -1,7 +1,19 @@
cmake_minimum_required(VERSION 2.8)
project(mirall)
find_package(Qt4 4.4.3 COMPONENTS QtCore QtGui QtXml QtTest REQUIRED )
find_package(Qt4 4.4.3 COMPONENTS QtCore QtGui QtXml QtNetwork QtTest REQUIRED )
macro(add_tests)
foreach( loop_var ${ARGV} )
qt4_automoc(test${loop_var}.cpp)
add_executable(test${loop_var} test${loop_var}.cpp)
target_link_libraries(test${loop_var} ${QT_LIBRARIES} mirall_static)
add_test(test${loop_var} ${CMAKE_CURRENT_BINARY_DIR}/test${loop_var} --catch_system_errors=no)
endforeach( loop_var )
endmacro(add_tests)
include(CTest)
enable_testing()
add_subdirectory(src)
add_subdirectory(test)

View file

@ -3,10 +3,4 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include(${QT_USE_FILE})
qt4_automoc(testfolderwatcher.cpp)
add_executable(testfolderwatcher testfolderwatcher.cpp)
target_link_libraries(testfolderwatcher ${QT_LIBRARIES} mirall_static)
qt4_automoc(testunisonfolder.cpp)
add_executable(testunisonfolder testunisonfolder.cpp)
target_link_libraries(testunisonfolder ${QT_LIBRARIES} mirall_static)
add_tests(folderwatcher unisonfolder)