1# Check the CMake source tree for suspicious policy introdcutions... 2# 3message("=============================================================================") 4message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") 5message("") 6message("CMake_BINARY_DIR='${CMake_BINARY_DIR}'") 7message("CMake_SOURCE_DIR='${CMake_SOURCE_DIR}'") 8message("GIT_EXECUTABLE='${GIT_EXECUTABLE}'") 9message("") 10 11 12# If this does not appear to be a git checkout, just pass the test here 13# and now. (Do not let the test fail if it is run in a tree *exported* from a 14# repository or unpacked from a .zip file source installer...) 15# 16set(is_git_checkout 0) 17if(EXISTS "${CMake_SOURCE_DIR}/.git") 18 set(is_git_checkout 1) 19endif() 20 21message("is_git_checkout='${is_git_checkout}'") 22message("") 23 24if(NOT is_git_checkout) 25 message("source tree is not a git checkout... test passes by early return...") 26 return() 27endif() 28 29# If no GIT_EXECUTABLE, see if we can figure out which git was used 30# for the ctest_update step on this dashboard... 31# 32if(is_git_checkout AND NOT GIT_EXECUTABLE) 33 set(ctest_ini_file "") 34 set(exe "") 35 36 # Use the old name: 37 if(EXISTS "${CMake_BINARY_DIR}/DartConfiguration.tcl") 38 set(ctest_ini_file "${CMake_BINARY_DIR}/DartConfiguration.tcl") 39 endif() 40 41 # But if it exists, prefer the new name: 42 if(EXISTS "${CMake_BINARY_DIR}/CTestConfiguration.ini") 43 set(ctest_ini_file "${CMake_BINARY_DIR}/CTestConfiguration.ini") 44 endif() 45 46 # If there is a ctest ini file, read the update command or git command 47 # from it: 48 # 49 if(ctest_ini_file) 50 file(STRINGS "${ctest_ini_file}" line REGEX "^GITCommand: (.*)$") 51 string(REGEX REPLACE "^GITCommand: (.*)$" "\\1" line "${line}") 52 if("${line}" MATCHES "^\"") 53 string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}") 54 else() 55 string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}") 56 endif() 57 set(exe "${line}") 58 if("${exe}" STREQUAL "GITCOMMAND-NOTFOUND") 59 set(exe "") 60 endif() 61 if(exe) 62 message("info: GIT_EXECUTABLE set by 'GITCommand:' from '${ctest_ini_file}'") 63 endif() 64 65 if(NOT exe) 66 file(STRINGS "${ctest_ini_file}" line REGEX "^UpdateCommand: (.*)$") 67 string(REGEX REPLACE "^UpdateCommand: (.*)$" "\\1" line "${line}") 68 if("${line}" MATCHES "^\"") 69 string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}") 70 else() 71 string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}") 72 endif() 73 set(exe "${line}") 74 if("${exe}" STREQUAL "GITCOMMAND-NOTFOUND") 75 set(exe "") 76 endif() 77 if(exe) 78 message("info: GIT_EXECUTABLE set by 'UpdateCommand:' from '${ctest_ini_file}'") 79 endif() 80 endif() 81 else() 82 message("info: no DartConfiguration.tcl or CTestConfiguration.ini file...") 83 endif() 84 85 # If we have still not grokked the exe, look in the Update.xml file to see 86 # if we can parse it from there... 87 # 88 if(NOT exe) 89 file(GLOB_RECURSE update_xml_file "${CMake_BINARY_DIR}/Testing/Update.xml") 90 if(update_xml_file) 91 file(STRINGS "${update_xml_file}" line 92 REGEX "^.*<UpdateCommand>(.*)</UpdateCommand>$" LIMIT_COUNT 1) 93 string(REPLACE ""\;" "\"" line "${line}") 94 string(REGEX REPLACE "^.*<UpdateCommand>(.*)</UpdateCommand>$" "\\1" line "${line}") 95 if("${line}" MATCHES "^\"") 96 string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}") 97 else() 98 string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}") 99 endif() 100 if(line) 101 set(exe "${line}") 102 endif() 103 if(exe) 104 message("info: GIT_EXECUTABLE set by '<UpdateCommand>' from '${update_xml_file}'") 105 endif() 106 else() 107 message("info: no Update.xml file...") 108 endif() 109 endif() 110 111 if(exe) 112 set(GIT_EXECUTABLE "${exe}") 113 message("GIT_EXECUTABLE='${GIT_EXECUTABLE}'") 114 message("") 115 116 if(NOT EXISTS "${GIT_EXECUTABLE}") 117 message(FATAL_ERROR "GIT_EXECUTABLE does not exist...") 118 endif() 119 else() 120 message(FATAL_ERROR "could not determine GIT_EXECUTABLE...") 121 endif() 122endif() 123 124 125if(is_git_checkout AND GIT_EXECUTABLE) 126 # Check with "git grep" if there are any unacceptable cmPolicies additions 127 # 128 message("=============================================================================") 129 message("This is a git checkout, using git grep to verify no unacceptable policies") 130 message("are being introduced....") 131 message("") 132 133 execute_process(COMMAND ${GIT_EXECUTABLE} grep -En "[0-9][0-9][0-9][0-9][0-9].*cmPolicies" 134 WORKING_DIRECTORY ${CMake_SOURCE_DIR} 135 OUTPUT_VARIABLE grep_output 136 OUTPUT_STRIP_TRAILING_WHITESPACE) 137 message("=== output of 'git grep -En \"[0-9][0-9][0-9][0-9][0-9].*cmPolicies\"' ===") 138 message("${grep_output}") 139 message("=== end output ===") 140 message("") 141 142 if(NOT "${grep_output}" STREQUAL "") 143 message(FATAL_ERROR "git grep output is non-empty... 144New CMake policies must be introduced in a non-date-based version number. 145Send email to the cmake-developers list to figure out what the target 146version number for this policy should be...") 147 endif() 148endif() 149 150 151# Still here? Good then... 152# 153message("test passes") 154message("") 155