FindSquish.cmake 4.9 KB

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