--- /usr/share/cmake-2.8/Modules/FindCxxTest.cmake	2010-06-28 17:15:57.000000000 +0200
+++ FindCxxTest.cmake	2010-07-27 11:02:07.599450318 +0200
@@ -15,10 +15,8 @@
 #       True if the CxxTest framework was found
 #   CXXTEST_INCLUDE_DIR
 #       Where to find the CxxTest include directory
-#   CXXTEST_PERL_TESTGEN_EXECUTABLE
-#       The perl-based test generator.
-#   CXXTEST_PYTHON_TESTGEN_EXECUTABLE
-#       The python-based test generator.
+#   CXXTEST_TESTGEN_EXECUTABLE
+#       The test generator.
 #
 # MACROS for optional use by CMake users:
 #
@@ -65,8 +63,8 @@
 #
 
 #=============================================================================
-# Copyright 2008-2009 Kitware, Inc.
-# Copyright 2008-2009 Philip Lowman <philip@yhbt.com>
+# Copyright 2008-2010 Kitware, Inc.
+# Copyright 2008-2010 Philip Lowman <philip@yhbt.com>
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
@@ -78,6 +76,9 @@
 # (To distributed this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
+# Version 1.3 (25/7/10)
+#     Included patch by Simone Rossetto to check if either Python or Perl
+#     are present in the system
 # Version 1.2 (3/2/08)
 #     Included patch from Tyler Roscoe to have the perl & python binaries
 #     detected based on CXXTEST_INCLUDE_DIR
@@ -95,16 +96,11 @@
 #=============================================================
 macro(CXXTEST_ADD_TEST _cxxtest_testname _cxxtest_outfname)
     set(_cxxtest_real_outfname ${CMAKE_CURRENT_BINARY_DIR}/${_cxxtest_outfname})
-    if(CXXTEST_USE_PYTHON)
-        set(_cxxtest_executable ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE})
-    else()
-        set(_cxxtest_executable ${CXXTEST_PERL_TESTGEN_EXECUTABLE})
-    endif()
 
     add_custom_command(
         OUTPUT  ${_cxxtest_real_outfname}
         DEPENDS ${ARGN}
-        COMMAND ${_cxxtest_executable}
+        COMMAND ${CXXTEST_TESTGEN_EXECUTABLE}
         --error-printer -o ${_cxxtest_real_outfname} ${ARGN}
     )
 
@@ -124,14 +120,40 @@
 #=============================================================
 # main()
 #=============================================================
+find_package(PythonInterp QUIET)
+find_package(Perl QUIET)
 
-find_path(CXXTEST_INCLUDE_DIR cxxtest/TestSuite.h)
-find_program(CXXTEST_PERL_TESTGEN_EXECUTABLE cxxtestgen.pl
-    PATHS ${CXXTEST_INCLUDE_DIR})
-find_program(CXXTEST_PYTHON_TESTGEN_EXECUTABLE cxxtestgen.py
-    PATHS ${CXXTEST_INCLUDE_DIR})
-
-include(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(CxxTest DEFAULT_MSG CXXTEST_INCLUDE_DIR)
+if(CXXTEST_USE_PYTHON AND NOT PYTHONINTERP_FOUND AND PERL_FOUND)
+   set(CXXTEST_USE_PYTHON false)
+   message("CXXTEST_USE_PYTHON is TRUE but Python hasn't been found, using Perl-based generator instead.")
+endif(CXXTEST_USE_PYTHON AND NOT PYTHONINTERP_FOUND AND PERL_FOUND)
+
+if(PYTHONINTERP_FOUND OR PERL_FOUND)
+
+   if(CXXTEST_USE_PYTHON)
+      set(_cxxtest_generator cxxtestgen.py)
+   else(CXXTEST_USE_PYTHON)
+      set(_cxxtest_generator cxxtestgen.pl)
+   else(CXXTEST_USE_PYTHON)
+
+   find_path(CXXTEST_INCLUDE_DIR cxxtest/TestSuite.h)
+   find_program(CXXTEST_TESTGEN_EXECUTABLE ${_cxxtest_generator}
+       PATHS ${CXXTEST_INCLUDE_DIR})
+
+   include(FindPackageHandleStandardArgs)
+   FIND_PACKAGE_HANDLE_STANDARD_ARGS(CxxTest DEFAULT_MSG CXXTEST_INCLUDE_DIR)
+
+   set(CXXTEST_INCLUDE_DIRS ${CXXTEST_INCLUDE_DIR})
+
+else(PYTHONINTERP_FOUND OR PERL_FOUND)
+
+   set(CXXTEST_FOUND false)
+   if(NOT CxxTest_FIND_QUIETLY)
+      if(CxxTest_FIND_REQUIRED)
+         message(FATAL_ERROR "Neither Python nor Perl found, cannot use CxxTest, aborting!")
+      else(CxxTest_FIND_REQUIRED)
+         message(STATUS "Neither Python nor Perl found, CxxTest will not be used.")
+      endif(CxxTest_FIND_REQUIRED)
+   endif(NOT CxxTest_FIND_QUIETLY)
 
-set(CXXTEST_INCLUDE_DIRS ${CXXTEST_INCLUDE_DIR})
+endif(PYTHONINTERP_FOUND OR PERL_FOUND)
