#
# ---- Find Squish
# This module can be used to find Squish (currently support is aimed at version 3).
#
# ---- Variables and Macros
# SQUISH_FOUND If false, don't try to use Squish
#
# SQUISH_INSTALL_DIR The Squish installation directory (containing bin, lib, etc)
# SQUISH_SERVER_EXECUTABLE The squishserver executable
# SQUISH_CLIENT_EXECUTABLE The squishrunner executable
#
# SQUISH_INSTALL_DIR_FOUND Was the install directory found?
# SQUISH_SERVER_EXECUTABLE_FOUND Was the server executable found?
# SQUISH_CLIENT_EXECUTABLE_FOUND Was the client executable found?
#
# macro SQUISH_ADD_TEST(testName applicationUnderTest testSuite testCase)
#
# ---- Typical Use
# ENABLE_TESTING()
# FIND_PACKAGE(Squish)
# IF (SQUISH_FOUND)
# SQUISH_ADD_TEST(myTestName myApplication testSuiteName testCaseName)
# ENDIF (SQUISH_FOUND)
#
#=============================================================================
# Copyright 2008-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
SET ( SQUISH_INSTALL_DIR_STRING "Directory containing the bin, doc, and lib directories for Squish; this should be the root of the installation directory." )
SET ( SQUISH_SERVER_EXECUTABLE_STRING "The squishserver executable program." )
SET ( SQUISH_CLIENT_EXECUTABLE_STRING "The squishclient executable program." )
# Search only if the location is not already known.
IF ( NOT SQUISH_INSTALL_DIR )
# Get the system search path as a list.
IF ( UNIX )
STRING ( REGEX MATCHALL "[^:]+" SQUISH_INSTALL_DIR_SEARCH1 "$ENV{PATH}" )
ELSE ( UNIX )
STRING ( REGEX REPLACE "\\\\" "/" SQUISH_INSTALL_DIR_SEARCH1 "$ENV{PATH}" )
ENDIF ( UNIX )
STRING ( REGEX REPLACE "/;" ";" SQUISH_INSTALL_DIR_SEARCH2 ${ SQUISH_INSTALL_DIR_SEARCH1 } )
# Construct a set of paths relative to the system search path.
SET ( SQUISH_INSTALL_DIR_SEARCH "" )
FOREACH ( dir ${ SQUISH_INSTALL_DIR_SEARCH2 } )
SET ( SQUISH_INSTALL_DIR_SEARCH ${ SQUISH_INSTALL_DIR_SEARCH } "${dir}/../lib/fltk" )
ENDFOREACH ( dir )
# Look for an installation
FIND_PATH ( SQUISH_INSTALL_DIR bin/squishrunner
# Look for an environment variable SQUISH_INSTALL_DIR.
$ E N V { S Q U I S H _ I N S T A L L _ D I R }
# Look in places relative to the system executable search path.
$ { S Q U I S H _ I N S T A L L _ D I R _ S E A R C H }
# Look in standard UNIX install locations.
#/usr/local/squish
D O C " T h e $ { S Q U I S H _ I N S T A L L _ D I R _ S T R I N G } "
)
ENDIF ( NOT SQUISH_INSTALL_DIR )
# search for the executables
IF ( SQUISH_INSTALL_DIR )
SET ( SQUISH_INSTALL_DIR_FOUND 1 )
# find the client program
IF ( NOT SQUISH_CLIENT_EXECUTABLE )
FIND_PROGRAM ( SQUISH_CLIENT_EXECUTABLE ${ SQUISH_INSTALL_DIR } /bin/squishrunner DOC "The ${SQUISH_CLIENT_EXECUTABLE_STRING}" )
ENDIF ( NOT SQUISH_CLIENT_EXECUTABLE )
# find the server program
IF ( NOT SQUISH_SERVER_EXECUTABLE )
FIND_PROGRAM ( SQUISH_SERVER_EXECUTABLE ${ SQUISH_INSTALL_DIR } /bin/squishserver DOC "The ${SQUISH_SERVER_EXECUTABLE_STRING}" )
ENDIF ( NOT SQUISH_SERVER_EXECUTABLE )
ELSE ( SQUISH_INSTALL_DIR )
SET ( SQUISH_INSTALL_DIR_FOUND 0 )
ENDIF ( SQUISH_INSTALL_DIR )
# record if executables are set
IF ( SQUISH_CLIENT_EXECUTABLE )
SET ( SQUISH_CLIENT_EXECUTABLE_FOUND 1 )
ELSE ( SQUISH_CLIENT_EXECUTABLE )
SET ( SQUISH_CLIENT_EXECUTABLE_FOUND 0 )
ENDIF ( SQUISH_CLIENT_EXECUTABLE )
IF ( SQUISH_SERVER_EXECUTABLE )
SET ( SQUISH_SERVER_EXECUTABLE_FOUND 1 )
ELSE ( SQUISH_SERVER_EXECUTABLE )
SET ( SQUISH_SERVER_EXECUTABLE_FOUND 0 )
ENDIF ( SQUISH_SERVER_EXECUTABLE )
# record if Squish was found
SET ( SQUISH_FOUND 1 )
FOREACH ( var SQUISH_INSTALL_DIR_FOUND SQUISH_CLIENT_EXECUTABLE_FOUND SQUISH_SERVER_EXECUTABLE_FOUND )
IF ( NOT ${ var } )
SET ( SQUISH_FOUND 0 )
ENDIF ( NOT ${ var } )
ENDFOREACH ( var )
MACRO ( SQUISH_ADD_TEST testName testAUT testCase envVars testWraper )
ADD_TEST ( ${ testName }
$ { C M A K E _ C O M M A N D } - V - V V
" - D s q u i s h _ a u t : S T R I N G = $ { t e s t A U T } "
" - D s q u i s h _ s e r v e r _ e x e c u t a b l e : S T R I N G = $ { S Q U I S H _ S E R V E R _ E X E C U T A B L E } "
" - D s q u i s h _ c l i e n t _ e x e c u t a b l e : S T R I N G = $ { S Q U I S H _ C L I E N T _ E X E C U T A B L E } "
" - D s q u i s h _ l i b q t d i r : S T R I N G = $ { Q T _ L I B R A R Y _ D I R } "
" - D s q u i s h _ t e s t _ c a s e : S T R I N G = $ { t e s t C a s e } "
" - D s q u i s h _ e n v _ v a r s : S T R I N G = $ { e n v V a r s } "
" - D s q u i s h _ w r a p p e r : S T R I N G = $ { t e s t W r a p e r } "
- P " $ { C M A K E _ R O O T } / M o d u l e s / S q u i s h T e s t S c r i p t . c m a k e "
)
SET_TESTS_PROPERTIES ( ${ testName }
P R O P E R T I E S F A I L _ R E G U L A R _ E X P R E S S I O N " F A I L E D ; E R R O R ; F A T A L "
)
ENDMACRO ( SQUISH_ADD_TEST )