Merge topic 'vs-windows-phone-and-store'

5d3d9a22 Help: Add notes for topic 'vs-windows-phone-and-store'
401a00d9 VS: Set WindowsPhone and WindowsStore min VS version required
709cebde VS: Generate WindowsPhone and WindowsStore application types
72395ab2 VS: Add .sln "Deploy" mark for WindowsPhone and WindowsStore binaries
2074f581 MSVC: Add system libs for WindowsPhone and WindowsStore
c72f0887 MSVC: Add default WindowsPhone and WindowsStore compile flags
1c94558a MSVC: Disable incremental linking for WindowsPhone and WindowsStore
592098e2 Define 'WINDOWS_PHONE' and 'WINDOWS_STORE' variables
aa42a78f Add WindowsPhone and WindowsStore platform information modules
b94ddf6c CMakeDetermineCompilerId: Recognize WindowsPhone and WindowsStore
d7938bff VS: Select WindowsPhone and WindowsStore default toolsets
3abd150c VS: Save WindowsPhone and WindowsStore system internally
This commit is contained in:
Brad King 2014-08-12 10:03:03 -04:00 committed by CMake Topic Stage
commit 7365a9fe92
22 changed files with 271 additions and 5 deletions

View File

@ -190,6 +190,8 @@ Variables that Describe the System
/variable/MSVC_VERSION
/variable/UNIX
/variable/WIN32
/variable/WINDOWS_PHONE
/variable/WINDOWS_STORE
/variable/XCODE_VERSION
Variables that Control the Build

View File

@ -0,0 +1,10 @@
vs-windows-phone-and-store
--------------------------
* Generators for Visual Studio 11 (2012) and above learned to generate
projects for Windows Phone and Windows Store. One may set the
:variable:`CMAKE_SYSTEM_NAME` variable to ``WindowsPhone``
or ``WindowsStore`` on the :manual:`cmake(1)` command-line
or in a :variable:`CMAKE_TOOLCHAIN_FILE` to activate these platforms.
Also set :variable:`CMAKE_SYSTEM_VERSION` to ``8.0`` or ``8.1`` to
specify the version of Windows to be targeted.

View File

@ -0,0 +1,5 @@
WINDOWS_PHONE
-------------
True when the :variable:`CMAKE_SYSTEM_NAME` variable is set
to ``WindowsPhone``.

View File

@ -0,0 +1,5 @@
WINDOWS_STORE
-------------
True when the :variable:`CMAKE_SYSTEM_NAME` variable is set
to ``WindowsStore``.

View File

@ -168,6 +168,18 @@ Id flags: ${testflags}
else()
set(id_toolset "")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone")
set(id_system "<ApplicationType>Windows Phone</ApplicationType>")
elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
set(id_system "<ApplicationType>Windows Store</ApplicationType>")
else()
set(id_system "")
endif()
if(id_system AND CMAKE_SYSTEM_VERSION)
set(id_system_version "<ApplicationTypeRevision>${CMAKE_SYSTEM_VERSION}</ApplicationTypeRevision>")
else()
set(id_system_version "")
endif()
if(CMAKE_VS_WINCE_VERSION)
set(id_entrypoint "mainACRTStartup")
if("${vs_version}" VERSION_LESS 9)

View File

@ -10,6 +10,8 @@
<ProjectGuid>{CAE07175-D007-4FC3-BFE8-47B392814159}</ProjectGuid>
<RootNamespace>CompilerId@id_lang@</RootNamespace>
<Keyword>Win32Proj</Keyword>
@id_system@
@id_system_version@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'" Label="Configuration">

View File

