FindSquish.cmake 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #
  2. # ---- Find Squish
  3. # This module can be used to find Squish (currently support is aimed at version 3).
  4. #
  5. # ---- Variables and Macros
  6. # SQUISH_FOUND If false, don't try to use Squish
  7. #
  8. # SQUISH_INSTALL_DIR The Squish installation directory (containing bin, lib, etc)
  9. # SQUISH_SERVER_EXECUTABLE The squishserver executable
  10. # SQUISH_CLIENT_EXECUTABLE The squishrunner executable
  11. #
  12. # SQUISH_INSTALL_DIR_FOUND Was the install directory found?
  13. # SQUISH_SERVER_EXECUTABLE_FOUND Was the server executable found?
  14. # SQUISH_CLIENT_EXECUTABLE_FOUND Was the client executable found?
  15. #
  16. # macro SQUISH_ADD_TEST(testName applicationUnderTest testSuite testCase)
  17. #
  18. # ---- Typical Use
  19. # ENABLE_TESTING()
  20. # FIND_PACKAGE(Squish)
  21. # IF (SQUISH_FOUND)
  22. # SQUISH_ADD_TEST(myTestName myApplication testSuiteName testCaseName)
  23. # ENDIF (SQUISH_FOUND)
  24. #
  25. #=============================================================================
  26. # Copyright 2008-2009 Kitware, Inc.
  27. #
  28. # Distributed under the OSI-approved BSD License (the "License");
  29. # see accompanying file Copyright.txt for details.
  30. #
  31. # This software is distributed WITHOUT ANY WARRANTY; without even the
  32. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  33. # See the License for more information.
  34. #=============================================================================
  35. # (To distribute this file outside of CMake, substitute the full
  36. # License text for the above reference.)
  37. SET(SQUISH_INSTALL_DIR_STRING "Directory containing the bin, doc, and lib directories for Squish; this should be the root of the installation directory.")
  38. SET(SQUISH_SERVER_EXECUTABLE_STRING "The squishserver executable program.")
  39. SET(SQUISH_CLIENT_EXECUTABLE_STRING "The squishclient executable program.")
  40. # Search only if the location is not already known.
  41. IF(NOT SQUISH_INSTALL_DIR)
  42. # Get the system search path as a list.
  43. IF(UNIX)
  44. STRING(REGEX MATCHALL "[^:]+" SQUISH_INSTALL_DIR_SEARCH1 "$ENV{PATH}")
  45. ELSE(UNIX)
  46. STRING(REGEX REPLACE "\\\\" "/" SQUISH_INSTALL_DIR_SEARCH1 "$ENV{PATH}")
  47. ENDIF(UNIX)
  48. STRING(REGEX REPLACE "/;" ";" SQUISH_INSTALL_DIR_SEARCH2 ${SQUISH_INSTALL_DIR_SEARCH1})
  49. # Construct a set of paths relative to the system search path.
  50. SET(SQUISH_INSTALL_DIR_SEARCH "")
  51. FOREACH(dir ${SQUISH_INSTALL_DIR_SEARCH2})
  52. SET(SQUISH_INSTALL_DIR_SEARCH ${SQUISH_INSTALL_DIR_SEARCH} "${dir}/../lib/fltk")
  53. ENDFOREACH(dir)
  54. # Look for an installation
  55. FIND_PATH(SQUISH_INSTALL_DIR bin/squishrunner
  56. # Look for an environment variable SQUISH_INSTALL_DIR.
  57. $ENV{SQUISH_INSTALL_DIR}
  58. # Look in places relative to the system executable search path.
  59. ${SQUISH_INSTALL_DIR_SEARCH}
  60. # Look in standard UNIX install locations.
  61. #/usr/local/squish
  62. DOC "The ${SQUISH_INSTALL_DIR_STRING}"
  63. )
  64. ENDIF(NOT SQUISH_INSTALL_DIR)
  65. # search for the executables
  66. IF(SQUISH_INSTALL_DIR)
  67. SET(SQUISH_INSTALL_DIR_FOUND 1)
  68. # find the client program
  69. IF(NOT SQUISH_CLIENT_EXECUTABLE)
  70. FIND_PROGRAM(SQUISH_CLIENT_EXECUTABLE ${SQUISH_INSTALL_DIR}/bin/squishrunner DOC "The ${SQUISH_CLIENT_EXECUTABLE_STRING}")
  71. ENDIF(NOT SQUISH_CLIENT_EXECUTABLE)
  72. # find the server program
  73. IF(NOT SQUISH_SERVER_EXECUTABLE)
  74. FIND_PROGRAM(SQUISH_SERVER_EXECUTABLE ${SQUISH_INSTALL_DIR}/bin/squishserver DOC "The ${SQUISH_SERVER_EXECUTABLE_STRING}")
  75. ENDIF(NOT SQUISH_SERVER_EXECUTABLE)
  76. ELSE(SQUISH_INSTALL_DIR)
  77. SET(SQUISH_INSTALL_DIR_FOUND 0)
  78. ENDIF(SQUISH_INSTALL_DIR)
  79. # record if executables are set
  80. IF(SQUISH_CLIENT_EXECUTABLE)
  81. SET(SQUISH_CLIENT_EXECUTABLE_FOUND 1)
  82. ELSE(SQUISH_CLIENT_EXECUTABLE)
  83. SET(SQUISH_CLIENT_EXECUTABLE_FOUND 0)
  84. ENDIF(SQUISH_CLIENT_EXECUTABLE)
  85. IF(SQUISH_SERVER_EXECUTABLE)
  86. SET(SQUISH_SERVER_EXECUTABLE_FOUND 1)
  87. ELSE(SQUISH_SERVER_EXECUTABLE)
  88. SET(SQUISH_SERVER_EXECUTABLE_FOUND 0)
  89. ENDIF(SQUISH_SERVER_EXECUTABLE)
  90. # record if Squish was found
  91. SET(SQUISH_FOUND 1)
  92. FOREACH(var SQUISH_INSTALL_DIR_FOUND SQUISH_CLIENT_EXECUTABLE_FOUND SQUISH_SERVER_EXECUTABLE_FOUND)
  93. IF(NOT ${var})
  94. SET(SQUISH_FOUND 0)
  95. ENDIF(NOT ${var})
  96. ENDFOREACH(var)
  97. MACRO(SQUISH_ADD_TEST testName testAUT testCase envVars testWraper)
  98. ADD_TEST(${testName}
  99. ${CMAKE_COMMAND} -V -VV
  100. "-Dsquish_aut:STRING=${testAUT}"
  101. "-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"
  102. "-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"
  103. "-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"
  104. "-Dsquish_test_case:STRING=${testCase}"
  105. "-Dsquish_env_vars:STRING=${envVars}"
  106. "-Dsquish_wrapper:STRING=${testWraper}"
  107. -P "${CMAKE_ROOT}/Modules/SquishTestScript.cmake"
  108. )
  109. SET_TESTS_PROPERTIES(${testName}
  110. PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED;ERROR;FATAL"
  111. )
  112. ENDMACRO(SQUISH_ADD_TEST)