Commit 581b0c0d authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'windows-ce'

3a1006e4 VS: Added "Deploy" at project configuration for WindowsCE targets
40c36c9f VS: Make DetermineCompilerId working with WinCE too
038df9e4 VS: Allow setting the name of the target platform
6fe4fcba VS: Add parser for WCE.VCPlatform.config to read WinCE platforms
2118a201 VS: Support setting correct subsystem and entry point for WinCE
6920fed6 VS: Change variable type of Name from const char* to string
102521b6 VS: Change variable type of ArchitectureId from const char* to string
332dc09d VS: Add static method to get the base of the registry
d41d4d3d VS: Add CMAKE_VS_PLATFORM_NAME definition to cmMakefile
14861f88 VS: Remove TargetMachine for linker when checking compiler id
parents 1ed04648 3a1006e4
......@@ -228,3 +228,7 @@ int main(int argc, char* argv[])
return require;
}
#endif
#ifdef ADD_MAINCRTSTARTUP
void mainCRTStartup() {}
#endif
......@@ -210,3 +210,7 @@ int main(int argc, char* argv[])
(void)argv;
return require;
}
#ifdef ADD_MAINCRTSTARTUP
extern "C" void mainCRTStartup() {}
#endif
......@@ -107,11 +107,14 @@ Id flags: ${testflags}
")
# Compile the compiler identification source.
if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([0-9]+)( .NET)?( 200[358])? *((Win64|IA64|ARM))?")
if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([0-9]+)")
set(vs_version ${CMAKE_MATCH_1})
set(vs_arch ${CMAKE_MATCH_4})
set(id_arch ${CMAKE_VS_PLATFORM_NAME})
set(id_lang "${lang}")
set(id_cl cl.exe)
if(NOT id_arch)
set(id_arch Win32)
endif()
if(NOT "${vs_version}" VERSION_LESS 10)
set(v 10)
set(ext vcxproj)
......@@ -123,25 +126,23 @@ Id flags: ${testflags}
set(v 6)
set(ext dsp)
endif()
if("${vs_arch}" STREQUAL "Win64")
set(id_machine_7 17)
if("${id_arch}" STREQUAL "x64")
set(id_machine_10 MachineX64)
set(id_arch x64)
elseif("${vs_arch}" STREQUAL "IA64")
set(id_machine_7 5)
elseif("${id_arch}" STREQUAL "Itanium")
set(id_machine_10 MachineIA64)
set(id_arch ia64)
else()
set(id_machine_6 x86)
set(id_machine_7 1)
set(id_machine_10 MachineX86)
set(id_arch Win32)
endif()
if(CMAKE_VS_PLATFORM_TOOLSET)
set(id_toolset "<PlatformToolset>${CMAKE_VS_PLATFORM_TOOLSET}</PlatformToolset>")
else()
set(id_toolset "")
endif()
if(CMAKE_VS_WINCE_VERSION)
set(id_definitions "ADD_MAINCRTSTARTUP")
endif()
if("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Bb][Uu][Ii][Ll][Dd]")
set(build /p:Configuration=Debug /p:Platform=@id_arch@ /p:VisualStudioVersion=${vs_version}.0)
elseif("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Dd][Ee][Vv]")
......
......@@ -106,6 +106,12 @@ if(CMAKE_SYSTEM_NAME)
set(CMAKE_CROSSCOMPILING TRUE)
endif()
set(PRESET_CMAKE_SYSTEM_NAME TRUE)
elseif(CMAKE_VS_WINCE_VERSION)
set(CMAKE_SYSTEM_NAME "WindowsCE")
set(CMAKE_SYSTEM_VERSION "${CMAKE_VS_WINCE_VERSION}")
set(CMAKE_SYSTEM_PROCESSOR "${MSVC_C_ARCHITECTURE_ID}")
set(CMAKE_CROSSCOMPILING TRUE)
set(PRESET_CMAKE_SYSTEM_NAME TRUE)
else()
set(CMAKE_SYSTEM_NAME "${CMAKE_HOST_SYSTEM_NAME}")
set(CMAKE_SYSTEM_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
......
......@@ -24,7 +24,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
PreprocessorDefinitions="@id_definitions@"
MinimalRebuild="false"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
......@@ -37,7 +37,6 @@
LinkIncremental="1"
GenerateDebugInformation="false"
SubSystem="1"
TargetMachine="@id_machine_7@"
/>
<Tool
Name="VCPostBuildEventTool"
......
......@@ -353,6 +353,8 @@ if (WIN32)
cmLocalVisualStudio7Generator.h
cmLocalVisualStudioGenerator.cxx
cmLocalVisualStudioGenerator.h
cmVisualStudioWCEPlatformParser.h
cmVisualStudioWCEPlatformParser.cxx
cmWin32ProcessExecution.cxx
cmWin32ProcessExecution.h
)
......
......@@ -144,8 +144,7 @@ void cmGlobalVisualStudio10Generator
::EnableLanguage(std::vector<std::string>const & lang,
cmMakefile *mf, bool optional)
{
if(!strcmp(this->ArchitectureId, "Itanium") ||
!strcmp(this->ArchitectureId, "x64"))
if(this->ArchitectureId == "Itanium" || this->ArchitectureId == "x64")
{
if(this->IsExpressEdition() && !this->Find64BitTools(mf))
{
......
......@@ -277,7 +277,7 @@ void cmGlobalVisualStudio71Generator
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio71Generator
::WriteProjectConfigurations(
std::ostream& fout, const char* name,
std::ostream& fout, const char* name, cmTarget::TargetType,
const std::set<std::string>& configsPartOfDefaultBuild,
const char* platformMapping)
{
......
......@@ -63,7 +63,7 @@ protected:
virtual void WriteProjectDepends(std::ostream& fout,
const char* name, const char* path, cmTarget &t);
virtual void WriteProjectConfigurations(
std::ostream& fout, const char* name,
std::ostream& fout, const char* name, cmTarget::TargetType type,
const std::set<std::string>& configsPartOfDefaultBuild,
const char* platformMapping = NULL);
virtual void WriteExternalProject(std::ostream& fout,
......
......@@ -247,7 +247,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
std::set<std::string> allConfigurations(this->Configurations.begin(),
this->Configurations.end());
this->WriteProjectConfigurations(
fout, target->GetName(),
fout, target->GetName(), target->GetType(),
allConfigurations, target->GetProperty("VS_PLATFORM_MAPPING"));
}
else
......@@ -259,7 +259,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
target->GetProperty("GENERATOR_FILE_NAME");
if (vcprojName)
{
this->WriteProjectConfigurations(fout, vcprojName,
this->WriteProjectConfigurations(fout, vcprojName, target->GetType(),
configsPartOfDefaultBuild);
}
}
......@@ -587,7 +587,7 @@ cmGlobalVisualStudio7Generator
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio7Generator
::WriteProjectConfigurations(
std::ostream& fout, const char* name,
std::ostream& fout, const char* name, cmTarget::TargetType,
const std::set<std::string>& configsPartOfDefaultBuild,
const char* platformMapping)
{
......
......@@ -108,7 +108,7 @@ protected:
virtual void WriteProjectDepends(std::ostream& fout,
const char* name, const char* path, cmTarget &t);
virtual void WriteProjectConfigurations(
std::ostream& fout, const char* name,
std::ostream& fout, const char* name, cmTarget::TargetType type,
const std::set<std::string>& configsPartOfDefaultBuild,
const char* platformMapping = NULL);
virtual void WriteSLNGlobalSections(std::ostream& fout,
......
......@@ -13,32 +13,58 @@
#include "cmGlobalVisualStudio8Generator.h"
#include "cmLocalVisualStudio7Generator.h"
#include "cmMakefile.h"
#include "cmVisualStudioWCEPlatformParser.h"
#include "cmake.h"
#include "cmGeneratedFileStream.h"
static const char vs8Win32generatorName[] = "Visual Studio 8 2005";
static const char vs8Win64generatorName[] = "Visual Studio 8 2005 Win64";
static const char vs8generatorName[] = "Visual Studio 8 2005";
class cmGlobalVisualStudio8Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
if(!strcmp(name, vs8Win32generatorName))
if(strstr(name, vs8generatorName) != name)
{
return 0;
}
const char* p = name + sizeof(vs8generatorName) - 1;
if(p[0] == '\0')
{
return new cmGlobalVisualStudio8Generator(
vs8Win32generatorName, NULL, NULL);
name, NULL, NULL);
}
if(p[0] != ' ')
{
return 0;
}
if(!strcmp(name, vs8Win64generatorName))
++p;
if(!strcmp(p, "Win64"))
{
return new cmGlobalVisualStudio8Generator(
vs8Win64generatorName, "x64", "CMAKE_FORCE_WIN64");
name, "x64", "CMAKE_FORCE_WIN64");
}
return 0;
cmVisualStudioWCEPlatformParser parser(p);
parser.ParseVersion("8.0");
if (!parser.Found())
{
return 0;
}
cmGlobalVisualStudio8Generator* ret = new cmGlobalVisualStudio8Generator(
name, parser.GetArchitectureFamily(), NULL);
ret->PlatformName = p;
ret->WindowsCEVersion = parser.GetOSVersion();
return ret;
}
virtual void GetDocumentation(cmDocumentationEntry& entry) const {
entry.Name = "Visual Studio 8 2005";
entry.Name = vs8generatorName;
entry.Brief = "Generates Visual Studio 8 2005 project files.";
entry.Full =
"It is possible to append a space followed by the platform name "
......@@ -48,8 +74,18 @@ public:
}
virtual void GetGenerators(std::vector<std::string>& names) const {
names.push_back(vs8Win32generatorName);
names.push_back(vs8Win64generatorName); }
names.push_back(vs8generatorName);
names.push_back(vs8generatorName + std::string(" Win64"));
cmVisualStudioWCEPlatformParser parser;
parser.ParseVersion("8.0");
const std::vector<std::string>& availablePlatforms =
parser.GetAvailablePlatforms();
for(std::vector<std::string>::const_iterator i =
availablePlatforms.begin(); i != availablePlatforms.end(); ++i)
{
names.push_back("Visual Studio 8 2005 " + *i);
}
}
};
//----------------------------------------------------------------------------
......@@ -79,11 +115,15 @@ cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator(
//----------------------------------------------------------------------------
const char* cmGlobalVisualStudio8Generator::GetPlatformName() const
{
if (!strcmp(this->ArchitectureId, "X86"))
if (!this->PlatformName.empty())
{
return this->PlatformName.c_str();
}
if (this->ArchitectureId == "X86")
{
return "Win32";
}
return this->ArchitectureId;
return this->ArchitectureId.c_str();
}
//----------------------------------------------------------------------------
......@@ -98,6 +138,19 @@ cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator()
return lg;
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf)
{
cmGlobalVisualStudio71Generator::AddPlatformDefinitions(mf);
mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName());
if(this->TargetsWindowsCE())
{
mf->AddDefinition("CMAKE_VS_WINCE_VERSION",
this->WindowsCEVersion.c_str());
}
}
//----------------------------------------------------------------------------
// ouput standard header for dsw file
void cmGlobalVisualStudio8Generator::WriteSLNHeader(std::ostream& fout)
......@@ -321,7 +374,7 @@ cmGlobalVisualStudio8Generator
void
cmGlobalVisualStudio8Generator
::WriteProjectConfigurations(
std::ostream& fout, const char* name,
std::ostream& fout, const char* name, cmTarget::TargetType type,
const std::set<std::string>& configsPartOfDefaultBuild,
const char* platformMapping)
{
......@@ -342,6 +395,15 @@ cmGlobalVisualStudio8Generator
<< (platformMapping ? platformMapping : this->GetPlatformName())
<< "\n";
}
bool needsDeploy = (type == cmTarget::EXECUTABLE ||
type == cmTarget::SHARED_LIBRARY);
if(this->TargetsWindowsCE() && needsDeploy)
{
fout << "\t\t{" << guid << "}." << *i
<< "|" << this->GetPlatformName() << ".Deploy.0 = " << *i << "|"
<< (platformMapping ? platformMapping : this->GetPlatformName())
<< "\n";
}
}
}
......
......@@ -28,7 +28,7 @@ public:
static cmGlobalGeneratorFactory* NewFactory();
///! Get the name for the generator.
virtual const char* GetName() const {return this->Name;}
virtual const char* GetName() const {return this->Name.c_str();}
const char* GetPlatformName() const;
......@@ -38,6 +38,8 @@ public:
///! Create a local generator appropriate to this Global Generator
virtual cmLocalGenerator *CreateLocalGenerator();
virtual void AddPlatformDefinitions(cmMakefile* mf);
/**
* Override Configure and Generate to add the build-system check
* target.
......@@ -62,6 +64,10 @@ public:
LinkLibraryDependencies and link to .sln dependencies. */
virtual bool NeedLinkLibraryDependencies(cmTarget& target);
/** Return true if building for Windows CE */
virtual bool TargetsWindowsCE() const {
return !this->WindowsCEVersion.empty(); }
protected:
virtual const char* GetIDEVersion() { return "8.0"; }
......@@ -73,16 +79,19 @@ protected:
virtual void WriteSLNHeader(std::ostream& fout);
virtual void WriteSolutionConfigurations(std::ostream& fout);
virtual void WriteProjectConfigurations(
std::ostream& fout, const char* name,
std::ostream& fout, const char* name, cmTarget::TargetType type,
const std::set<std::string>& configsPartOfDefaultBuild,
const char* platformMapping = NULL);
virtual bool ComputeTargetDepends();
virtual void WriteProjectDepends(std::ostream& fout, const char* name,
const char* path, cmTarget &t);
const char* Name;
std::string Name;
std::string PlatformName;
std::string WindowsCEVersion;
private:
class Factory;
friend class Factory;
};
#endif
......@@ -13,37 +13,63 @@
#include "cmGlobalVisualStudio9Generator.h"
#include "cmLocalVisualStudio7Generator.h"
#include "cmMakefile.h"
#include "cmVisualStudioWCEPlatformParser.h"
#include "cmake.h"
static const char vs9Win32generatorName[] = "Visual Studio 9 2008";
static const char vs9Win64generatorName[] = "Visual Studio 8 2005 Win64";
static const char vs9IA64generatorName[] = "Visual Studio 9 2008 IA64";
static const char vs9generatorName[] = "Visual Studio 9 2008";
class cmGlobalVisualStudio9Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
if(!strcmp(name, vs9Win32generatorName))
if(strstr(name, vs9generatorName) != name)
{
return 0;
}
const char* p = name + sizeof(vs9generatorName) - 1;
if(p[0] == '\0')
{
return new cmGlobalVisualStudio9Generator(
vs9Win32generatorName, NULL, NULL);
name, NULL, NULL);
}
if(p[0] != ' ')
{
return 0;
}
if(!strcmp(name, vs9Win64generatorName))
++p;
if(!strcmp(p, "IA64"))
{
return new cmGlobalVisualStudio9Generator(
vs9Win64generatorName, "x64", "CMAKE_FORCE_WIN64");
name, "Itanium", "CMAKE_FORCE_IA64");
}
if(!strcmp(name, vs9IA64generatorName))
if(!strcmp(p, "Win64"))
{
return new cmGlobalVisualStudio9Generator(
vs9IA64generatorName, "Itanium", "CMAKE_FORCE_IA64");
name, "x64", "CMAKE_FORCE_WIN64");
}
cmVisualStudioWCEPlatformParser parser(p);
parser.ParseVersion("9.0");
if (!parser.Found())
{
return 0;
}
return 0;
cmGlobalVisualStudio9Generator* ret = new cmGlobalVisualStudio9Generator(
name, parser.GetArchitectureFamily(), NULL);
ret->PlatformName = p;
ret->WindowsCEVersion = parser.GetOSVersion();
return ret;
}
virtual void GetDocumentation(cmDocumentationEntry& entry) const {
entry.Name = "Visual Studio 9 2008";
entry.Name = vs9generatorName;
entry.Brief = "Generates Visual Studio 9 2008 project files.";
entry.Full =
"It is possible to append a space followed by the platform name "
......@@ -53,9 +79,19 @@ public:
}
virtual void GetGenerators(std::vector<std::string>& names) const {
names.push_back(vs9Win32generatorName);
names.push_back(vs9Win64generatorName);
names.push_back(vs9IA64generatorName); }
names.push_back(vs9generatorName);
names.push_back(vs9generatorName + std::string(" Win64"));
names.push_back(vs9generatorName + std::string(" IA64"));
cmVisualStudioWCEPlatformParser parser;
parser.ParseVersion("9.0");
const std::vector<std::string>& availablePlatforms =
parser.GetAvailablePlatforms();
for(std::vector<std::string>::const_iterator i =
availablePlatforms.begin(); i != availablePlatforms.end(); ++i)
{
names.push_back("Visual Studio 9 2008 " + *i);
}
}
};
//----------------------------------------------------------------------------
......
......@@ -55,5 +55,6 @@ protected:
virtual const char* GetIDEVersion() { return "9.0"; }
private:
class Factory;
friend class Factory;
};
#endif
......@@ -32,10 +32,17 @@ cmGlobalVisualStudioGenerator::~cmGlobalVisualStudioGenerator()
//----------------------------------------------------------------------------
std::string cmGlobalVisualStudioGenerator::GetRegistryBase()
{
return cmGlobalVisualStudioGenerator::GetRegistryBase(
this->GetIDEVersion());
}
//----------------------------------------------------------------------------
std::string cmGlobalVisualStudioGenerator::GetRegistryBase(
const char* version)
{
std::string key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\";
key += this->GetIDEVersion();
return key;
return key + version;
}
//----------------------------------------------------------------------------
......@@ -492,8 +499,8 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target)
//----------------------------------------------------------------------------
void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf)
{
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", this->ArchitectureId);
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", this->ArchitectureId);
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", this->ArchitectureId.c_str());
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", this->ArchitectureId.c_str());
if(this->AdditionalPlatformDefinition)
{
......
......@@ -65,10 +65,16 @@ public:
/** Get the top-level registry key for this VS version. */
std::string GetRegistryBase();
/** Get the top-level registry key for the given VS version. */
static std::string GetRegistryBase(const char* version);
/** Return true if the generated build tree may contain multiple builds.
i.e. "Can I build Debug and Release in the same tree?" */
virtual bool IsMultiConfig() { return true; }
/** Return true if building for Windows CE */
virtual bool TargetsWindowsCE() const { return false; }
class TargetSet: public std::set<cmTarget*> {};
struct TargetCompare
{
......@@ -98,7 +104,7 @@ protected:
std::string GetUtilityDepend(cmTarget* target);
typedef std::map<cmTarget*, cmStdString> UtilityDependsMap;
UtilityDependsMap UtilityDepends;
const char* ArchitectureId;
std::string ArchitectureId;
const char* AdditionalPlatformDefinition;
private:
......
......@@ -229,6 +229,9 @@ void cmLocalVisualStudio7Generator
this->FortranProject =
static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
->TargetIsFortranOnly(target);
this->WindowsCEProject =
static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
->TargetsWindowsCE();
// Intel Fortran for VS10 uses VS9 format ".vfproj" files.
VSVersion realVersion = this->Version;
......@@ -1169,6 +1172,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
cmComputeLinkInformation& cli = *pcli;
const char* linkLanguage = cli.GetLinkLanguage();
bool isWin32Executable = target.GetPropertyAsBool("WIN32_EXECUTABLE");
// Compute the variable name to lookup standard libraries for this
// language.
std::string standardLibsVar = "CMAKE_";
......@@ -1216,15 +1221,24 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
{
fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
}
if ( target.GetPropertyAsBool("WIN32_EXECUTABLE") )
if ( this->WindowsCEProject )
{
fout << "\t\t\t\tSubSystem=\"9\"\n"
<< "\t\t\t\tEntryPointSymbol=\""
<< (isWin32Executable ? "WinMainCRTStartup" : "mainACRTStartup")
<< "\"\n";
}
else if ( this->FortranProject )
{
fout << "\t\t\t\tSubSystem=\""
<< (this->FortranProject? "subSystemWindows" : "2") << "\"\n";
<< (isWin32Executable ? "subSystemWindows" : "subSystemConsole")
<< "\"\n";
}
else
{
fout << "\t\t\t\tSubSystem=\""
<< (this->FortranProject? "subSystemConsole" : "1") << "\"\n";
<< (isWin32Executable ? "2" : "1")
<< "\"\n";
}
std::string stackVar = "CMAKE_";
stackVar += linkLanguage;
......
......@@ -122,6 +122,7 @@ private:
cmVS7FlagTable const* ExtraFlagTable;
std::string ModuleDefinitionFile;
bool FortranProject;
bool WindowsCEProject;
std::string PlatformName; // Win32 or x64
cmLocalVisualStudio7GeneratorInternals* Internal;
};
......
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2012 Kitware, Inc., Insight Software Consortium