diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2020-12-07 14:14:54 (GMT) |
---|---|---|
committer | Robert Maynard <robert.maynard@kitware.com> | 2020-12-07 14:14:54 (GMT) |
commit | 9af93fef11e9ea23d7d87a1c217254c482555262 (patch) | |
tree | 4a728838b1784604c14464187db7675fcfcad34a /Source/cmLocalGenerator.cxx | |
parent | 72ae15ebcb6061623b8a4a7119ddb49154e83094 (diff) | |
download | CMake-9af93fef11e9ea23d7d87a1c217254c482555262.zip CMake-9af93fef11e9ea23d7d87a1c217254c482555262.tar.gz CMake-9af93fef11e9ea23d7d87a1c217254c482555262.tar.bz2 |
ISPC: Handle OBJECT sources in different directories
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 4e6010c..73e5431 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2434,9 +2434,10 @@ void cmLocalGenerator::AddISPCDependencies(cmGeneratorTarget* target) this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); for (std::string const& config : configsList) { - std::string perConfigDir = target->GetObjectDirectory(config); + std::string rootObjectDir = target->GetObjectDirectory(config); + std::string headerDir = rootObjectDir; if (cmProp prop = target->GetProperty("ISPC_HEADER_DIRECTORY")) { - perConfigDir = cmSystemTools::CollapseFullPath( + headerDir = cmSystemTools::CollapseFullPath( cmStrCat(this->GetBinaryDirectory(), '/', *prop)); } @@ -2453,11 +2454,11 @@ void cmLocalGenerator::AddISPCDependencies(cmGeneratorTarget* target) std::string ispcSource = cmSystemTools::GetFilenameWithoutLastExtension(objectName); - auto headerPath = cmStrCat(perConfigDir, '/', ispcSource, ".h"); + auto headerPath = cmStrCat(headerDir, '/', ispcSource, ".h"); target->AddISPCGeneratedHeader(headerPath, config); if (extra_objects) { std::vector<std::string> objs = detail::ComputeISPCExtraObjects( - objectName, perConfigDir, ispcSuffixes); + objectName, rootObjectDir, ispcSuffixes); target->AddISPCGeneratedObject(std::move(objs), config); } } @@ -4074,15 +4075,23 @@ std::vector<std::string> ComputeISPCExtraObjects( std::string const& objectName, std::string const& buildDirectory, std::vector<std::string> const& ispcSuffixes) { + auto normalizedDir = cmSystemTools::CollapseFullPath(buildDirectory); std::vector<std::string> computedObjects; computedObjects.reserve(ispcSuffixes.size()); auto extension = cmSystemTools::GetFilenameLastExtension(objectName); - auto objNameNoExt = - cmSystemTools::GetFilenameWithoutLastExtension(objectName); + + // We can't use cmSystemTools::GetFilenameWithoutLastExtension as it + // drops any directories in objectName + auto objNameNoExt = objectName; + std::string::size_type dot_pos = objectName.rfind('.'); + if (dot_pos != std::string::npos) { + objNameNoExt.resize(dot_pos); + } + for (const auto& ispcTarget : ispcSuffixes) { computedObjects.emplace_back( - cmStrCat(buildDirectory, "/", objNameNoExt, "_", ispcTarget, extension)); + cmStrCat(normalizedDir, "/", objNameNoExt, "_", ispcTarget, extension)); } return computedObjects; |