Geant4 Cross Reference |
1 # Copied from Geant4 installation, need patch 1 # Copied from Geant4 installation, need patch 2 # - Find StatTest 2 # - Find StatTest 3 # This module tries to find the StatTest appli 3 # This module tries to find the StatTest application 4 # Once done this will define 4 # Once done this will define 5 # << 5 # 6 # STATTEST_FOUND - Application found 6 # STATTEST_FOUND - Application found 7 # STATTEST_APP - Application 7 # STATTEST_APP - Application 8 # STATTEST_CMD - Command line to run th 8 # STATTEST_CMD - Command line to run the application 9 # STATTEST_ADD_TEST - Helper function to def 9 # STATTEST_ADD_TEST - Helper function to define a ctest using 10 # StatTest (Only if we are 10 # StatTest (Only if we are using for G4 testing) 11 # 11 # 12 # Variables used by this module, which can cha << 12 # Variables used by this module, which can change the default behaviour 13 # and need to be set before calling find_packa 13 # and need to be set before calling find_package 14 # 14 # 15 # STATTEST_ROOT_DIR Root directory to StatTest 15 # STATTEST_ROOT_DIR Root directory to StatTest package 16 # 16 # 17 17 18 if(NOT GEANT4_ENABLE_TESTING) 18 if(NOT GEANT4_ENABLE_TESTING) 19 #No meaning for this if not testing 19 #No meaning for this if not testing 20 SET(STATTEST_FOUND FALSE) 20 SET(STATTEST_FOUND FALSE) 21 return() 21 return() 22 endif() 22 endif() 23 23 24 #Search application 24 #Search application 25 #Note that the second suggested path is G4 spe << 25 #Note that the second suggested path is G4 specific... 26 find_path(STATTEST_APP_DIR 26 find_path(STATTEST_APP_DIR 27 NAMES StatTestVersion.py 27 NAMES StatTestVersion.py 28 PATHS ${STATTEST_ROOT_DIR} ${PROJECT_SOURC << 28 PATHS ${STATTEST_ROOT_DIR} ${CMAKE_SOURCE_DIR}/verification/StatTest 29 NO_DEFAULT_PATH 29 NO_DEFAULT_PATH 30 ) 30 ) 31 31 32 #If we didn't find it there, fall back to some 32 #If we didn't find it there, fall back to some standard search paths 33 find_path(STATTEST_APP_DIR NAMES StatTestVersi 33 find_path(STATTEST_APP_DIR NAMES StatTestVersion.py) 34 34 35 #### 35 #### 36 #### Run-time dependencies... 36 #### Run-time dependencies... 37 #### 37 #### 38 # - Check if ROOT is available 38 # - Check if ROOT is available 39 find_package(ROOT QUIET) 39 find_package(ROOT QUIET) 40 if(NOT ROOT_FOUND) 40 if(NOT ROOT_FOUND) 41 MESSAGE(STATUS "StatTest: ROOT package not f 41 MESSAGE(STATUS "StatTest: ROOT package not found --> StatTest package disabled") 42 set(STATTEST_FOUND FALSE) 42 set(STATTEST_FOUND FALSE) 43 set(_root_isok FALSE) 43 set(_root_isok FALSE) 44 else() 44 else() 45 set(_root_isok TRUE) 45 set(_root_isok TRUE) 46 # - Check if python interpreter is correct v << 46 # - Check if python interpreter is correct version 47 # (the one compatible with root) 47 # (the one compatible with root) 48 find_package(Python ${ROOT_PYTHONVER} QUIET << 48 find_package(PythonInterp ${ROOT_PYTHONVER} QUIET) 49 if(NOT Python_Interpreter_FOUND) << 49 if(NOT PYTHONINTERP_FOUND) 50 MESSAGE(STATUS "StatTest: Python interpre 50 MESSAGE(STATUS "StatTest: Python interpreter of version ${ROOT_PYTHONVER} not found --> StatTest package disabled") 51 set(STATTEST_FOUND FALSE) 51 set(STATTEST_FOUND FALSE) 52 set(_python_isok FALSE) 52 set(_python_isok FALSE) 53 else() 53 else() 54 set(STATTEST_FOUND TRUE) 54 set(STATTEST_FOUND TRUE) 55 set(_python_isok TRUE) 55 set(_python_isok TRUE) 56 endif() 56 endif() 57 endif() 57 endif() 58 58 59 include(FindPackageHandleStandardArgs) 59 include(FindPackageHandleStandardArgs) 60 find_package_handle_standard_args( 60 find_package_handle_standard_args( 61 StatTest 61 StatTest 62 DEFAULT_MSG 62 DEFAULT_MSG 63 STATTEST_APP_DIR 63 STATTEST_APP_DIR 64 _root_isok 64 _root_isok 65 _python_isok 65 _python_isok 66 ) 66 ) 67 67 68 68 69 if(STATTEST_FOUND) 69 if(STATTEST_FOUND) 70 set(STATTEST_APP ${STATTEST_APP_DIR}/runtest 70 set(STATTEST_APP ${STATTEST_APP_DIR}/runtests.py) 71 set(STATTEST_CMD ${PYTHON_EXECUTABLE} ${STAT 71 set(STATTEST_CMD ${PYTHON_EXECUTABLE} ${STATTEST_APP}) 72 72 73 # Let's create a function that helps in buil << 73 # Let's create a function that helps in building tests for 74 # regression testing 74 # regression testing 75 # function STATTEST_ADD_TEST(<name> << 75 # function STATTEST_ADD_TEST(<name> 76 # G4TEST testname 76 # G4TEST testname 77 # CONFIG conffile 77 # CONFIG conffile 78 # INPUT inputfile 78 # INPUT inputfile 79 # [DEBUG] 79 # [DEBUG] 80 # [TEXT] #Input is text file inste 80 # [TEXT] #Input is text file instead of root 81 # [REFERENCE refe 81 # [REFERENCE reference] 82 # [LABELS label1 82 # [LABELS label1 label2 ...] 83 # [IMG filename]) 83 # [IMG filename]) 84 function(STATTEST_ADD_TEST stattest) 84 function(STATTEST_ADD_TEST stattest) 85 CMAKE_PARSE_ARGUMENTS(ARG "DEBUG;TEXT" << 85 CMAKE_PARSE_ARGUMENTS(ARG "DEBUG;TEXT" 86 "CONFIG;INPUT;REFERENCE;G4TEST;IMG" 86 "CONFIG;INPUT;REFERENCE;G4TEST;IMG" 87 "LABELS" ${ARGN} 87 "LABELS" ${ARGN} 88 ) 88 ) 89 #check mandatory arguments 89 #check mandatory arguments 90 list(LENGTH ARG_CONFIG _len) 90 list(LENGTH ARG_CONFIG _len) 91 if(_len LESS 1) 91 if(_len LESS 1) 92 message(FATAL_ERROR "STATTEST_ADD_TEST 92 message(FATAL_ERROR "STATTEST_ADD_TEST: conffile is mandatory") 93 endif() 93 endif() 94 << 94 95 list(LENGTH ARG_INPUT _len) 95 list(LENGTH ARG_INPUT _len) 96 if(_len LESS 1) 96 if(_len LESS 1) 97 message(FATAL_ERROR "STATTEST_ADD_TEST 97 message(FATAL_ERROR "STATTEST_ADD_TEST: inputfile is mandatory") 98 endif() 98 endif() 99 << 99 100 list(LENGTH ARG_G4TEST _len) 100 list(LENGTH ARG_G4TEST _len) 101 if(_len LESS 1) 101 if(_len LESS 1) 102 message(FATAL_ERROR "STATTEST_ADD_TEST 102 message(FATAL_ERROR "STATTEST_ADD_TEST: testname is mandatory") 103 endif() 103 endif() 104 104 105 #Set basic command line 105 #Set basic command line 106 if(ARG_IMG) 106 if(ARG_IMG) 107 set(_command ${STATTEST_CMD} -g ${ARG_ 107 set(_command ${STATTEST_CMD} -g ${ARG_IMG}) 108 else() 108 else() 109 set(_command ${STATTEST_CMD}) 109 set(_command ${STATTEST_CMD}) 110 endif() 110 endif() 111 << 111 112 if(ARG_TEXT) 112 if(ARG_TEXT) 113 set(_command ${_command} "-T") 113 set(_command ${_command} "-T") 114 endif() << 114 endif() 115 115 116 #Mandatory parameters 116 #Mandatory parameters 117 set(_command ${_command} ${ARG_CONFIG} ${A 117 set(_command ${_command} ${ARG_CONFIG} ${ARG_INPUT}) 118 if(ARG_REFERENCE) 118 if(ARG_REFERENCE) 119 set(_command ${_command} ${ARG_REFEREN 119 set(_command ${_command} ${ARG_REFERENCE}) 120 endif() 120 endif() 121 121 122 if(ARG_LABELS) 122 if(ARG_LABELS) 123 set(_labels ${ARG_LABELS}) 123 set(_labels ${ARG_LABELS}) 124 else() 124 else() 125 set(_labels "") 125 set(_labels "") 126 endif() 126 endif() 127 127 128 include(G4CTest) << 128 include(Geant4CTest) 129 << 129 130 #Now build G4 test 130 #Now build G4 test 131 GEANT4_ADD_TEST(${stattest} << 131 GEANT4_ADD_TEST(${stattest} 132 COMMAND ${_command} 132 COMMAND ${_command} 133 DEPENDS ${ARG_G4TEST} 133 DEPENDS ${ARG_G4TEST} 134 LABELS ${_labels} 134 LABELS ${_labels} 135 ) 135 ) 136 endfunction() 136 endfunction() 137 endif(STATTEST_FOUND) 137 endif(STATTEST_FOUND) 138 138 139 mark_as_advanced(STATTEST_APP_DIR) 139 mark_as_advanced(STATTEST_APP_DIR)