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 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 # - Validate sources listed in sources.cmake with those on disk
  2 # This file is configured by Geant4 to locate all sources.cmake files in
  3 # the source tree used by the current build tree.
  4 #
  5 # We have to parse the sources.cmake files for the headers and sources
  6 # because these files use the include_directories command, which is non
  7 # scriptable. A simple REGEX is used to find all the .cc, .hh and .icc
  8 # files listed in each sources.cmake file. These lists are compared with
  9 # a GLOB of those in the include and src directories of the module
 10 # corresponding to the sources.cmake file.
 11 #
 12 # Warnings are printed when a mismatch is detected.
 13 #
 14 # Note that certain modules have configurable source lists and so we
 15 # expect these to show a mismatch. We allow for this by providing the
 16 # variable:
 17 #
 18 #  GEANT4_FALSEPOSITIVE_SOURCES  List of all source files (.cc, .hh, .icc)
 19 #                                that may result in false positive mismatch.
 20 #
 21 # As this file is configured by Geant4's CMake system the generated
 22 # file "geant4_validate_sources.cmake" SHOULD NOT BE EDITED
 23 #
 24 
 25 #-----------------------------------------------------------------------
 26 # List all sources that we know cause false positives, e.g. obsolete,
 27 # but still on disk
 28 #
 29 set(GEANT4_FALSEPOSITIVE_SOURCES
 30   # G4{Global,Geom}Config.hh generated
 31   G4FindDataDir.hh
 32   G4GlobalConfig.hh
 33   G4GeomConfig.hh
 34   # - Xaw is deprecated...
 35   G4UIXaw.hh
 36   G4UIXaw.cc
 37   # - VRML has icc files in the src/ directory. These are only used
 38   #   internally but validate_sources assumes icc files will be in
 39   #   include/
 40   #   They are covered in sources.cmake though!
 41   G4VRML2SceneHandlerFunc.icc
 42   # - Documentation of processes/hadronic/models/cascade/cascade
 43   # lists some sources in comments. These do not correspond to
 44   # real sources so we can safely filter them
 45   # TODO : Improve regex to identify comments!!!!
 46   T1xxChannel.cc
 47   XXChannel.cc
 48   )
 49 
 50 #-----------------------------------------------------------------------
 51 # First locate our current source tree
 52 #
 53 set(GEANT4_SOURCE_TREE "@PROJECT_SOURCE_DIR@/source")
 54 message(STATUS "Scanning source tree ${GEANT4_SOURCE_TREE}")
 55 
 56 #-----------------------------------------------------------------------
 57 # Now find all of the sources.cmake files...
 58 #
 59 file(GLOB_RECURSE GEANT4_SOURCESCMAKE_FILES
 60   ${GEANT4_SOURCE_TREE}/*/sources.cmake
 61   )
 62 
 63 list(FILTER GEANT4_SOURCESCMAKE_FILES EXCLUDE REGEX "externals\\/zlib\\/sources.cmake")
 64 
 65 list(LENGTH GEANT4_SOURCESCMAKE_FILES GEANT4_SOURCESCMAKE_COUNT)
 66 message(STATUS "Located ${GEANT4_SOURCESCMAKE_COUNT} sources.cmake files")
 67 
 68 #-----------------------------------------------------------------------
 69 # Parse each modules and process...
 70 #
 71 foreach(_sourcesfile ${GEANT4_SOURCESCMAKE_FILES})
 72    # - Where are we?
 73   get_filename_component(_sourcesfile_location ${_sourcesfile} PATH)
 74 
 75   # - Find on disk files...
 76   file(GLOB
 77     _ondisk_public_hh
 78     RELATIVE ${_sourcesfile_location}/include
 79     ${_sourcesfile_location}/include/*.hh
 80     ${_sourcesfile_location}/include/*.icc
 81     )
 82   file(GLOB
 83     _ondisk_private_hh
 84     RELATIVE ${_sourcesfile_location}/include/private
 85     ${_sourcesfile_location}/include/private/*.hh
 86     ${_sourcesfile_location}/include/private/*.icc
 87     )
 88   set(_ondisk_hh ${_ondisk_public_hh} ${_ondisk_private_hh})
 89 
 90   file(GLOB
 91     _ondisk_cc
 92     RELATIVE ${_sourcesfile_location}/src
 93     ${_sourcesfile_location}/src/*.cc
 94     )
 95 
 96   # - Find files listed in sources.cmake
 97   # Ouch, we have to use a READ, because we can't load the module directly
 98   # due to it using the non scriptable command include_directories.
 99   file(READ ${_sourcesfile} _sourcesfile_contents)
100   string(REGEX MATCHALL "[A-Z0-9a-z_]+\\.cc" _sources_cc "${_sourcesfile_contents}")
101   string(REGEX MATCHALL "[A-Z0-9a-z_]+\\.(hh|icc)" _sources_hh "${_sourcesfile_contents}")
102 
103   # - If we take the difference of each list (in both directions),
104   #   then there should be no mismatch if resulting lists are empty.
105   # - On disk, but not in sources
106   set(_cmp_ondisk ${_ondisk_hh} ${_ondisk_cc})
107   set(_cmp_sources ${_sources_hh} ${_sources_cc})
108   list(REMOVE_ITEM _cmp_ondisk ${_cmp_sources})
109   set(_missing_in_sources ${_cmp_ondisk})
110 
111   # - In sources, but not on disk
112   set(_cmp_ondisk ${_ondisk_hh} ${_ondisk_cc})
113   set(_cmp_sources ${_sources_hh} ${_sources_cc})
114   list(REMOVE_ITEM _cmp_sources ${_cmp_ondisk})
115   set(_missing_on_disk ${_cmp_sources})
116 
117   # - Remove known false positives - can probably move this to above
118   # difference calculation.
119   if(_missing_in_sources)
120     list(REMOVE_ITEM _missing_in_sources ${GEANT4_FALSEPOSITIVE_SOURCES})
121   endif()
122   if(_missing_on_disk)
123     list(REMOVE_ITEM _missing_on_disk ${GEANT4_FALSEPOSITIVE_SOURCES})
124   endif()
125 
126   # - Report if either list is not empty
127   if(_missing_in_sources OR _missing_on_disk)
128     message(" ")
129     message("Problems detected in ${_sourcesfile_location}:")
130     set(GEANT4_BUILD_ISINCONSISTENT TRUE)
131 
132     # - New/Obsolete File Error
133     if(_missing_in_sources)
134       message("Sources on disk but not listed in sources.cmake:")
135       foreach(_m ${_missing_in_sources})
136         message("  ${_m}")
137       endforeach()
138     endif()
139 
140     # - Removed File Error - In general, should be picked up at standard
141     # CMake run time, but we double report here to be paranoid.
142     if(_missing_on_disk)
143       message("Sources listed in sources.cmake but not on disk:")
144       foreach(_m ${_missing_on_disk})
145         message("  ${_m}")
146       endforeach()
147     endif()
148   endif()
149 endforeach()
150 
151 #-----------------------------------------------------------------------
152 # Final fail?
153 #
154 if(GEANT4_BUILD_ISINCONSISTENT)
155   message(FATAL_ERROR "Inconsistent Geant4 build detected!")
156 else()
157   message(STATUS "Geant4 build appears consistent")
158 endif()
159