def __ExpandPathAndJoin(self, config: Config, package: Package, srcList: Optional[List[str]]) -> str:
     if srcList is None or len(srcList) <= 0:
         return ''
     if package.AbsolutePath is None:
         raise Exception("Invalid package")
     expandedList = [CMakeGeneratorUtil.GetSDKBasedPathUsingCMakeVariable(config, IOUtil.Join(package.AbsolutePath, entry)) for entry in srcList]
     return "\n  " + "\n  ".join(expandedList)
    def __GenerateCMakeFile(self, config: Config, package: Package,
                            platformName: str,
                            template: CMakeGeneratorUtil.CodeTemplateCMake,
                            androidProjectDir: str,
                            androidProjectCMakeDir: str) -> None:

        pathType = CMakeGeneratorUtil.CMakePathType.Relative

        packageName = CMakeGeneratorUtil.GetPackageName(package)

        # this ignore is a workaround allowing us to build using the same info as the old Android builder
        ignoreLibs = ["android_native_app_glue"]

        aliasPackageName = CMakeGeneratorUtil.GetAliasName(packageName)
        targetIncludeDirectories = CMakeGeneratorUtil.BuildTargetIncludeDirectories(
            config, package, template.PackageTargetIncludeDirectories,
            template.PackageTargetIncludeDirEntry, pathType)
        targetIncludeDirectories = targetIncludeDirectories.replace(
            Variable.RecipeVariant, "${ANDROID_ABI}")

        includeFiles = self.__ExpandPathAndJoin(
            config, package, package.ResolvedBuildAllIncludeFiles)
        sourceFiles = self.__ExpandPathAndJoin(
            config, package, package.ResolvedBuildSourceFiles)
        linkLibrariesDirectDependencies = CMakeGeneratorUtil.BuildTargetLinkLibrariesForDirectDependencies(
            config, package, template.PackageDependencyTargetLinkLibraries,
            ignoreLibs)
        directDefinitions = CMakeGeneratorUtil.BuildDirectDefinitions(
            config, package,
            template.PackageDependencyTargetCompileDefinitions)
        findDirectExternalDependencies = CMakeGeneratorUtil.BuildFindDirectExternalDependencies(
            config, package, template.PackageDependencyFindPackage)

        buildCMakeFile = template.Master

        if package.Type == PackageType.Executable:
            if package.AbsoluteContentPath is None:
                raise Exception("Invalid package")
            packageContentPath = CMakeGeneratorUtil.GetSDKBasedPathUsingCMakeVariable(
                config, package.AbsoluteContentPath)
            buildCMakeFile = buildCMakeFile.replace("##PACKAGE_CONTENT_PATH##",
                                                    packageContentPath)
            buildCMakeFile = buildCMakeFile.replace(
                "##PACKAGE_ANDROID_PROJECT_PATH##", androidProjectDir)
        buildCMakeFile = buildCMakeFile.replace("##PACKAGE_INCLUDE_FILES##",
                                                includeFiles)
        buildCMakeFile = buildCMakeFile.replace("##PACKAGE_SOURCE_FILES##",
                                                sourceFiles)
        buildCMakeFile = buildCMakeFile.replace(
            "##TARGET_INCLUDE_DIRECTORIES##", targetIncludeDirectories)
        buildCMakeFile = buildCMakeFile.replace(
            "##PACKAGE_DIRECT_DEPENDENCIES_TARGET_LINK_LIBRARIES##",
            linkLibrariesDirectDependencies)
        buildCMakeFile = buildCMakeFile.replace(
            "##PACKAGE_DIRECT_DEPENDENCIES_TARGET_COMPILE_DEFINITIONS##",
            directDefinitions)
        buildCMakeFile = buildCMakeFile.replace(
            "##PACKAGES_FIND_DIRECT_EXTERNAL_DEPENDENCIES##",
            findDirectExternalDependencies)
        buildCMakeFile = buildCMakeFile.replace(
            "##SNIPPET_DEFAULT_TARGET_COMPILE_OPTIONS##",
            template.SnippetDefaultTargetCompileOptions)
        buildCMakeFile = buildCMakeFile.replace(
            "##SNIPPET_DEFAULT_TARGET_COMPILE_FEATURES##",
            template.SnippetDefaultTargetCompileFeatures)
        buildCMakeFile = buildCMakeFile.replace("##PACKAGE_NAME!##",
                                                packageName.upper())
        buildCMakeFile = buildCMakeFile.replace("##PACKAGE_NAME##",
                                                packageName)
        buildCMakeFile = buildCMakeFile.replace("##ALIAS_PACKAGE_NAME##",
                                                aliasPackageName)

        if not config.DisableWrite:
            # We store all cmake build files in their own dir inside the 'android' exe-project's folder
            # to prevent collision with other more generic CMake builders
            packageCMakeDir = self.__GetPackageCMakeDir(
                androidProjectCMakeDir, package)
            IOUtil.SafeMakeDirs(packageCMakeDir)
            dstFileCMakeFile = self.__GetPackageCMakeFileName(
                androidProjectCMakeDir, package)
            IOUtil.WriteFileIfChanged(dstFileCMakeFile, buildCMakeFile)