@ -162,6 +162,14 @@ if(WINCE)
if (MSVC_VERSION LESS 1600)
set(CMAKE_C_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT} corelibc.lib")
endif ()
elseif(WINDOWS_PHONE OR WINDOWS_STORE)
set(_FLAGS_C " /DUNICODE /D_UNICODE")
set(_FLAGS_CXX " /DUNICODE /D_UNICODE /GR /EHsc")
if(WINDOWS_PHONE)
set(CMAKE_C_STANDARD_LIBRARIES_INIT "WindowsPhoneCore.lib RuntimeObject.lib PhoneAppModelHost.lib")
else()
set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib")
endif()
else()
set(_PLATFORM_DEFINES "/DWIN32")
@ -199,11 +207,13 @@ unset(_MACHINE_ARCH_FLAG)
# add /debug and /INCREMENTAL:YES to DEBUG and RELWITHDEBINFO also add pdbtype
# on versions that support it
set( MSVC_INCREMENTAL_YES_FLAG "")
if(NOT WINDOWS_PHONE AND NOT WINDOWS_STORE)
if(NOT MSVC_INCREMENTAL_DEFAULT)
set( MSVC_INCREMENTAL_YES_FLAG "/INCREMENTAL:YES")
else()
set( MSVC_INCREMENTAL_YES_FLAG "/INCREMENTAL" )
endif()
endif()
if (CMAKE_COMPILER_SUPPORTS_PDBTYPE)
set (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug /pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}")

View File

@ -2,6 +2,10 @@ set(WIN32 1)
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsCE")
set(WINCE 1)
elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone")
set(WINDOWS_PHONE 1)
elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
set(WINDOWS_STORE 1)
endif()
set(CMAKE_STATIC_LIBRARY_PREFIX "")

View File

@ -0,0 +1 @@
include(Platform/Windows-MSVC-C)

View File

@ -0,0 +1 @@
include(Platform/Windows-MSVC-CXX)

View File

@ -0,0 +1 @@
include(Platform/Windows)

View File

@ -0,0 +1 @@
include(Platform/Windows-MSVC-C)

View File

@ -0,0 +1 @@
include(Platform/Windows-MSVC-CXX)

View File

@ -0,0 +1 @@
include(Platform/Windows)

View File

