Skip to content

Commit

Permalink
Merge pull request #87 from microsoft/dev/jgoshi/PortUnicodeAndInstal…
Browse files Browse the repository at this point in the history
…lFixes

Port unicode and install fixes from upstream Kitware
  • Loading branch information
jgoshi committed Oct 15, 2019
2 parents e9fd8fd + 5dca3f5 commit 62dad8b
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 8 deletions.
9 changes: 3 additions & 6 deletions Source/cmFileAPICodemodel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1025,12 +1025,9 @@ Json::Value Target::DumpInstallPrefix()
Json::Value Target::DumpInstallDestinations()
{
Json::Value destinations = Json::arrayValue;
auto installGens = this->GT->Makefile->GetInstallGenerators();
for (auto iGen : installGens) {
auto itGen = dynamic_cast<cmInstallTargetGenerator*>(iGen);
if (itGen != nullptr && itGen->GetTarget() == this->GT) {
destinations.append(this->DumpInstallDestination(itGen));
}
auto installGens = this->GT->Target->GetInstallGenerators();
for (auto itGen : installGens) {
destinations.append(this->DumpInstallDestination(itGen));
}
return destinations;
}
Expand Down
3 changes: 3 additions & 0 deletions Source/cmGlobalVisualStudioGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ const char* cmGlobalVisualStudioGenerator::GetIDEVersion() const

void cmGlobalVisualStudioGenerator::WriteSLNHeader(std::ostream& fout)
{
char utf8bom[] = { char(0xEF), char(0xBB), char(0xBF) };
fout.write(utf8bom, 3);

switch (this->Version) {
case cmGlobalVisualStudioGenerator::VS9:
fout << "Microsoft Visual Studio Solution File, Format Version 10.00\n";
Expand Down
4 changes: 3 additions & 1 deletion Source/cmInstallCommand.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(
target.SetHaveInstallRule(true);
const char* component = namelink ? args.GetNamelinkComponent().c_str()
: args.GetComponent().c_str();
return new cmInstallTargetGenerator(
auto g = new cmInstallTargetGenerator(
target.GetName(), destination.c_str(), impLib,
args.GetPermissions().c_str(), args.GetConfigurations(), component,
message, args.GetExcludeFromAll(), args.GetOptional() || forceOpt,
backtrace);
target.AddInstallGenerator(g);
return g;
}

static cmInstallTargetGenerator* CreateInstallTargetGenerator(
Expand Down
12 changes: 12 additions & 0 deletions Source/cmTarget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class cmTargetInternals
std::vector<cmCustomCommand> PreBuildCommands;
std::vector<cmCustomCommand> PreLinkCommands;
std::vector<cmCustomCommand> PostBuildCommands;
std::vector<cmInstallTargetGenerator*> InstallGenerators;
std::set<std::string> SystemIncludeDirectories;
cmTarget::LinkLibraryVectorType OriginalLinkLibraries;
std::vector<std::string> IncludeDirectoriesEntries;
Expand Down Expand Up @@ -857,6 +858,17 @@ void cmTarget::SetHaveInstallRule(bool hir)
impl->HaveInstallRule = hir;
}

void cmTarget::AddInstallGenerator(cmInstallTargetGenerator* g)
{
impl->InstallGenerators.emplace_back(g);
}

std::vector<cmInstallTargetGenerator*> const& cmTarget::GetInstallGenerators()
const
{
return impl->InstallGenerators;
}

bool cmTarget::GetIsGeneratorProvided() const
{
return impl->IsGeneratorProvided;
Expand Down
4 changes: 4 additions & 0 deletions Source/cmTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

class cmCustomCommand;
class cmGlobalGenerator;
class cmInstallTargetGenerator;
class cmMakefile;
class cmMessenger;
class cmPropertyMap;
Expand Down Expand Up @@ -146,6 +147,9 @@ class cmTarget
bool GetHaveInstallRule() const;
void SetHaveInstallRule(bool hir);

void AddInstallGenerator(cmInstallTargetGenerator* g);
std::vector<cmInstallTargetGenerator*> const& GetInstallGenerators() const;

/**
* Get/Set whether this target was auto-created by a generator.
*/
Expand Down
35 changes: 34 additions & 1 deletion Tests/RunCMake/FileAPI/codemodel-v2-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -2087,7 +2087,40 @@ def gen_check_targets(c, g, inSource):
],
"build": "^cxx$",
"source": "^cxx$",
"install": None,
"install": {
"prefix": "^(/usr/local|[A-Za-z]:.*/codemodel-v2)$",
"destinations": [
{
"path": "bin",
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 37,
"command": "install",
"hasParent": True,
},
{
"file": "^codemodel-v2\\.cmake$",
"line": None,
"command": None,
"hasParent": True,
},
{
"file": "^CMakeLists\\.txt$",
"line": 3,
"command": "include",
"hasParent": True,
},
{
"file": "^CMakeLists\\.txt$",
"line": None,
"command": None,
"hasParent": False,
},
],
},
],
},
"link": {
"language": "CXX",
"lto": None,
Expand Down
2 changes: 2 additions & 0 deletions Tests/RunCMake/FileAPI/codemodel-v2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ if(_ipo)
set_property(TARGET c_static_lib PROPERTY INTERPROCEDURAL_OPTIMIZATION ON)
file(WRITE "${CMAKE_BINARY_DIR}/ipo_enabled.txt" "")
endif()

install(TARGETS cxx_exe)

0 comments on commit 62dad8b

Please sign in to comment.