KDE/kdelibs/cmake/modules

Thiago Macieira thiago at kde.org
Tue Jan 23 23:37:18 CET 2007


SVN commit 626619 by thiago:

Add macro KDE4_ADD_TEST for unit test usage. This way, if you have
CMake 2.4.4 or later, you don't need to turn on KDE4_BUILD_TESTS to be
allowed to build tests: just cd into the tests dir and
"make targetname".

PS: it's time we bumped the minimum version requirement for CMake...

CCMAIL:kde-buildsystem at kde.org


 M  +33 -0     KDE4Macros.cmake  


--- trunk/KDE/kdelibs/cmake/modules/KDE4Macros.cmake #626618:626619
@@ -663,6 +663,39 @@
 
 endmacro (KDE4_ADD_KDEINIT_EXECUTABLE)
 
+macro (KDE4_ADD_TEST _target_NAME)
+
+   MATH(EXPR cmake_version "${CMAKE_MAJOR_VERSION} * 10000 + ${CMAKE_MINOR_VERSION} * 100 + ${CMAKE_PATCH_VERSION}")
+
+   set(_add_executable_param)
+   set(_go)
+   if (KDE4_BUILD_TESTS)
+       set(_go TRUE)
+   else (KDE4_BUILD_TESTS)
+      if (cmake_version GREATER 20403)
+          set(_go TRUE)
+	  set(_add_executable_param EXCLUDE_FROM_ALL)
+      endif (cmake_version GREATER 20403)
+   endif (KDE4_BUILD_TESTS)
+
+   if (_go)
+       kde4_get_automoc_files(_automoc_FILES ${ARGN})
+
+       add_executable(${_target_NAME} ${_add_executable_param} ${ARGN} ${_automoc_FILES})
+
+       set_target_properties(${_target_NAME} PROPERTIES
+			     EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}
+			     DEFINITIONS -DKDESRCDIR=\\"${CMAKE_CURRENT_SOURCE_DIR}\\"
+			     SKIP_BUILD_RPATH FALSE
+			     BUILD_WITH_INSTALL_RPATH FALSE)
+
+       if (WIN32)
+       	  target_link_libraries(${_target_NAME} ${QT_QTMAIN_LIBRARY})
+       endif (WIN32)
+
+    endif (_go)
+endmacro (KDE4_ADD_TEST)
+
 macro (KDE4_ADD_EXECUTABLE _target_NAME)
 
    kde4_check_executable_params( _SRCS _nogui _uninst ${ARGN})


More information about the Kde-buildsystem mailing list