Geant4 Cross Reference |
1 #.rst: 2 # G4GitUtilities 3 # -------------- 4 # 5 # .. code-block::cmake 6 # 7 # include(G4GitUtilities) 8 # 9 # CMake functions and macros for working with 10 # Geant4's build/packaging systems. 11 # 12 13 #--------------------------------------------- 14 # License and Disclaimer 15 # 16 # The Geant4 software is copyright of the C 17 # the Geant4 Collaboration. It is provided u 18 # conditions of the Geant4 Software License, 19 # LICENSE and available at http://cern.ch/gea 20 # include a list of copyright holders. 21 # 22 # Neither the authors of this software system, 23 # institutes,nor the agencies providing financ 24 # work make any representation or warranty, 25 # regarding this software system or assume a 26 # use. Please see the license in the file LI 27 # for the full disclaimer and the limitation o 28 # 29 # This code implementation is the result of 30 # technical work of the GEANT4 collaboration. 31 # By using, copying, modifying or distribut 32 # any work based on the software) you agree 33 # use in resulting scientific publications 34 # acceptance of all terms of the Geant4 Softwa 35 # 36 #--------------------------------------------- 37 38 include_guard(GLOBAL) 39 40 #--------------------------------------------- 41 #.rst: 42 # .. cmake:command:: geant4_git_find_dirty 43 # 44 # .. code-block:: cmake 45 # 46 # geant4_git_find_dirty(<basedir> <modifie 47 # 48 # Runs ``git status`` in the ``<basedir>``, 49 # and untracked/ignored files to ``<modified 50 # respectively. 51 # 52 # ``<basedir>`` must be the root of the repo 53 # the ``.git/`` directory. 54 # 55 # Nothing is returned in the output variable 56 # git repository or if a ``git`` executable 57 # 58 function(geant4_git_find_dirty _basedir _outpu 59 if(NOT EXISTS "${_basedir}/.git") 60 return() 61 endif() 62 63 find_package(Git QUIET) 64 if(NOT Git_FOUND) 65 return() 66 endif() 67 68 execute_process(COMMAND ${GIT_EXECUTABLE} st 69 WORKING_DIRECTORY "${_basedir}" 70 OUTPUT_VARIABLE GEANT4_GIT_UNTRACKED 71 ERROR_VARIABLE GEANT4_GIT_UNTRACKED_ERROR) 72 73 if(GEANT4_GIT_UNTRACKED_ERROR) 74 message(FATAL_ERROR "geant4_git_find_dirty 75 endif() 76 77 if(GEANT4_GIT_UNTRACKED) 78 set(_modded_files) 79 set(_untracked_files) 80 81 string(REPLACE "\n" ";" GEANT4_GIT_UNTRACK 82 foreach(item ${GEANT4_GIT_UNTRACKED}) 83 if(item MATCHES "^ *(M|A|R|D|C)") 84 string(REGEX REPLACE "^ *[MARDC][MARDC 85 list(APPEND _modded_files ${_modded_pa 86 endif() 87 88 if(item MATCHES "^ *(\\!|\\?)") 89 string(REGEX REPLACE "^ *(\\!\\!|\\?\\ 90 list(APPEND _untracked_files "${_untra 91 endif() 92 endforeach() 93 94 set(${_output_modified} ${_modded_files} P 95 set(${_output_untracked} ${_untracked_file 96 endif() 97 endfunction()