# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
F i n d S q u i s h
- - - - - - - - - -
- - T y p i c a l U s e
T h i s m o d u l e c a n b e u s e d t o f i n d S q u i s h . C u r r e n t l y S q u i s h v e r s i o n s 3
a n d 4 a r e s u p p o r t e d .
: :
S Q U I S H _ F O U N D I f f a l s e , d o n ' t t r y t o u s e S q u i s h
S Q U I S H _ V E R S I O N T h e f u l l v e r s i o n o f S q u i s h f o u n d
S Q U I S H _ V E R S I O N _ M A J O R T h e m a j o r v e r s i o n o f S q u i s h f o u n d
S Q U I S H _ V E R S I O N _ M I N O R T h e m i n o r v e r s i o n o f S q u i s h f o u n d
S Q U I S H _ V E R S I O N _ P A T C H T h e p a t c h v e r s i o n o f S q u i s h f o u n d
: :
S Q U I S H _ I N S T A L L _ D I R T h e S q u i s h i n s t a l l a t i o n d i r e c t o r y
( c o n t a i n i n g b i n , l i b , e t c )
S Q U I S H _ S E R V E R _ E X E C U T A B L E T h e s q u i s h s e r v e r e x e c u t a b l e
S Q U I S H _ C L I E N T _ E X E C U T A B L E T h e s q u i s h r u n n e r e x e c u t a b l e
: :
S Q U I S H _ I N S T A L L _ D I R _ F O U N D W a s t h e i n s t a l l d i r e c t o r y f o u n d ?
S Q U I S H _ S E R V E R _ E X E C U T A B L E _ F O U N D W a s t h e s e r v e r e x e c u t a b l e f o u n d ?
S Q U I S H _ C L I E N T _ E X E C U T A B L E _ F O U N D W a s t h e c l i e n t e x e c u t a b l e f o u n d ?
I t p r o v i d e s t h e f u n c t i o n squish_v4_add_test ( ) f o r a d d i n g a s q u i s h t e s t
t o c m a k e u s i n g S q u i s h 4 . x :
: :
squish_v4_add_test ( cmakeTestName
A U T t a r g e t N a m e S U I T E s u i t e N a m e T E S T s q u i s h T e s t N a m e
[ S E T T I N G S G R O U P g r o u p ] [ P R E _ C O M M A N D c o m m a n d ] [ P O S T _ C O M M A N D c o m m a n d ] )
T h e a r g u m e n t s h a v e t h e f o l l o w i n g m e a n i n g :
` ` c m a k e T e s t N a m e ` `
t h i s w i l l b e u s e d a s t h e f i r s t a r g u m e n t f o r add_test ( )
` ` A U T t a r g e t N a m e ` `
t h e n a m e o f t h e c m a k e t a r g e t w h i c h w i l l b e u s e d a s A U T , i . e . t h e
e x e c u t a b l e w h i c h w i l l b e t e s t e d .
` ` S U I T E s u i t e N a m e ` `
t h i s i s e i t h e r t h e f u l l p a t h t o t h e s q u i s h s u i t e , o r j u s t t h e
l a s t d i r e c t o r y o f t h e s u i t e , i . e . t h e s u i t e n a m e . I n t h i s c a s e
t h e C M a k e L i s t s . t x t w h i c h c a l l s squish_add_test ( ) m u s t b e l o c a t e d
i n t h e p a r e n t d i r e c t o r y o f t h e s u i t e d i r e c t o r y .
` ` T E S T s q u i s h T e s t N a m e ` `
t h e n a m e o f t h e s q u i s h t e s t , i . e . t h e n a m e o f t h e s u b d i r e c t o r y
o f t h e t e s t i n s i d e t h e s u i t e d i r e c t o r y .
` ` S E T T I N G S G R O U P g r o u p ` `
i f s p e c i f i e d , t h e g i v e n s e t t i n g s g r o u p w i l l b e u s e d f o r e x e c u t i n g t h e t e s t .
I f n o t s p e c i f i e d , t h e g r o u p n a m e w i l l b e " C T e s t _ < u s e r n a m e > "
` ` P R E _ C O M M A N D c o m m a n d ` `
i f s p e c i f i e d , t h e g i v e n c o m m a n d w i l l b e e x e c u t e d b e f o r e s t a r t i n g t h e s q u i s h t e s t .
` ` P O S T _ C O M M A N D c o m m a n d ` `
s a m e a s P R E _ C O M M A N D , b u t a f t e r t h e s q u i s h t e s t h a s b e e n e x e c u t e d .
: :
enable_testing ( )
find_package ( Squish 4.0 )
if ( SQUISH_FOUND )
squish_v4_add_test ( myTestName
A U T m y A p p
S U I T E $ { C M A K E _ S O U R C E _ D I R } / t e s t s / m y S u i t e
T E S T s o m e S q u i s h T e s t
S E T T I N G S G R O U P m y G r o u p
)
endif ( )
F o r u s e r s o f S q u i s h v e r s i o n 3 . x t h e m a c r o squish_v3_add_test ( ) i s
p r o v i d e d :
: :
squish_v3_add_test ( testName applicationUnderTest testCase envVars testWrapper )
U s e t h i s m a c r o t o a d d a t e s t u s i n g S q u i s h 3 . x .
: :
enable_testing ( )
find_package ( Squish )
if ( SQUISH_FOUND )
squish_v3_add_test ( myTestName myApplication testCase envVars testWrapper )
endif ( )
m a c r o SQUISH_ADD_TEST ( testName applicationUnderTest testCase envVars
t e s t W r a p p e r )
: :
T h i s i s d e p r e c a t e d . U s e SQUISH_V3_ADD_TEST ( ) i f y o u a r e u s i n g S q u i s h 3 . x i n s t e a d .
#]=======================================================================]
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.
file ( TO_CMAKE_PATH "$ENV{PATH}" SQUISH_INSTALL_DIR_SEARCH2 )
# 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 ( )
string ( REPLACE "//" "/" SQUISH_INSTALL_DIR_SEARCH "${SQUISH_INSTALL_DIR_SEARCH}" )
# Look for an installation
find_path ( SQUISH_INSTALL_DIR bin/squishrunner
H I N T S
# 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 }
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 ( )
# 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 ${ CMAKE_EXECUTABLE_SUFFIX } DOC "The ${SQUISH_CLIENT_EXECUTABLE_STRING}" )
endif ( )
# find the server program
if ( NOT SQUISH_SERVER_EXECUTABLE )
find_program ( SQUISH_SERVER_EXECUTABLE ${ SQUISH_INSTALL_DIR } /bin/squishserver ${ CMAKE_EXECUTABLE_SUFFIX } DOC "The ${SQUISH_SERVER_EXECUTABLE_STRING}" )
endif ( )
else ( )
set ( SQUISH_INSTALL_DIR_FOUND 0 )
endif ( )
set ( SQUISH_VERSION )
set ( SQUISH_VERSION_MAJOR )
set ( SQUISH_VERSION_MINOR )
set ( SQUISH_VERSION_PATCH )
# record if executables are set
if ( SQUISH_CLIENT_EXECUTABLE )
set ( SQUISH_CLIENT_EXECUTABLE_FOUND 1 )
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 ( )
else ( )
set ( SQUISH_CLIENT_EXECUTABLE_FOUND 0 )
endif ( )
if ( SQUISH_SERVER_EXECUTABLE )
set ( SQUISH_SERVER_EXECUTABLE_FOUND 1 )
else ( )
set ( SQUISH_SERVER_EXECUTABLE_FOUND 0 )
endif ( )
# record if Squish was found
include ( ${ CMAKE_CURRENT_LIST_DIR } /FindPackageHandleStandardArgs.cmake )
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 )
set ( _SQUISH_MODULE_DIR "${CMAKE_CURRENT_LIST_DIR}" )
macro ( SQUISH_V3_ADD_TEST testName testAUT testCase envVars testWraper )
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 ( )
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 = 3 "
" - 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 } "
" - 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 } "
- 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 E D ; E R R O R ; F A T A L "
)
endmacro ( )
macro ( SQUISH_ADD_TEST )
message ( STATUS "Using squish_add_test() is deprecated, use squish_v3_add_test() instead." )
squish_v3_add_test ( ${ ARGV } )
endmacro ( )
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_filename_component ( testAUTName ${ testAUTLocation } 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 ( )