Back to home page

EIC code displayed by LXR

 
 

    


Warning, /geant4/cmake/Templates/geant4_validate_sources.cmake.in is written in an unsupported language. File is not indexed.

0001 # - Validate sources listed in sources.cmake with those on disk
0002 # This file is configured by Geant4 to locate all sources.cmake files in
0003 # the source tree used by the current build tree.
0004 #
0005 # We have to parse the sources.cmake files for the headers and sources
0006 # because these files use the include_directories command, which is non
0007 # scriptable. A simple REGEX is used to find all the .cc, .hh and .icc
0008 # files listed in each sources.cmake file. These lists are compared with
0009 # a GLOB of those in the include and src directories of the module
0010 # corresponding to the sources.cmake file.
0011 #
0012 # Warnings are printed when a mismatch is detected.
0013 #
0014 # Note that certain modules have configurable source lists and so we
0015 # expect these to show a mismatch. We allow for this by providing the
0016 # variable:
0017 #
0018 #  GEANT4_FALSEPOSITIVE_SOURCES  List of all source files (.cc, .hh, .icc)
0019 #                                that may result in false positive mismatch.
0020 #
0021 # As this file is configured by Geant4's CMake system the generated
0022 # file "geant4_validate_sources.cmake" SHOULD NOT BE EDITED
0023 #
0024 
0025 #-----------------------------------------------------------------------
0026 # List all sources that we know cause false positives, e.g. obsolete,
0027 # but still on disk
0028 #
0029 set(GEANT4_FALSEPOSITIVE_SOURCES
0030   # G4{Global,Geom}Config.hh generated
0031   G4FindDataDir.hh
0032   G4GlobalConfig.hh
0033   G4GeomConfig.hh
0034   # - Xaw is deprecated...
0035   G4UIXaw.hh
0036   G4UIXaw.cc
0037   # - VRML has icc files in the src/ directory. These are only used
0038   #   internally but validate_sources assumes icc files will be in
0039   #   include/
0040   #   They are covered in sources.cmake though!
0041   G4VRML2SceneHandlerFunc.icc
0042   # - Documentation of processes/hadronic/models/cascade/cascade
0043   # lists some sources in comments. These do not correspond to
0044   # real sources so we can safely filter them
0045   # TODO : Improve regex to identify comments!!!!
0046   T1xxChannel.cc
0047   XXChannel.cc
0048   )
0049 
0050 #-----------------------------------------------------------------------
0051 # First locate our current source tree
0052 #
0053 set(GEANT4_SOURCE_TREE "@PROJECT_SOURCE_DIR@/source")
0054 message(STATUS "Scanning source tree ${GEANT4_SOURCE_TREE}")
0055 
0056 #-----------------------------------------------------------------------
0057 # Now find all of the sources.cmake files...
0058 #
0059 file(GLOB_RECURSE GEANT4_SOURCESCMAKE_FILES
0060   ${GEANT4_SOURCE_TREE}/*/sources.cmake
0061   )
0062 
0063 list(FILTER GEANT4_SOURCESCMAKE_FILES EXCLUDE REGEX "externals\\/zlib\\/sources.cmake")
0064 
0065 list(LENGTH GEANT4_SOURCESCMAKE_FILES GEANT4_SOURCESCMAKE_COUNT)
0066 message(STATUS "Located ${GEANT4_SOURCESCMAKE_COUNT} sources.cmake files")
0067 
0068 #-----------------------------------------------------------------------
0069 # Parse each modules and process...
0070 #
0071 foreach(_sourcesfile ${GEANT4_SOURCESCMAKE_FILES})
0072    # - Where are we?
0073   get_filename_component(_sourcesfile_location ${_sourcesfile} PATH)
0074 
0075   # - Find on disk files...
0076   file(GLOB
0077     _ondisk_public_hh
0078     RELATIVE ${_sourcesfile_location}/include
0079     ${_sourcesfile_location}/include/*.hh
0080     ${_sourcesfile_location}/include/*.icc
0081     )
0082   file(GLOB
0083     _ondisk_private_hh
0084     RELATIVE ${_sourcesfile_location}/include/private
0085     ${_sourcesfile_location}/include/private/*.hh
0086     ${_sourcesfile_location}/include/private/*.icc
0087     )
0088   set(_ondisk_hh ${_ondisk_public_hh} ${_ondisk_private_hh})
0089 
0090   file(GLOB
0091     _ondisk_cc
0092     RELATIVE ${_sourcesfile_location}/src
0093     ${_sourcesfile_location}/src/*.cc
0094     )
0095 
0096   # - Find files listed in sources.cmake
0097   # Ouch, we have to use a READ, because we can't load the module directly
0098   # due to it using the non scriptable command include_directories.
0099   file(READ ${_sourcesfile} _sourcesfile_contents)
0100   string(REGEX MATCHALL "[A-Z0-9a-z_]+\\.cc" _sources_cc "${_sourcesfile_contents}")
0101   string(REGEX MATCHALL "[A-Z0-9a-z_]+\\.(hh|icc)" _sources_hh "${_sourcesfile_contents}")
0102 
0103   # - If we take the difference of each list (in both directions),
0104   #   then there should be no mismatch if resulting lists are empty.
0105   # - On disk, but not in sources
0106   set(_cmp_ondisk ${_ondisk_hh} ${_ondisk_cc})
0107   set(_cmp_sources ${_sources_hh} ${_sources_cc})
0108   list(REMOVE_ITEM _cmp_ondisk ${_cmp_sources})
0109   set(_missing_in_sources ${_cmp_ondisk})
0110 
0111   # - In sources, but not on disk
0112   set(_cmp_ondisk ${_ondisk_hh} ${_ondisk_cc})
0113   set(_cmp_sources ${_sources_hh} ${_sources_cc})
0114   list(REMOVE_ITEM _cmp_sources ${_cmp_ondisk})
0115   set(_missing_on_disk ${_cmp_sources})
0116 
0117   # - Remove known false positives - can probably move this to above
0118   # difference calculation.
0119   if(_missing_in_sources)
0120     list(REMOVE_ITEM _missing_in_sources ${GEANT4_FALSEPOSITIVE_SOURCES})
0121   endif()
0122   if(_missing_on_disk)
0123     list(REMOVE_ITEM _missing_on_disk ${GEANT4_FALSEPOSITIVE_SOURCES})
0124   endif()
0125 
0126   # - Report if either list is not empty
0127   if(_missing_in_sources OR _missing_on_disk)
0128     message(" ")
0129     message("Problems detected in ${_sourcesfile_location}:")
0130     set(GEANT4_BUILD_ISINCONSISTENT TRUE)
0131 
0132     # - New/Obsolete File Error
0133     if(_missing_in_sources)
0134       message("Sources on disk but not listed in sources.cmake:")
0135       foreach(_m ${_missing_in_sources})
0136         message("  ${_m}")
0137       endforeach()
0138     endif()
0139 
0140     # - Removed File Error - In general, should be picked up at standard
0141     # CMake run time, but we double report here to be paranoid.
0142     if(_missing_on_disk)
0143       message("Sources listed in sources.cmake but not on disk:")
0144       foreach(_m ${_missing_on_disk})
0145         message("  ${_m}")
0146       endforeach()
0147     endif()
0148   endif()
0149 endforeach()
0150 
0151 #-----------------------------------------------------------------------
0152 # Final fail?
0153 #
0154 if(GEANT4_BUILD_ISINCONSISTENT)
0155   message(FATAL_ERROR "Inconsistent Geant4 build detected!")
0156 else()
0157   message(STATUS "Geant4 build appears consistent")
0158 endif()
0159