logic: adding vs compatibility flags to new project when Coati is using global includes of Visual Studio

* also added distinct path detectors for 32 and 64 bit Visual Studio
This commit is contained in:
malte_langkabel
2017-02-07 12:44:08 +01:00
parent a2e88b9048
commit d988af2ea9
6 changed files with 82 additions and 12 deletions
@@ -25,6 +25,7 @@
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageScrollSpeedChange.h"
#include "utility/messaging/type/MessageStatus.h"
#include "utility/utilityPathDetection.h"
#include "utility/utilityString.h"
#include "Application.h"
@@ -246,6 +247,29 @@ void QtProjectWizzard::showPreferences()
connect(window, SIGNAL(next()), this, SLOT(savePreferences()));
}
bool QtProjectWizzard::applicationSettingsContainVisualStudioHeaderSearchPaths()
{
std::vector<FilePath> usedExpandedGlobalHeaderSearchPaths = ApplicationSettings::getInstance()->getHeaderSearchPathsExpanded();
const std::shared_ptr<CombinedPathDetector> headerPathDetector = utility::getCxxVsHeaderPathDetector();
for (const std::string& detectorName: headerPathDetector->getWorkingDetectorNames())
{
for (const FilePath& path: headerPathDetector->getPaths(detectorName))
{
const FilePath expandedPath = path.expandEnvironmentVariables();
for (const FilePath& usedExpandedPath: usedExpandedGlobalHeaderSearchPaths)
{
if (expandedPath == usedExpandedPath)
{
return true;
}
}
}
}
return false;
}
template<typename T>
QtProjectWizzardWindow* QtProjectWizzard::createWindowWithContent()
{
@@ -335,6 +359,15 @@ void QtProjectWizzard::selectedProjectType(LanguageType languageType, QtProjectW
else
{
m_settings = std::make_shared<CxxProjectSettings>();
if (applicationSettingsContainVisualStudioHeaderSearchPaths())
{
std::vector<std::string> flags;
flags.push_back("-fms-extensions");
flags.push_back("-fms-compatibility");
flags.push_back("-fms-compatibility-version=19");
std::dynamic_pointer_cast<CxxProjectSettings>(m_settings)->setCompilerFlags(flags);
}
}
m_settings->setLanguage(languageType);
emptyProject();
@@ -42,6 +42,8 @@ public slots:
void showPreferences();
private:
static bool applicationSettingsContainVisualStudioHeaderSearchPaths();
template<typename T>
QtProjectWizzardWindow* createWindowWithContent();
@@ -8,10 +8,11 @@
#include "utility/file/FilePath.h"
#include "utility/logging/logging.h"
CxxVsHeaderPathDetector::CxxVsHeaderPathDetector(int version, bool isExpress)
: PathDetector("Visual Studio " + std::to_string(version) + (isExpress ? " Express" : ""))
CxxVsHeaderPathDetector::CxxVsHeaderPathDetector(int version, bool isExpress, ApplicationArchitectureType architecture)
: PathDetector("Visual Studio " + std::to_string(version) + (isExpress ? " Express" : "") + (architecture == APPLICATION_ARCHITECTURE_X86_64 ? "64 Bit" : ""))
, m_version(version)
, m_isExpress(isExpress)
, m_architecture(architecture)
{
}
@@ -89,7 +90,7 @@ std::vector<FilePath> CxxVsHeaderPathDetector::getPaths() const
FilePath CxxVsHeaderPathDetector::getVsInstallPathUsingRegistry() const
{
QString key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\";
if (QSysInfo::currentCpuArchitecture() == "x86_64")
if (m_architecture == APPLICATION_ARCHITECTURE_X86_32)
{
key += "Wow6432Node\\";
}
@@ -2,11 +2,12 @@
#define CXX_VS_HEADER_PATH_DETECTOR_H
#include "utility/path_detector/PathDetector.h"
#include "utility/ApplicationArchitectureType.h"
class CxxVsHeaderPathDetector: public PathDetector
{
public:
CxxVsHeaderPathDetector(int version, bool isExpress);
CxxVsHeaderPathDetector(int version, bool isExpress, ApplicationArchitectureType architecture);
virtual ~CxxVsHeaderPathDetector();
virtual std::vector<FilePath> getPaths() const;
@@ -17,6 +18,7 @@ private:
const int m_version;
const bool m_isExpress;
const ApplicationArchitectureType m_architecture;
};
#endif // CXX_VS_HEADER_PATH_DETECTOR_H
+38 -8
View File
@@ -29,19 +29,49 @@ std::shared_ptr<CombinedPathDetector> utility::getJavaRuntimePathDetector()
return combinedDetector;
}
std::shared_ptr<CombinedPathDetector> utility::getCxxVsHeaderPathDetector()
{
std::shared_ptr<CombinedPathDetector> combinedDetector = std::make_shared<CombinedPathDetector>();
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(14, false, APPLICATION_ARCHITECTURE_X86_32));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(14, false, APPLICATION_ARCHITECTURE_X86_64));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(14, true, APPLICATION_ARCHITECTURE_X86_32));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(14, true, APPLICATION_ARCHITECTURE_X86_64));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(12, false, APPLICATION_ARCHITECTURE_X86_32));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(12, false, APPLICATION_ARCHITECTURE_X86_64));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(12, true, APPLICATION_ARCHITECTURE_X86_32));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(12, true, APPLICATION_ARCHITECTURE_X86_64));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(11, false, APPLICATION_ARCHITECTURE_X86_32));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(11, false, APPLICATION_ARCHITECTURE_X86_64));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(11, true, APPLICATION_ARCHITECTURE_X86_32));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(11, true, APPLICATION_ARCHITECTURE_X86_64));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(9, false, APPLICATION_ARCHITECTURE_X86_32));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(9, false, APPLICATION_ARCHITECTURE_X86_64));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(9, true, APPLICATION_ARCHITECTURE_X86_32));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(9, true, APPLICATION_ARCHITECTURE_X86_64));
return combinedDetector;
}
std::shared_ptr<CombinedPathDetector> utility::getCxxHeaderPathDetector()
{
std::shared_ptr<CombinedPathDetector> combinedDetector = std::make_shared<CombinedPathDetector>();
combinedDetector->addDetector(std::make_shared<CxxHeaderPathDetector>("gcc"));
combinedDetector->addDetector(std::make_shared<CxxHeaderPathDetector>("clang"));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(14, false));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(14, true));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(12, false));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(12, true));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(11, false));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(11, true));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(9, false));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(9, true));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(14, false, APPLICATION_ARCHITECTURE_X86_32));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(14, false, APPLICATION_ARCHITECTURE_X86_64));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(14, true, APPLICATION_ARCHITECTURE_X86_32));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(14, true, APPLICATION_ARCHITECTURE_X86_64));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(12, false, APPLICATION_ARCHITECTURE_X86_32));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(12, false, APPLICATION_ARCHITECTURE_X86_64));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(12, true, APPLICATION_ARCHITECTURE_X86_32));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(12, true, APPLICATION_ARCHITECTURE_X86_64));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(11, false, APPLICATION_ARCHITECTURE_X86_32));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(11, false, APPLICATION_ARCHITECTURE_X86_64));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(11, true, APPLICATION_ARCHITECTURE_X86_32));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(11, true, APPLICATION_ARCHITECTURE_X86_64));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(9, false, APPLICATION_ARCHITECTURE_X86_32));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(9, false, APPLICATION_ARCHITECTURE_X86_64));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(9, true, APPLICATION_ARCHITECTURE_X86_32));
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(9, true, APPLICATION_ARCHITECTURE_X86_64));
return combinedDetector;
}
@@ -6,6 +6,8 @@
namespace utility
{
std::shared_ptr<CombinedPathDetector> getJavaRuntimePathDetector();
std::shared_ptr<CombinedPathDetector> getCxxVsHeaderPathDetector();
std::shared_ptr<CombinedPathDetector> getCxxHeaderPathDetector();
std::shared_ptr<CombinedPathDetector> getCxxFrameworkPathDetector();
}