(self, tline: CMakeTraceLine)
Handler for the CMake set() function in all variaties.

        comes in three flavors:
        set(<var> <value> [PARENT_SCOPE])
        set(<var> <value> CACHE <type> <docstring> [FORCE])
        set(ENV{<var>} <value>)

        We don't support the ENV variant, and any uses of it will be ignored
        silently. the other two variates are supported, with some caveats:
        - we don't properly handle scoping, so calls to set() inside a
          function without PARENT_SCOPE set could incorrectly shadow the
          outer scope.
        - We don't honor the type of CACHE arguments
Handler for the CMake set() function in all variaties.
Handler for the CMake set () function in all variaties .
def _cmake_set(self, tline: CMakeTraceLine) -> None:
        """Handler for the CMake set() function in all variaties.

        comes in three flavors:
        set(<var> <value> [PARENT_SCOPE])
        set(<var> <value> CACHE <type> <docstring> [FORCE])
        set(ENV{<var>} <value>)

        We don't support the ENV variant, and any uses of it will be ignored
        silently. the other two variates are supported, with some caveats:
        - we don't properly handle scoping, so calls to set() inside a
          function without PARENT_SCOPE set could incorrectly shadow the
          outer scope.
        - We don't honor the type of CACHE arguments
        """
        # DOC: https://cmake.org/cmake/help/latest/command/set.html

        cache_type  = None
        cache_force = 'FORCE' in tline.args
        try:
            cache_idx  = tline.args.index('CACHE')
            cache_type = tline.args[cache_idx + 1]
        except (ValueError, IndexError):
            pass

        # 1st remove PARENT_SCOPE and CACHE from args
        args = []
        for i in tline.args:
            if not i or i == 'PARENT_SCOPE':
                continue

            # Discard everything after the CACHE keyword
            if i == 'CACHE':
                break

            args.append(i)

        if len(args) < 1:
            return self._gen_exception('set', 'requires at least one argument', tline)

        # Now that we've removed extra arguments all that should be left is the
        # variable identifier and the value, join the value back together to
        # ensure spaces in the value are correctly handled. This assumes that
        # variable names don't have spaces. Please don't do that...
        identifier = args.pop(0)
        value = ' '.join(args)

        # Write to the CMake cache instead
        if cache_type:
            # Honor how the CMake FORCE parameter works
            if identifier not in self.cache or cache_force:
                self.cache[identifier] = CMakeCacheEntry(value.split(';'), cache_type)

        if not value:
            # Same as unset
            if identifier in self.vars:
                del self.vars[identifier]
        else:
            self.vars[identifier] = value.split(';')
            self.vars_by_file.setdefault(tline.file, {})[identifier] = value.split(';')
def _cmake_set ( self , tline : CMakeTraceLine ) -> None : # DOC: https://cmake.org/cmake/help/latest/command/set.html cache_type = None cache_force = 'FORCE' in tline . args try : cache_idx = tline . args . index ( 'CACHE' ) cache_type = tline . args [ cache_idx + 1 ] except ( ValueError , IndexError ) : pass # 1st remove PARENT_SCOPE and CACHE from args args = [ ] for i in tline . args : if not i or i == 'PARENT_SCOPE' : continue # Discard everything after the CACHE keyword if i == 'CACHE' : break args . append ( i ) if len ( args ) < 1 : return self . _gen_exception ( 'set' , 'requires at least one argument' , tline ) # Now that we've removed extra arguments all that should be left is the # variable identifier and the value, join the value back together to # ensure spaces in the value are correctly handled. This assumes that # variable names don't have spaces. Please don't do that... identifier = args . pop ( 0 ) value = ' ' . join ( args ) # Write to the CMake cache instead if cache_type : # Honor how the CMake FORCE parameter works if identifier not in self . cache or cache_force : self . cache [ identifier ] = CMakeCacheEntry ( value . split ( ';' ) , cache_type ) if not value : # Same as unset if identifier in self . vars : del self . vars [ identifier ] else : self . vars [ identifier ] = value . split ( ';' ) self . vars_by_file . setdefault ( tline . file , { } ) [ identifier ] = value . split ( ';' )