MCPcopy Create free account
hub / github.com/Kitware/CMake / GetFilePrefixInternal

Method GetFilePrefixInternal

Source/cmGeneratorTarget.cxx:432–481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432cmValue cmGeneratorTarget::GetFilePrefixInternal(
433 std::string const& config, cmStateEnums::ArtifactType artifact,
434 std::string const& language) const
435{
436 // no prefix for non-main target types.
437 if (this->GetType() != cmStateEnums::STATIC_LIBRARY &&
438 this->GetType() != cmStateEnums::SHARED_LIBRARY &&
439 this->GetType() != cmStateEnums::MODULE_LIBRARY &&
440 this->GetType() != cmStateEnums::EXECUTABLE) {
441 return nullptr;
442 }
443
444 bool const isImportedLibraryArtifact =
445 (artifact == cmStateEnums::ImportLibraryArtifact);
446
447 // Return an empty prefix for the import library if this platform
448 // does not support import libraries.
449 if (isImportedLibraryArtifact && !this->NeedImportLibraryName(config)) {
450 return nullptr;
451 }
452
453 // The implib option is only allowed for shared libraries, module
454 // libraries, and executables.
455 if (this->GetType() != cmStateEnums::SHARED_LIBRARY &&
456 this->GetType() != cmStateEnums::MODULE_LIBRARY &&
457 this->GetType() != cmStateEnums::EXECUTABLE) {
458 artifact = cmStateEnums::RuntimeBinaryArtifact;
459 }
460
461 // Compute prefix value.
462 cmValue targetPrefix =
463 (isImportedLibraryArtifact ? this->GetProperty("IMPORT_PREFIX")
464 : this->GetProperty("PREFIX"));
465
466 if (!targetPrefix) {
467 char const* prefixVar = this->Target->GetPrefixVariableInternal(artifact);
468 if (!language.empty() && cmNonempty(prefixVar)) {
469 std::string langPrefix = cmStrCat(prefixVar, '_', language);
470 targetPrefix = this->Makefile->GetDefinition(langPrefix);
471 }
472
473 // if there is no prefix on the target nor specific language
474 // use the cmake definition.
475 if (!targetPrefix && prefixVar) {
476 targetPrefix = this->Makefile->GetDefinition(prefixVar);
477 }
478 }
479
480 return targetPrefix;
481}
482
483cmValue cmGeneratorTarget::GetFileSuffixInternal(
484 std::string const& config, cmStateEnums::ArtifactType artifact,

Callers 2

GetFilePrefixMethod · 0.95

Calls 8

GetTypeMethod · 0.95
NeedImportLibraryNameMethod · 0.95
GetPropertyMethod · 0.95
cmNonemptyFunction · 0.85
cmStrCatFunction · 0.70
emptyMethod · 0.45
GetDefinitionMethod · 0.45

Tested by

no test coverage detected