Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / FindSquish.cmake
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 #=============================================================================
27 # Copyright 2008-2009 Kitware, Inc.
28 #
29 # Distributed under the OSI-approved BSD License (the "License");
30 # see accompanying file Copyright.txt for details.
31 #
32 # This software is distributed WITHOUT ANY WARRANTY; without even the
33 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
34 # See the License for more information.
35 #=============================================================================
36 # (To distribute this file outside of CMake, substitute the full
37 #  License text for the above reference.)
38
39 set(SQUISH_INSTALL_DIR_STRING "Directory containing the bin, doc, and lib directories for Squish; this should be the root of the installation directory.")
40 set(SQUISH_SERVER_EXECUTABLE_STRING "The squishserver executable program.")
41 set(SQUISH_CLIENT_EXECUTABLE_STRING "The squishclient executable program.")
42
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   file(TO_CMAKE_PATH "$ENV{PATH}" SQUISH_INSTALL_DIR_SEARCH2)
47
48   # Construct a set of paths relative to the system search path.
49   set(SQUISH_INSTALL_DIR_SEARCH "")
50   foreach(dir ${SQUISH_INSTALL_DIR_SEARCH2})
51     set(SQUISH_INSTALL_DIR_SEARCH ${SQUISH_INSTALL_DIR_SEARCH} "${dir}/../lib/fltk")
52   endforeach()
53   string(REPLACE "//" "/" SQUISH_INSTALL_DIR_SEARCH "${SQUISH_INSTALL_DIR_SEARCH}")
54
55   # Look for an installation
56   find_path(SQUISH_INSTALL_DIR bin/squishrunner
57     HINTS
58     # Look for an environment variable SQUISH_INSTALL_DIR.
59       ENV SQUISH_INSTALL_DIR
60
61     # Look in places relative to the system executable search path.
62     ${SQUISH_INSTALL_DIR_SEARCH}
63
64     # Look in standard UNIX install locations.
65     #/usr/local/squish
66
67     DOC "The ${SQUISH_INSTALL_DIR_STRING}"
68     )
69 endif()
70
71 # search for the executables
72 if(SQUISH_INSTALL_DIR)
73   set(SQUISH_INSTALL_DIR_FOUND 1)
74
75   # find the client program
76   if(NOT SQUISH_CLIENT_EXECUTABLE)
77     find_program(SQUISH_CLIENT_EXECUTABLE ${SQUISH_INSTALL_DIR}/bin/squishrunner DOC "The ${SQUISH_CLIENT_EXECUTABLE_STRING}")
78   endif()
79
80   # find the server program
81   if(NOT SQUISH_SERVER_EXECUTABLE)
82     find_program(SQUISH_SERVER_EXECUTABLE ${SQUISH_INSTALL_DIR}/bin/squishserver DOC "The ${SQUISH_SERVER_EXECUTABLE_STRING}")
83   endif()
84
85 else()
86   set(SQUISH_INSTALL_DIR_FOUND 0)
87 endif()
88
89 # record if executables are set
90 if(SQUISH_CLIENT_EXECUTABLE)
91   set(SQUISH_CLIENT_EXECUTABLE_FOUND 1)
92 else()
93   set(SQUISH_CLIENT_EXECUTABLE_FOUND 0)
94 endif()
95
96 if(SQUISH_SERVER_EXECUTABLE)
97   set(SQUISH_SERVER_EXECUTABLE_FOUND 1)
98 else()
99   set(SQUISH_SERVER_EXECUTABLE_FOUND 0)
100 endif()
101
102 # record if Squish was found
103 set(SQUISH_FOUND 1)
104 foreach(var SQUISH_INSTALL_DIR_FOUND SQUISH_CLIENT_EXECUTABLE_FOUND SQUISH_SERVER_EXECUTABLE_FOUND)
105   if(NOT ${var})
106     set(SQUISH_FOUND 0)
107   endif()
108 endforeach()
109
110 macro(SQUISH_ADD_TEST testName testAUT testCase envVars testWraper)
111   add_test(${testName}
112     ${CMAKE_COMMAND} -V -VV
113     "-Dsquish_aut:STRING=${testAUT}"
114     "-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"
115     "-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"
116     "-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"
117     "-Dsquish_test_case:STRING=${testCase}"
118     "-Dsquish_env_vars:STRING=${envVars}"
119     "-Dsquish_wrapper:STRING=${testWraper}"
120     -P "${CMAKE_ROOT}/Modules/SquishTestScript.cmake"
121     )
122   set_tests_properties(${testName}
123     PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED;ERROR;FATAL"
124     )
125 endmacro()
126