FindSquish.cmake 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 ()
  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. file(TO_CMAKE_PATH "$ENV{PATH}" SQUISH_INSTALL_DIR_SEARCH2)
  44. # Construct a set of paths relative to the system search path.
  45. set(SQUISH_INSTALL_DIR_SEARCH "")
  46. foreach(dir ${SQUISH_INSTALL_DIR_SEARCH2})
  47. set(SQUISH_INSTALL_DIR_SEARCH ${SQUISH_INSTALL_DIR_SEARCH} "${dir}/../lib/fltk")
  48. endforeach()
  49. string(REPLACE "//" "/" SQUISH_INSTALL_DIR_SEARCH "${SQUISH_INSTALL_DIR_SEARCH}")
  50. # Look for an installation
  51. find_path(SQUISH_INSTALL_DIR bin/squishrunner
  52. # Look for an environment variable SQUISH_INSTALL_DIR.
  53. $ENV{SQUISH_INSTALL_DIR}
  54. # Look in places relative to the system executable search path.
  55. ${SQUISH_INSTALL_DIR_SEARCH}
  56. # Look in standard UNIX install locations.
  57. #/usr/local/squish
  58. DOC "The ${SQUISH_INSTALL_DIR_STRING}"
  59. )
  60. endif()
  61. # search for the executables
  62. if(SQUISH_INSTALL_DIR)
  63. set(SQUISH_INSTALL_DIR_FOUND 1)
  64. # find the client program
  65. if(NOT SQUISH_CLIENT_EXECUTABLE)
  66. find_program(SQUISH_CLIENT_EXECUTABLE ${SQUISH_INSTALL_DIR}/bin/squishrunner DOC "The ${SQUISH_CLIENT_EXECUTABLE_STRING}")
  67. endif()
  68. # find the server program
  69. if(NOT SQUISH_SERVER_EXECUTABLE)
  70. find_program(SQUISH_SERVER_EXECUTABLE ${SQUISH_INSTALL_DIR}/bin/squishserver DOC "The ${SQUISH_SERVER_EXECUTABLE_STRING}")
  71. endif()
  72. else()
  73. set(SQUISH_INSTALL_DIR_FOUND 0)
  74. endif()
  75. # record if executables are set
  76. if(SQUISH_CLIENT_EXECUTABLE)
  77. set(SQUISH_CLIENT_EXECUTABLE_FOUND 1)
  78. else()
  79. set(SQUISH_CLIENT_EXECUTABLE_FOUND 0)
  80. endif()
  81. if(SQUISH_SERVER_EXECUTABLE)
  82. set(SQUISH_SERVER_EXECUTABLE_FOUND 1)
  83. else()
  84. set(SQUISH_SERVER_EXECUTABLE_FOUND 0)
  85. endif()
  86. # record if Squish was found
  87. set(SQUISH_FOUND 1)
  88. foreach(var SQUISH_INSTALL_DIR_FOUND SQUISH_CLIENT_EXECUTABLE_FOUND SQUISH_SERVER_EXECUTABLE_FOUND)
  89. if(NOT ${var})
  90. set(SQUISH_FOUND 0)
  91. endif()
  92. endforeach()
  93. macro(SQUISH_ADD_TEST testName testAUT testCase envVars testWraper)
  94. add_test(${testName}
  95. ${CMAKE_COMMAND} -V -VV
  96. "-Dsquish_aut:STRING=${testAUT}"
  97. "-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"
  98. "-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"
  99. "-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"
  100. "-Dsquish_test_case:STRING=${testCase}"
  101. "-Dsquish_env_vars:STRING=${envVars}"
  102. "-Dsquish_wrapper:STRING=${testWraper}"
  103. -P "${CMAKE_ROOT}/Modules/SquishTestScript.cmake"
  104. )
  105. set_tests_properties(${testName}
  106. PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED;ERROR;FATAL"
  107. )
  108. endmacro()