@ -97,6 +97,8 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
this->ExpressEdition = cmSystemTools::ReadRegistryValue(
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\10.0\\Setup\\VC;"
"ProductDir", vc10Express, cmSystemTools::KeyWOW64_32);
this->SystemIsWindowsPhone = false;
this->SystemIsWindowsStore = false;
this->MasmEnabled = false;
this->MSBuildCommandInitialized = false;
}
@ -146,11 +148,45 @@ bool cmGlobalVisualStudio10Generator::SetSystemName(std::string const& s,
}
//----------------------------------------------------------------------------
bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile*)
bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf)
{
if(this->SystemName == "WindowsPhone")
{
this->SystemIsWindowsPhone = true;
if(!this->InitializeWindowsPhone(mf))
{
return false;
}
}
else if(this->SystemName == "WindowsStore")
{
this->SystemIsWindowsStore = true;
if(!this->InitializeWindowsStore(mf))
{
return false;
}
}
return true;
}
//----------------------------------------------------------------------------
bool cmGlobalVisualStudio10Generator::InitializeWindowsPhone(cmMakefile* mf)
{
cmOStringStream e;
e << this->GetName() << " does not support Windows Phone.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
//----------------------------------------------------------------------------
bool cmGlobalVisualStudio10Generator::InitializeWindowsStore(cmMakefile* mf)
{
cmOStringStream e;
e << this->GetName() << " does not support Windows Store.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator
::AddVSPlatformToolsetDefinition(cmMakefile* mf) const

View File

@ -70,6 +70,14 @@ public:
/** Return the CMAKE_SYSTEM_VERSION. */
std::string const& GetSystemVersion() const { return this->SystemVersion; }
/** Return true if building for WindowsPhone */
bool TargetsWindowsPhone() const
{ return this->SystemIsWindowsPhone; }
/** Return true if building for WindowsStore */
bool TargetsWindowsStore() const
{ return this->SystemIsWindowsStore; }
/**
* Where does this version of Visual Studio look for macros for the
* current user? Returns the empty string if this version of Visual
@ -99,6 +107,10 @@ public:
protected:
virtual void Generate();
virtual bool InitializeSystem(cmMakefile* mf);
virtual bool InitializeWindowsPhone(cmMakefile* mf);
virtual bool InitializeWindowsStore(cmMakefile* mf);
virtual std::string SelectWindowsPhoneToolset() const { return ""; }
virtual std::string SelectWindowsStoreToolset() const { return ""; }
virtual const char* GetIDEVersion() { return "10.0"; }
@ -108,6 +120,8 @@ protected:
std::string DefaultPlatformToolset;
std::string SystemName;
std::string SystemVersion;
bool SystemIsWindowsPhone;
bool SystemIsWindowsStore;
bool ExpressEdition;
bool MasmEnabled;

View File

@ -128,6 +128,56 @@ cmGlobalVisualStudio11Generator::MatchesGeneratorName(
return false;
}
//----------------------------------------------------------------------------
bool cmGlobalVisualStudio11Generator::InitializeWindowsPhone(cmMakefile* mf)
{
this->DefaultPlatformToolset = this->SelectWindowsPhoneToolset();
if(this->DefaultPlatformToolset.empty())
{
cmOStringStream e;
e << this->GetName() << " supports Windows Phone '8.0', but not '"
<< this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
return true;
}
//----------------------------------------------------------------------------
bool cmGlobalVisualStudio11Generator::InitializeWindowsStore(cmMakefile* mf)
{
this->DefaultPlatformToolset = this->SelectWindowsStoreToolset();
if(this->DefaultPlatformToolset.empty())
{
cmOStringStream e;
e << this->GetName() << " supports Windows Store '8.0', but not '"
<< this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
return true;
}
//----------------------------------------------------------------------------
std::string cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset() const
{
if(this->SystemVersion == "8.0")
{
return "v110_wp80";
}
return this->cmGlobalVisualStudio10Generator::SelectWindowsPhoneToolset();
}
//----------------------------------------------------------------------------
std::string cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset() const
{
if(this->SystemVersion == "8.0")
{
return "v110";
}
return this->cmGlobalVisualStudio10Generator::SelectWindowsStoreToolset();
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout)
{
@ -192,3 +242,17 @@ cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs()
return ret;
}
//----------------------------------------------------------------------------
bool
cmGlobalVisualStudio11Generator::NeedsDeploy(cmTarget::TargetType type) const
{
if((type == cmTarget::EXECUTABLE ||
type == cmTarget::SHARED_LIBRARY) &&
(this->SystemIsWindowsPhone ||
this->SystemIsWindowsStore))
{
return true;
}
return cmGlobalVisualStudio10Generator::NeedsDeploy(type);
}

View File

@ -34,9 +34,16 @@ public:
/** TODO: VS 11 user macro support. */
virtual std::string GetUserMacrosDirectory() { return ""; }
protected:
virtual bool InitializeWindowsPhone(cmMakefile* mf);
virtual bool InitializeWindowsStore(cmMakefile* mf);
virtual std::string SelectWindowsPhoneToolset() const;
virtual std::string SelectWindowsStoreToolset() const;
virtual const char* GetIDEVersion() { return "11.0"; }
bool UseFolderProperty();
static std::set<std::string> GetInstalledWindowsCESDKs();
/** Return true if the configuration needs to be deployed */
virtual bool NeedsDeploy(cmTarget::TargetType type) const;
private:
class Factory;
friend class Factory;

View File

@ -108,6 +108,56 @@ cmGlobalVisualStudio12Generator::MatchesGeneratorName(
return false;
}
//----------------------------------------------------------------------------
bool cmGlobalVisualStudio12Generator::InitializeWindowsPhone(cmMakefile* mf)
{
this->DefaultPlatformToolset = this->SelectWindowsPhoneToolset();
if(this->DefaultPlatformToolset.empty())
{
cmOStringStream e;
e << this->GetName() << " supports Windows Phone '8.0' and '8.1', "
"but not '" << this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
return true;
}
//----------------------------------------------------------------------------
bool cmGlobalVisualStudio12Generator::InitializeWindowsStore(cmMakefile* mf)
{
this->DefaultPlatformToolset = this->SelectWindowsStoreToolset();
if(this->DefaultPlatformToolset.empty())
{
cmOStringStream e;
e << this->GetName() << " supports Windows Store '8.0' and '8.1', "
"but not '" << this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
return true;
}
//----------------------------------------------------------------------------
std::string cmGlobalVisualStudio12Generator::SelectWindowsPhoneToolset() const
{
if(this->SystemVersion == "8.1")
{
return "v120_wp81";
}
return this->cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset();
}
//----------------------------------------------------------------------------
std::string cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset() const
{
if(this->SystemVersion == "8.1")
{
return "v120";
}
return this->cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset();
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio12Generator::WriteSLNHeader(std::ostream& fout)
{

View File

@ -39,6 +39,10 @@ public:
//version number
virtual const char* GetToolsVersion() { return "12.0"; }
protected:
virtual bool InitializeWindowsPhone(cmMakefile* mf);
virtual bool InitializeWindowsStore(cmMakefile* mf);
virtual std::string SelectWindowsPhoneToolset() const;
virtual std::string SelectWindowsStoreToolset() const;
virtual const char* GetIDEVersion() { return "12.0"; }
private:
class Factory;

View File

@ -286,6 +286,11 @@ void cmVisualStudio10TargetGenerator::Generate()
this->WriteString("<ProjectGUID>", 2);
(*this->BuildFileStream) << "{" << this->GUID << "}</ProjectGUID>\n";
if(this->MSTools && this->Target->GetType() <= cmTarget::UTILITY)
{
this->WriteApplicationTypeSettings();
}
const char* vsProjectTypes =
this->Target->GetProperty("VS_GLOBAL_PROJECT_TYPES");
if(vsProjectTypes)
@ -2100,3 +2105,32 @@ bool cmVisualStudio10TargetGenerator::
expectedResxHeaders.find(headerFile);
return it != expectedResxHeaders.end();
}
void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
{
bool const isWindowsPhone = this->GlobalGenerator->TargetsWindowsPhone();
bool const isWindowsStore = this->GlobalGenerator->TargetsWindowsStore();
std::string const& v = this->GlobalGenerator->GetSystemVersion();
if(isWindowsPhone || isWindowsStore)
{
this->WriteString("<ApplicationType>", 2);
(*this->BuildFileStream) << (isWindowsPhone ?
"Windows Phone" : "Windows Store")
<< "</ApplicationType>\n";
this->WriteString("<ApplicationTypeRevision>", 2);
(*this->BuildFileStream) << cmVS10EscapeXML(v)
<< "</ApplicationTypeRevision>\n";
if(v == "8.1")
{
// Visual Studio 12.0 is necessary for building 8.1 apps
this->WriteString("<MinimumVisualStudioVersion>12.0"
"</MinimumVisualStudioVersion>\n", 2);
}
else if (v == "8.0")
{
// Visual Studio 11.0 is necessary for building 8.0 apps
this->WriteString("<MinimumVisualStudioVersion>11.0"
"</MinimumVisualStudioVersion>\n", 2);
}
}
}

View File

@ -91,6 +91,7 @@ private:
void WriteCustomCommand(cmSourceFile const* sf);
void WriteGroups();
void WriteProjectReferences();
void WriteApplicationTypeSettings();
bool OutputSourceSpecificFlags(cmSourceFile const* source);
void AddLibraries(cmComputeLinkInformation& cli,
std::vector<std::string>& libVec);