diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2020-12-10 21:08:24 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-12-14 18:13:09 (GMT) |
commit | c9a50f35565dcc1df8bd82126ecced95e60c29e4 (patch) | |
tree | ede35e80def43d76af7378632f05115c0b43bea7 /Source | |
parent | 6aff058ab4a2d54a316dbaa536572ad71efb8b51 (diff) | |
download | CMake-c9a50f35565dcc1df8bd82126ecced95e60c29e4.zip CMake-c9a50f35565dcc1df8bd82126ecced95e60c29e4.tar.gz CMake-c9a50f35565dcc1df8bd82126ecced95e60c29e4.tar.bz2 |
ISPC: Generated Headers suffix configurable with a better default
The target property `ISPC_HEADER_SUFFIX` and associated global
variable now can control the suffix used when generating the
C/C++ interoperability ISPC headers.
In addition the default suffix is now "_ispc.h" which matches the
common convention that the ISPC compiler team uses and recommends.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCoreTryCompile.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 16 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 1 |
5 files changed, 27 insertions, 6 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 77a6d4b..6672aa6 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -201,6 +201,7 @@ std::string const kCMAKE_CUDA_ARCHITECTURES = "CMAKE_CUDA_ARCHITECTURES"; std::string const kCMAKE_CUDA_RUNTIME_LIBRARY = "CMAKE_CUDA_RUNTIME_LIBRARY"; std::string const kCMAKE_ENABLE_EXPORTS = "CMAKE_ENABLE_EXPORTS"; std::string const kCMAKE_ISPC_INSTRUCTION_SETS = "CMAKE_ISPC_INSTRUCTION_SETS"; +std::string const kCMAKE_ISPC_HEADER_SUFFIX = "CMAKE_ISPC_HEADER_SUFFIX"; std::string const kCMAKE_LINK_SEARCH_END_STATIC = "CMAKE_LINK_SEARCH_END_STATIC"; std::string const kCMAKE_LINK_SEARCH_START_STATIC = @@ -718,6 +719,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, vars.insert(kCMAKE_CUDA_RUNTIME_LIBRARY); vars.insert(kCMAKE_ENABLE_EXPORTS); vars.insert(kCMAKE_ISPC_INSTRUCTION_SETS); + vars.insert(kCMAKE_ISPC_HEADER_SUFFIX); vars.insert(kCMAKE_LINK_SEARCH_END_STATIC); vars.insert(kCMAKE_LINK_SEARCH_START_STATIC); vars.insert(kCMAKE_OSX_ARCHITECTURES); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 368f278..884d15d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2426,9 +2426,12 @@ void cmLocalGenerator::AddISPCDependencies(cmGeneratorTarget* target) return; } - std::vector<std::string> ispcSuffixes = + cmProp ispcHeaderSuffixProp = target->GetProperty("ISPC_HEADER_SUFFIX"); + assert(ispcHeaderSuffixProp != nullptr); + + std::vector<std::string> ispcArchSuffixes = detail::ComputeISPCObjectSuffixes(target); - const bool extra_objects = (ispcSuffixes.size() > 1); + const bool extra_objects = (ispcArchSuffixes.size() > 1); std::vector<std::string> configsList = this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); @@ -2451,14 +2454,19 @@ void cmLocalGenerator::AddISPCDependencies(cmGeneratorTarget* target) const std::string& lang = sf->GetLanguage(); if (lang == "ISPC") { std::string const& objectName = target->GetObjectName(sf); + + // Drop both ".obj" and the source file extension std::string ispcSource = cmSystemTools::GetFilenameWithoutLastExtension(objectName); + ispcSource = + cmSystemTools::GetFilenameWithoutLastExtension(ispcSource); - auto headerPath = cmStrCat(headerDir, '/', ispcSource, ".h"); + auto headerPath = + cmStrCat(headerDir, '/', ispcSource, *ispcHeaderSuffixProp); target->AddISPCGeneratedHeader(headerPath, config); if (extra_objects) { std::vector<std::string> objs = detail::ComputeISPCExtraObjects( - objectName, rootObjectDir, ispcSuffixes); + objectName, rootObjectDir, ispcArchSuffixes); target->AddISPCGeneratedObject(std::move(objs), config); } } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 3776fec..c6d6c99 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -591,6 +591,11 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( if (lang == "ISPC") { std::string ispcSource = cmSystemTools::GetFilenameWithoutLastExtension(objectName); + ispcSource = cmSystemTools::GetFilenameWithoutLastExtension(ispcSource); + + cmProp ispcSuffixProp = + this->GeneratorTarget->GetProperty("ISPC_HEADER_SUFFIX"); + assert(ispcSuffixProp != nullptr); std::string directory = this->GeneratorTarget->GetObjectDirectory(config); if (cmProp prop = @@ -598,7 +603,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( directory = cmStrCat(this->LocalGenerator->GetBinaryDirectory(), '/', *prop); } - ispcHeaderRelative = cmStrCat(directory, '/', ispcSource, ".h"); + ispcHeaderRelative = cmStrCat(directory, '/', ispcSource, *ispcSuffixProp); ispcHeaderForShell = this->LocalGenerator->ConvertToOutputFormat( ispcHeaderRelative, cmOutputConverter::SHELL); } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 662399e..d41cbd2 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1374,6 +1374,11 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( this->GeneratorTarget->GetObjectName(source); std::string ispcSource = cmSystemTools::GetFilenameWithoutLastExtension(objectName); + ispcSource = cmSystemTools::GetFilenameWithoutLastExtension(ispcSource); + + cmProp ispcSuffixProp = + this->GeneratorTarget->GetProperty("ISPC_HEADER_SUFFIX"); + assert(ispcSuffixProp != nullptr); std::string ispcHeaderDirectory = this->GeneratorTarget->GetObjectDirectory(config); @@ -1384,7 +1389,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( } std::string ispcHeader = - cmStrCat(ispcHeaderDirectory, '/', ispcSource, ".h"); + cmStrCat(ispcHeaderDirectory, '/', ispcSource, *ispcSuffixProp); ispcHeader = this->ConvertToNinjaPath(ispcHeader); // Make sure ninja knows what command generates the header diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d26de9c..bda2b30 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -369,6 +369,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("JOB_POOL_PRECOMPILE_HEADER"); initProp("ISPC_COMPILER_LAUNCHER"); initProp("ISPC_HEADER_DIRECTORY"); + initPropValue("ISPC_HEADER_SUFFIX", "_ispc.h"); initProp("ISPC_INSTRUCTION_SETS"); initProp("LINK_SEARCH_START_STATIC"); initProp("LINK_SEARCH_END_STATIC"); |