Back to home page

EIC code displayed by LXR

 
 

    


Warning, /geant4/cmake/Modules/FindStatTest.cmake is written in an unsupported language. File is not indexed.

0001 # Copied from Geant4 installation, need patch
0002 # - Find StatTest
0003 # This module tries to find the StatTest application
0004 # Once done this will define
0005 #
0006 #       STATTEST_FOUND    - Application found
0007 #       STATTEST_APP      - Application
0008 #   STATTEST_CMD      - Command line to run the application
0009 #   STATTEST_ADD_TEST - Helper function to define a ctest using
0010 #                                 StatTest (Only if we are using for G4 testing)
0011 #
0012 # Variables used by this module, which can change the default behaviour
0013 # and need to be set before calling find_package
0014 #
0015 #       STATTEST_ROOT_DIR       Root directory to StatTest package
0016 #
0017 
0018 if(NOT GEANT4_ENABLE_TESTING)
0019     #No meaning for this if not testing
0020     SET(STATTEST_FOUND FALSE)
0021     return()
0022 endif()
0023 
0024 #Search application
0025 #Note that the second suggested path is G4 specific...
0026 find_path(STATTEST_APP_DIR
0027                 NAMES StatTestVersion.py
0028                 PATHS ${STATTEST_ROOT_DIR} ${PROJECT_SOURCE_DIR}/verification/StatTest
0029                 NO_DEFAULT_PATH
0030     )
0031 
0032 #If we didn't find it there, fall back to some standard search paths
0033 find_path(STATTEST_APP_DIR NAMES StatTestVersion.py)
0034 
0035 ####
0036 #### Run-time dependencies...
0037 ####
0038 # - Check if ROOT is available
0039 find_package(ROOT QUIET)
0040 if(NOT ROOT_FOUND)
0041   MESSAGE(STATUS "StatTest: ROOT package not found --> StatTest package disabled")
0042   set(STATTEST_FOUND FALSE)
0043   set(_root_isok FALSE)
0044 else()
0045   set(_root_isok TRUE)
0046   # - Check if python interpreter is correct version
0047   # (the one compatible with root)
0048   find_package(Python ${ROOT_PYTHONVER} QUIET COMPONENTS Interpreter)
0049   if(NOT Python_Interpreter_FOUND)
0050      MESSAGE(STATUS "StatTest: Python interpreter of version ${ROOT_PYTHONVER} not found --> StatTest package disabled")
0051      set(STATTEST_FOUND FALSE)
0052      set(_python_isok FALSE)
0053   else()
0054      set(STATTEST_FOUND TRUE)
0055      set(_python_isok TRUE)
0056   endif()
0057 endif()
0058 
0059 include(FindPackageHandleStandardArgs)
0060 find_package_handle_standard_args(
0061     StatTest
0062     DEFAULT_MSG
0063     STATTEST_APP_DIR
0064     _root_isok
0065     _python_isok
0066   )
0067 
0068 
0069 if(STATTEST_FOUND)
0070   set(STATTEST_APP ${STATTEST_APP_DIR}/runtests.py)
0071   set(STATTEST_CMD ${PYTHON_EXECUTABLE} ${STATTEST_APP})
0072 
0073   # Let's create a function that helps in building tests for
0074   # regression testing
0075   # function STATTEST_ADD_TEST(<name>
0076   #                                          G4TEST testname
0077   #                            CONFIG conffile
0078   #                            INPUT inputfile
0079   #                              [DEBUG]
0080   #                              [TEXT]  #Input is text file instead of root
0081   #                            [REFERENCE reference]
0082   #                            [LABELS label1 label2 ...]
0083   #                            [IMG filename])
0084   function(STATTEST_ADD_TEST stattest)
0085         CMAKE_PARSE_ARGUMENTS(ARG "DEBUG;TEXT"
0086         "CONFIG;INPUT;REFERENCE;G4TEST;IMG"
0087         "LABELS" ${ARGN}
0088     )
0089     #check mandatory arguments
0090     list(LENGTH ARG_CONFIG _len)
0091     if(_len LESS 1)
0092         message(FATAL_ERROR "STATTEST_ADD_TEST: conffile is mandatory")
0093     endif()
0094 
0095     list(LENGTH ARG_INPUT _len)
0096     if(_len LESS 1)
0097         message(FATAL_ERROR "STATTEST_ADD_TEST: inputfile is mandatory")
0098     endif()
0099 
0100     list(LENGTH ARG_G4TEST _len)
0101     if(_len LESS 1)
0102         message(FATAL_ERROR "STATTEST_ADD_TEST: testname is mandatory")
0103     endif()
0104 
0105     #Set basic command line
0106     if(ARG_IMG)
0107         set(_command ${STATTEST_CMD} -g ${ARG_IMG})
0108     else()
0109         set(_command ${STATTEST_CMD})
0110     endif()
0111 
0112     if(ARG_TEXT)
0113             set(_command ${_command} "-T")
0114     endif()
0115 
0116     #Mandatory parameters
0117     set(_command ${_command} ${ARG_CONFIG} ${ARG_INPUT})
0118     if(ARG_REFERENCE)
0119         set(_command ${_command} ${ARG_REFERENCE})
0120     endif()
0121 
0122     if(ARG_LABELS)
0123         set(_labels ${ARG_LABELS})
0124     else()
0125         set(_labels "")
0126     endif()
0127 
0128     include(G4CTest)
0129 
0130      #Now build G4 test
0131     GEANT4_ADD_TEST(${stattest}
0132         COMMAND ${_command}
0133         DEPENDS ${ARG_G4TEST}
0134         LABELS ${_labels}
0135         )
0136   endfunction()
0137 endif(STATTEST_FOUND)
0138 
0139 mark_as_advanced(STATTEST_APP_DIR)