def __GetCMakeConfiguration( self, configList: List[XmlCMakeConfiguration]) -> CMakeConfiguration: if len(configList) != 1: if len(configList) <= 0: return CMakeConfiguration("${TopProjectRoot}/build", None, CMakeUtil.GetMinimumVersion(), []) raise Exception("There can only be one CMakeConfiguration") configEntry = configList[0] defaultBuildDir = configEntry.DefaultBuildDir defaultInstallPrefix = configEntry.DefaultInstallPrefix minVersion = self.__ParseCMakeVersionString(configEntry.MinVersion) platformList = [] # type: List[CMakeConfigurationPlatform] for platformEntry in configEntry.Platforms: # Default to the platform one if its defined, else default to the general one (which can be None) platformEntryDefaultInstallPrefix = platformEntry.DefaultInstallPrefix if platformEntry.DefaultInstallPrefix is not None else defaultInstallPrefix # Generate the platform config object platformList.append( CMakeConfigurationPlatform(platformEntry.Name, platformEntry.DefaultGeneratorName, platformEntryDefaultInstallPrefix)) if defaultBuildDir is None: raise Exception( "CMakleConfiguration.DefaultBuildDir must be defined") return CMakeConfiguration(defaultBuildDir, defaultInstallPrefix, minVersion, platformList)
def BuildGeneratorCMakeConfig(log: Log, toolVersion: Version, platformName: str, buildVariantConfig: BuildVariantConfig, userCMakeConfig: Optional[UserCMakeConfig], cmakeConfiguration: CMakeConfiguration, defaultCompilerVersion: int, isCheckMode: bool) -> GeneratorCMakeConfig: """ Build the CMake config based on the supplied parameters and the default settings from the toolconfig """ # Setup default configuration buildDir = IOUtil.Join(cmakeConfiguration.DefaultBuildDir, platformName) generatorName = "" installPrefix = cmakeConfiguration.DefaultInstallPrefix # Give the platform a chance to override the config platformConfig = cmakeConfiguration.TryGetPlatformConfig(platformName) allowFindPackage = True if platformConfig is not None: if platformConfig.DefaultGeneratorName is not None: generatorName = platformConfig.DefaultGeneratorName if platformConfig.DefaultInstallPrefix is not None: installPrefix = platformConfig.DefaultInstallPrefix if platformConfig.AllowFindPackage is not None: allowFindPackage = platformConfig.AllowFindPackage log.LogPrintVerbose(2, "project defined AllowFindPackage to {0}".format(allowFindPackage)) # Apply the commandline overrides (so the user gets the final say) buildDirSetByUser = False if userCMakeConfig is not None: if userCMakeConfig.BuildDir is not None: buildDir = userCMakeConfig.BuildDir buildDirSetByUser = True if userCMakeConfig.GeneratorName is not None: generatorName = userCMakeConfig.GeneratorName if userCMakeConfig.InstallPrefix is not None: installPrefix = userCMakeConfig.InstallPrefix if userCMakeConfig.AllowFindPackage is not None: allowFindPackage = userCMakeConfig.AllowFindPackage log.LogPrintVerbose(2, "Command line set AllowFindPackage to {0}".format(allowFindPackage)) # If we still dont have a generator name then try to select a good default if len(generatorName) <= 0: # Try to determine the default generator name for the platform generatorName = CMakeHelper.GetPlatformDefaultCMakeGenerator(platformName, defaultCompilerVersion) cmakeVersion = CMakeUtil.GetVersion() cmakeConfigGlobalArgs = [] if userCMakeConfig is None else shlex.split(userCMakeConfig.ConfigGlobalArgs) cmakeConfigAppArgs = [] if userCMakeConfig is None else shlex.split(userCMakeConfig.ConfigAppArgs) checkDir = IOUtil.Join(buildDir, 'fsl') if isCheckMode: buildDir = checkDir return GeneratorCMakeConfig(toolVersion, platformName, buildVariantConfig, buildDir, buildDirSetByUser, checkDir, generatorName, installPrefix, cmakeVersion, cmakeConfigGlobalArgs, cmakeConfigAppArgs, allowFindPackage)
def BuildGeneratorCMakeConfig( platformName: str, userCMakeConfig: Optional[UserCMakeConfig], cmakeConfiguration: CMakeConfiguration, defaultCompilerVersion: int) -> GeneratorCMakeConfig: """ Build the CMake config based on the supplied parameters and the default settings from the toolconfig """ # Setup default configuration buildDir = cmakeConfiguration.DefaultBuildDir generatorName = "" installPrefix = cmakeConfiguration.DefaultInstallPrefix # Give the platform a chance to override the config platformConfig = cmakeConfiguration.TryGetPlatformConfig(platformName) if platformConfig is not None: if platformConfig.DefaultGeneratorName is not None: generatorName = platformConfig.DefaultGeneratorName if platformConfig.DefaultInstallPrefix is not None: installPrefix = platformConfig.DefaultInstallPrefix # Apply the commandline overrides (so the user gets the final say) if userCMakeConfig is not None: if userCMakeConfig.BuildDir is not None: buildDir = userCMakeConfig.BuildDir if userCMakeConfig.GeneratorName is not None: generatorName = userCMakeConfig.GeneratorName if userCMakeConfig.InstallPrefix is not None: installPrefix = userCMakeConfig.InstallPrefix # If we still dont have a generator name then try to select a good default if len(generatorName) <= 0: # Try to determine the default generator name for the platform generatorName = CMakeTypes.GetPlatformDefaultCMakeGenerator( platformName, defaultCompilerVersion) cmakeVersion = CMakeUtil.GetVersion() return GeneratorCMakeConfig(buildDir, generatorName, installPrefix, cmakeVersion)