Source

BlueGo / BlueGo / Compiler.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using BlueGo.GUI;

namespace BlueGo
{
    // http://www.cmake.org/cmake/help/v2.8.8/cmake.html#command:find_package
    class Package
    {
        string package;
        string version;
        string Components;
    }

    enum eCompiler
    {
        Unknown,
        VS2010,
        VS2012
    }

    class Compiler
    {
        // checks if a certain compiler is present
        public static bool IsPresent(eCompiler compiler)
        {
            switch (compiler)
            {
                case eCompiler.VS2010:
                    if (Directory.Exists( PreferencesManager.Instance.VS2010Location))
                    {
                        return true;
                    }
                    break;

                case eCompiler.VS2012:
                    if (Directory.Exists(PreferencesManager.Instance.VS2012Location))
                    {
                        return true;
                    }
                    break;

                default:
                    break;
            }

            return false;
        }

        static public string GetCompilerPath(eCompiler compiler)
        {
            switch (compiler)
            {
                case eCompiler.VS2010:
                    {
                        if (Directory.Exists(PreferencesManager.Instance.VS2010Location))
                            return PreferencesManager.Instance.VS2010Location;
                    }
                    break;                    
         
                case eCompiler.VS2012:
                    {
                        if (Directory.Exists(PreferencesManager.Instance.VS2012Location))
                            return PreferencesManager.Instance.VS2012Location;
                    }
                    break;

                default:
                    break;
            }

            throw new Exception("Could not local compiler path.");
        }
    }
    
}