2008-12-09 01:39:30 +03:00
#
# ---- Find Squish
2012-11-05 00:06:20 +04:00
# This module can be used to find Squish. Currently Squish versions 3 and 4 are supported.
2008-12-09 01:39:30 +03:00
#
# ---- Variables and Macros
2009-10-19 20:58:40 +04:00
# SQUISH_FOUND If false, don't try to use Squish
2012-11-04 22:11:43 +04:00
# SQUISH_VERSION The full version of Squish found
# SQUISH_VERSION_MAJOR The major version of Squish found
# SQUISH_VERSION_MINOR The minor version of Squish found
# SQUISH_VERSION_PATCH The patch version of Squish found
2008-12-09 01:39:30 +03:00
#
2009-10-19 20:58:40 +04:00
# SQUISH_INSTALL_DIR The Squish installation directory (containing bin, lib, etc)
# SQUISH_SERVER_EXECUTABLE The squishserver executable
# SQUISH_CLIENT_EXECUTABLE The squishrunner executable
2008-12-09 01:39:30 +03:00
#
2009-10-19 20:58:40 +04:00
# 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?
2008-12-09 01:39:30 +03:00
#
2012-11-05 00:06:20 +04:00
# It provides the function squish_v4_add_test() for adding a squish test to cmake using Squish 4.x:
#
# squish_v4_add_test(cmakeTestName AUT targetName SUITE suiteName TEST squishTestName
# [SETTINGSGROUP group] [PRE_COMMAND command] [POST_COMMAND command] )
#
# The arguments have the following meaning:
# cmakeTestName: this will be used as the first argument for add_test()
# AUT targetName: the name of the cmake target which will be used as AUT, i.e. the
# executable which will be tested.
# SUITE suiteName: this is either the full path to the squish suite, or just the
# last directory of the suite, i.e. the suite name. In this case
# the CMakeLists.txt which calls squish_add_test() must be located
# in the parent directory of the suite directory.
# TEST squishTestName: the name of the squish test, i.e. the name of the subdirectory
# of the test inside the suite directory.
# SETTINGSGROUP group: if specified, the given settings group will be used for executing the test.
# If not specified, the groupname will be "CTest_<username>"
# PRE_COMMAND command: if specified, the given command will be executed before starting the squish test.
# POST_COMMAND command: same as PRE_COMMAND, but after the squish test has been executed.
#
# ---- Typical Use
# enable_testing()
# find_package(Squish 4.0)
# if (SQUISH_FOUND)
# squish_v4_add_test(myTestName AUT myApp SUITE ${CMAKE_SOURCE_DIR}/tests/mySuite TEST someSquishTest SETTINGSGROUP myGroup )
# endif ()
#
#
# For users of Squish version 3.x the macro squish_v3_add_test() is provided:
# squish_v3_add_test(testName applicationUnderTest testCase envVars testWrapper)
2012-11-04 22:41:34 +04:00
# Use this macro to add a test using Squish 3.x.
2008-12-09 01:39:30 +03:00
#
# ---- Typical Use
2012-08-13 21:47:32 +04:00
# enable_testing()
# find_package(Squish)
# if (SQUISH_FOUND)
2012-11-05 00:06:20 +04:00
# squish_v3_add_test(myTestName myApplication testCase envVars testWrapper)
2012-08-13 21:50:14 +04:00
# endif ()
2008-12-09 01:39:30 +03:00
#
2012-11-04 22:41:34 +04:00
# macro SQUISH_ADD_TEST(testName applicationUnderTest testCase envVars testWrapper)
# This is deprecated. Use SQUISH_V3_ADD_TEST() if you are using Squish 3.x instead.
2008-12-09 01:39:30 +03:00
2009-09-28 19:45:50 +04:00
#=============================================================================
# Copyright 2008-2009 Kitware, Inc.
2012-11-05 00:06:20 +04:00
# Copyright 2012 Alexander Neundorf
2009-09-28 19:45:50 +04:00
#
# 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.
#=============================================================================
2010-08-07 04:48:47 +04:00
# (To distribute this file outside of CMake, substitute the full
2009-09-28 19:45:50 +04:00
# License text for the above reference.)
2012-11-05 00:06:20 +04:00
include ( CMakeParseArguments )
2012-08-13 21:47:32 +04:00
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." )
2008-12-09 01:39:30 +03:00
# Search only if the location is not already known.
2012-08-13 21:47:32 +04:00
if ( NOT SQUISH_INSTALL_DIR )
2008-12-09 01:39:30 +03:00
# Get the system search path as a list.
2012-08-13 21:47:32 +04:00
file ( TO_CMAKE_PATH "$ENV{PATH}" SQUISH_INSTALL_DIR_SEARCH2 )
2008-12-09 01:39:30 +03:00
# Construct a set of paths relative to the system search path.
2012-08-13 21:47:32 +04:00
set ( SQUISH_INSTALL_DIR_SEARCH "" )
foreach ( dir ${ SQUISH_INSTALL_DIR_SEARCH2 } )
set ( SQUISH_INSTALL_DIR_SEARCH ${ SQUISH_INSTALL_DIR_SEARCH } "${dir}/../lib/fltk" )
2012-08-13 21:50:14 +04:00
endforeach ( )
2012-08-13 21:47:32 +04:00
string ( REPLACE "//" "/" SQUISH_INSTALL_DIR_SEARCH "${SQUISH_INSTALL_DIR_SEARCH}" )
2008-12-09 01:39:30 +03:00
# Look for an installation
2012-08-13 21:47:32 +04:00
find_path ( SQUISH_INSTALL_DIR bin/squishrunner
2012-03-29 02:00:54 +04:00
H I N T S
2008-12-09 01:39:30 +03:00
# Look for an environment variable SQUISH_INSTALL_DIR.
2012-03-29 02:00:54 +04:00
E N V S Q U I S H _ I N S T A L L _ D I R
2008-12-09 01:39:30 +03:00
# 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 } "
)
2012-08-13 21:50:14 +04:00
endif ( )
2008-12-09 01:39:30 +03:00
# search for the executables
2012-08-13 21:47:32 +04:00
if ( SQUISH_INSTALL_DIR )
set ( SQUISH_INSTALL_DIR_FOUND 1 )
2008-12-09 01:39:30 +03:00
# find the client program
2012-08-13 21:47:32 +04:00
if ( NOT SQUISH_CLIENT_EXECUTABLE )
2012-11-04 22:25:43 +04:00
find_program ( SQUISH_CLIENT_EXECUTABLE ${ SQUISH_INSTALL_DIR } /bin/squishrunner ${ CMAKE_EXECUTABLE_SUFFIX } DOC "The ${SQUISH_CLIENT_EXECUTABLE_STRING}" )
2012-08-13 21:50:14 +04:00
endif ( )
2008-12-09 01:39:30 +03:00
# find the server program
2012-08-13 21:47:32 +04:00
if ( NOT SQUISH_SERVER_EXECUTABLE )
2012-11-04 22:25:43 +04:00
find_program ( SQUISH_SERVER_EXECUTABLE ${ SQUISH_INSTALL_DIR } /bin/squishserver ${ CMAKE_EXECUTABLE_SUFFIX } DOC "The ${SQUISH_SERVER_EXECUTABLE_STRING}" )
2012-08-13 21:50:14 +04:00
endif ( )
2008-12-09 01:39:30 +03:00
2012-08-13 21:50:14 +04:00
else ( )
2012-08-13 21:47:32 +04:00
set ( SQUISH_INSTALL_DIR_FOUND 0 )
2012-08-13 21:50:14 +04:00
endif ( )
2008-12-09 01:39:30 +03:00
2012-11-04 22:11:43 +04:00
set ( SQUISH_VERSION )
set ( SQUISH_VERSION_MAJOR )
set ( SQUISH_VERSION_MINOR )
set ( SQUISH_VERSION_PATCH )
2008-12-09 01:39:30 +03:00
# record if executables are set
2012-08-13 21:47:32 +04:00
if ( SQUISH_CLIENT_EXECUTABLE )
set ( SQUISH_CLIENT_EXECUTABLE_FOUND 1 )
2012-11-04 22:11:43 +04:00
execute_process ( COMMAND "${SQUISH_CLIENT_EXECUTABLE}" --version
O U T P U T _ V A R I A B L E _ s q u i s h V e r s i o n O u t p u t
E R R O R _ Q U I E T )
if ( "${_squishVersionOutput}" MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+).*$" )
set ( SQUISH_VERSION_MAJOR "${CMAKE_MATCH_1}" )
set ( SQUISH_VERSION_MINOR "${CMAKE_MATCH_2}" )
set ( SQUISH_VERSION_PATCH "${CMAKE_MATCH_3}" )
set ( SQUISH_VERSION "${SQUISH_VERSION_MAJOR}.${SQUISH_VERSION_MINOR}.${SQUISH_VERSION_PATCH}" )
endif ( )
2012-08-13 21:50:14 +04:00
else ( )
2012-08-13 21:47:32 +04:00
set ( SQUISH_CLIENT_EXECUTABLE_FOUND 0 )
2012-08-13 21:50:14 +04:00
endif ( )
2012-08-13 21:47:32 +04:00
if ( SQUISH_SERVER_EXECUTABLE )
set ( SQUISH_SERVER_EXECUTABLE_FOUND 1 )
2012-08-13 21:50:14 +04:00
else ( )
2012-08-13 21:47:32 +04:00
set ( SQUISH_SERVER_EXECUTABLE_FOUND 0 )
2012-08-13 21:50:14 +04:00
endif ( )
2008-12-09 01:39:30 +03:00
# record if Squish was found
2012-11-04 22:22:27 +04:00
include ( FindPackageHandleStandardArgs )
find_package_handle_standard_args ( Squish REQUIRED_VARS SQUISH_INSTALL_DIR SQUISH_CLIENT_EXECUTABLE SQUISH_SERVER_EXECUTABLE
V E R S I O N _ V A R S Q U I S H _ V E R S I O N )
2012-08-13 21:47:32 +04:00
2012-11-04 22:45:25 +04:00
set ( _SQUISH_MODULE_DIR "${CMAKE_CURRENT_LIST_DIR}" )
2012-11-04 22:41:34 +04:00
macro ( SQUISH_V3_ADD_TEST testName testAUT testCase envVars testWraper )
2012-11-05 00:06:20 +04:00
if ( "${SQUISH_VERSION_MAJOR}" STREQUAL "4" )
message ( STATUS "Using squish_v3_add_test(), but SQUISH_VERSION_MAJOR is ${SQUISH_VERSION_MAJOR}.\nThis may not work." )
endif ( )
2012-08-13 21:47:32 +04:00
add_test ( ${ testName }
2008-12-09 01:39:30 +03:00
$ { C M A K E _ C O M M A N D } - V - V V
2012-11-05 00:06:20 +04:00
" - D s q u i s h _ v e r s i o n : S T R I N G = 3 "
2008-12-09 01:39:30 +03:00
" - 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 } "
2012-11-05 00:06:20 +04:00
" - D s q u i s h _ m o d u l e _ d i r : S T R I N G = $ { _ S Q U I S H _ M O D U L E _ D I R } "
2012-11-04 22:45:25 +04:00
- P " $ { _ S Q U I S H _ M O D U L E _ D I R } / S q u i s h T e s t S c r i p t . c m a k e "
2008-12-09 01:39:30 +03:00
)
2012-08-13 21:47:32 +04:00
set_tests_properties ( ${ testName }
2008-12-09 01:39:30 +03:00
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 "
)
2012-08-13 21:50:14 +04:00
endmacro ( )
2012-08-13 21:42:58 +04:00
2012-11-04 22:41:34 +04:00
macro ( SQUISH_ADD_TEST )
message ( STATUS "Using squish_add_test() is deprecated, use squish_v3_add_test() instead." )
squish_v3_add_test ( ${ ARGV } )
endmacro ( )
2012-11-05 00:06:20 +04:00
function ( SQUISH_V4_ADD_TEST testName )
if ( NOT "${SQUISH_VERSION_MAJOR}" STREQUAL "4" )
message ( STATUS "Using squish_v4_add_test(), but SQUISH_VERSION_MAJOR is ${SQUISH_VERSION_MAJOR}.\nThis may not work." )
endif ( )
set ( oneValueArgs AUT SUITE TEST SETTINGSGROUP PRE_COMMAND POST_COMMAND )
cmake_parse_arguments ( _SQUISH "" "${oneValueArgs}" "" ${ ARGN } )
if ( _SQUISH_UNPARSED_ARGUMENTS )
message ( FATAL_ERROR "Unknown keywords given to SQUISH_ADD_TEST(): \" ${ _SQUISH_UNPARSED_ARGUMENTS } \"")
endif ( )
if ( NOT _SQUISH_AUT )
message ( FATAL_ERROR "Required argument AUT not given for SQUISH_ADD_TEST()" )
endif ( )
if ( NOT _SQUISH_SUITE )
message ( FATAL_ERROR "Required argument SUITE not given for SQUISH_ADD_TEST()" )
endif ( )
if ( NOT _SQUISH_TEST )
message ( FATAL_ERROR "Required argument TEST not given for SQUISH_ADD_TEST()" )
endif ( )
get_target_property ( testAUTLocation ${ _SQUISH_AUT } LOCATION )
get_filename_component ( testAUTDir ${ testAUTLocation } PATH )
get_target_property ( testAUTName ${ _SQUISH_AUT } OUTPUT_NAME )
get_filename_component ( absTestSuite "${_SQUISH_SUITE}" ABSOLUTE )
if ( NOT EXISTS "${absTestSuite}" )
message ( FATAL_ERROR "Could not find squish test suite ${_SQUISH_SUITE} (checked ${absTestSuite})" )
endif ( )
set ( absTestCase "${absTestSuite}/${_SQUISH_TEST}" )
if ( NOT EXISTS "${absTestCase}" )
message ( FATAL_ERROR "Could not find squish testcase ${_SQUISH_TEST} (checked ${absTestCase})" )
endif ( )
if ( NOT _SQUISH_SETTINGSGROUP )
set ( _SQUISH_SETTINGSGROUP "CTest_$ENV{LOGNAME}" )
endif ( )
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 _ v e r s i o n : S T R I N G = 4 "
" - D s q u i s h _ a u t : S T R I N G = $ { t e s t A U T N a m e } "
" - D s q u i s h _ a u t _ d i r : S T R I N G = $ { t e s t A U T D i r } "
" - 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 _ s u i t e : S T R I N G = $ { a b s T e s t S u i t e } "
" - D s q u i s h _ t e s t _ c a s e : S T R I N G = $ { _ S Q U I S H _ T E S T } "
" - 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 } "
" - D s q u i s h _ m o d u l e _ d i r : S T R I N G = $ { _ S Q U I S H _ M O D U L E _ D I R } "
" - D s q u i s h _ s e t t i n g s g r o u p : S T R I N G = $ { _ S Q U I S H _ S E T T I N G S G R O U P } "
" - D s q u i s h _ p r e _ c o m m a n d : S T R I N G = $ { _ S Q U I S H _ P R E _ C O M M A N D } "
" - D s q u i s h _ p o s t _ c o m m a n d : S T R I N G = $ { _ S Q U I S H _ P O S T _ C O M M A N D } "
- P " $ { _ S Q U I S H _ M O D U L E _ D I R } / 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 ; F A I L E D ; E R R O R ; F A T A L "
)
endfunction ( )