summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx412
1 files changed, 210 insertions, 202 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index a67122c..5311d38 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -12,6 +12,8 @@
#include <string.h>
#include <unordered_set>
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmCustomCommand.h"
#include "cmGeneratorExpression.h"
@@ -86,8 +88,7 @@ const char* cmTargetPropertyComputer::GetSources<cmTarget>(
std::ostringstream ss;
const char* sep = "";
for (std::string const& entry : entries) {
- std::vector<std::string> files;
- cmSystemTools::ExpandListArgument(entry, files);
+ std::vector<std::string> files = cmExpandedList(entry);
for (std::string const& file : files) {
if (cmHasLiteralPrefix(file, "$<TARGET_OBJECTS:") &&
file.back() == '>') {
@@ -168,7 +169,8 @@ public:
cmPropertyMap Properties;
bool IsGeneratorProvided;
bool HaveInstallRule;
- bool DLLPlatform;
+ bool IsDLLPlatform;
+ bool IsAIX;
bool IsAndroid;
bool IsImportedTarget;
bool ImportedGloballyVisible;
@@ -217,7 +219,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
impl->Name = name;
impl->IsGeneratorProvided = false;
impl->HaveInstallRule = false;
- impl->DLLPlatform = false;
+ impl->IsDLLPlatform = false;
+ impl->IsAIX = false;
impl->IsAndroid = false;
impl->IsImportedTarget =
(vis == VisibilityImported || vis == VisibilityImportedGlobally);
@@ -225,21 +228,32 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
impl->BuildInterfaceIncludesAppended = false;
// Check whether this is a DLL platform.
- impl->DLLPlatform =
+ impl->IsDLLPlatform =
!impl->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty();
+ // Check whether we are targeting AIX.
+ impl->IsAIX =
+ (impl->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "AIX");
+
// Check whether we are targeting an Android platform.
impl->IsAndroid =
(impl->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "Android");
- std::string gKey;
- gKey.reserve(128);
- gKey += "CMAKE_";
- auto InitProperty = [this, mf, &gKey](const std::string& property,
- const char* default_value) {
+ std::string defKey;
+ defKey.reserve(128);
+ defKey += "CMAKE_";
+ auto initProp = [this, mf, &defKey](const std::string& property) {
// Replace everything after "CMAKE_"
- gKey.replace(gKey.begin() + 6, gKey.end(), property);
- if (const char* value = mf->GetDefinition(gKey)) {
+ defKey.replace(defKey.begin() + 6, defKey.end(), property);
+ if (const char* value = mf->GetDefinition(defKey)) {
+ this->SetProperty(property, value);
+ }
+ };
+ auto initPropValue = [this, mf, &defKey](const std::string& property,
+ const char* default_value) {
+ // Replace everything after "CMAKE_"
+ defKey.replace(defKey.begin() + 6, defKey.end(), property);
+ if (const char* value = mf->GetDefinition(defKey)) {
this->SetProperty(property, value);
} else if (default_value) {
this->SetProperty(property, default_value);
@@ -249,107 +263,110 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
// Setup default property values.
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
this->GetType() != cmStateEnums::UTILITY) {
- InitProperty("ANDROID_API", nullptr);
- InitProperty("ANDROID_API_MIN", nullptr);
- InitProperty("ANDROID_ARCH", nullptr);
- InitProperty("ANDROID_STL_TYPE", nullptr);
- InitProperty("ANDROID_SKIP_ANT_STEP", nullptr);
- InitProperty("ANDROID_PROCESS_MAX", nullptr);
- InitProperty("ANDROID_PROGUARD", nullptr);
- InitProperty("ANDROID_PROGUARD_CONFIG_PATH", nullptr);
- InitProperty("ANDROID_SECURE_PROPS_PATH", nullptr);
- InitProperty("ANDROID_NATIVE_LIB_DIRECTORIES", nullptr);
- InitProperty("ANDROID_NATIVE_LIB_DEPENDENCIES", nullptr);
- InitProperty("ANDROID_JAVA_SOURCE_DIR", nullptr);
- InitProperty("ANDROID_JAR_DIRECTORIES", nullptr);
- InitProperty("ANDROID_JAR_DEPENDENCIES", nullptr);
- InitProperty("ANDROID_ASSETS_DIRECTORIES", nullptr);
- InitProperty("ANDROID_ANT_ADDITIONAL_OPTIONS", nullptr);
- InitProperty("BUILD_RPATH", nullptr);
- InitProperty("BUILD_RPATH_USE_ORIGIN", nullptr);
- InitProperty("INSTALL_NAME_DIR", nullptr);
- InitProperty("INSTALL_RPATH", "");
- InitProperty("INSTALL_RPATH_USE_LINK_PATH", "OFF");
- InitProperty("INTERPROCEDURAL_OPTIMIZATION", nullptr);
- InitProperty("SKIP_BUILD_RPATH", "OFF");
- InitProperty("BUILD_WITH_INSTALL_RPATH", "OFF");
- InitProperty("ARCHIVE_OUTPUT_DIRECTORY", nullptr);
- InitProperty("LIBRARY_OUTPUT_DIRECTORY", nullptr);
- InitProperty("RUNTIME_OUTPUT_DIRECTORY", nullptr);
- InitProperty("PDB_OUTPUT_DIRECTORY", nullptr);
- InitProperty("COMPILE_PDB_OUTPUT_DIRECTORY", nullptr);
- InitProperty("FRAMEWORK", nullptr);
- InitProperty("Fortran_FORMAT", nullptr);
- InitProperty("Fortran_MODULE_DIRECTORY", nullptr);
- InitProperty("Fortran_COMPILER_LAUNCHER", nullptr);
- InitProperty("GNUtoMS", nullptr);
- InitProperty("OSX_ARCHITECTURES", nullptr);
- InitProperty("IOS_INSTALL_COMBINED", nullptr);
- InitProperty("AUTOMOC", nullptr);
- InitProperty("AUTOUIC", nullptr);
- InitProperty("AUTORCC", nullptr);
- InitProperty("AUTOGEN_ORIGIN_DEPENDS", nullptr);
- InitProperty("AUTOGEN_PARALLEL", nullptr);
- InitProperty("AUTOMOC_COMPILER_PREDEFINES", nullptr);
- InitProperty("AUTOMOC_DEPEND_FILTERS", nullptr);
- InitProperty("AUTOMOC_MACRO_NAMES", nullptr);
- InitProperty("AUTOMOC_MOC_OPTIONS", nullptr);
- InitProperty("AUTOUIC_OPTIONS", nullptr);
- InitProperty("AUTOUIC_SEARCH_PATHS", nullptr);
- InitProperty("AUTORCC_OPTIONS", nullptr);
- InitProperty("LINK_DEPENDS_NO_SHARED", nullptr);
- InitProperty("LINK_INTERFACE_LIBRARIES", nullptr);
- InitProperty("MSVC_RUNTIME_LIBRARY", nullptr);
- InitProperty("WIN32_EXECUTABLE", nullptr);
- InitProperty("MACOSX_BUNDLE", nullptr);
- InitProperty("MACOSX_RPATH", nullptr);
- InitProperty("NO_SYSTEM_FROM_IMPORTED", nullptr);
- InitProperty("BUILD_WITH_INSTALL_NAME_DIR", nullptr);
- InitProperty("C_CLANG_TIDY", nullptr);
- InitProperty("C_COMPILER_LAUNCHER", nullptr);
- InitProperty("C_CPPLINT", nullptr);
- InitProperty("C_CPPCHECK", nullptr);
- InitProperty("C_INCLUDE_WHAT_YOU_USE", nullptr);
- InitProperty("LINK_WHAT_YOU_USE", nullptr);
- InitProperty("C_STANDARD", nullptr);
- InitProperty("C_STANDARD_REQUIRED", nullptr);
- InitProperty("C_EXTENSIONS", nullptr);
- InitProperty("CXX_CLANG_TIDY", nullptr);
- InitProperty("CXX_COMPILER_LAUNCHER", nullptr);
- InitProperty("CXX_CPPLINT", nullptr);
- InitProperty("CXX_CPPCHECK", nullptr);
- InitProperty("CXX_INCLUDE_WHAT_YOU_USE", nullptr);
- InitProperty("CXX_STANDARD", nullptr);
- InitProperty("CXX_STANDARD_REQUIRED", nullptr);
- InitProperty("CXX_EXTENSIONS", nullptr);
- InitProperty("CUDA_STANDARD", nullptr);
- InitProperty("CUDA_STANDARD_REQUIRED", nullptr);
- InitProperty("CUDA_EXTENSIONS", nullptr);
- InitProperty("CUDA_COMPILER_LAUNCHER", nullptr);
- InitProperty("CUDA_SEPARABLE_COMPILATION", nullptr);
- InitProperty("LINK_SEARCH_START_STATIC", nullptr);
- InitProperty("LINK_SEARCH_END_STATIC", nullptr);
- InitProperty("FOLDER", nullptr);
- InitProperty("Swift_MODULE_DIRECTORY", nullptr);
- InitProperty("VS_JUST_MY_CODE_DEBUGGING", nullptr);
+ initProp("ANDROID_API");
+ initProp("ANDROID_API_MIN");
+ initProp("ANDROID_ARCH");
+ initProp("ANDROID_STL_TYPE");
+ initProp("ANDROID_SKIP_ANT_STEP");
+ initProp("ANDROID_PROCESS_MAX");
+ initProp("ANDROID_PROGUARD");
+ initProp("ANDROID_PROGUARD_CONFIG_PATH");
+ initProp("ANDROID_SECURE_PROPS_PATH");
+ initProp("ANDROID_NATIVE_LIB_DIRECTORIES");
+ initProp("ANDROID_NATIVE_LIB_DEPENDENCIES");
+ initProp("ANDROID_JAVA_SOURCE_DIR");
+ initProp("ANDROID_JAR_DIRECTORIES");
+ initProp("ANDROID_JAR_DEPENDENCIES");
+ initProp("ANDROID_ASSETS_DIRECTORIES");
+ initProp("ANDROID_ANT_ADDITIONAL_OPTIONS");
+ initProp("BUILD_RPATH");
+ initProp("BUILD_RPATH_USE_ORIGIN");
+ initProp("INSTALL_NAME_DIR");
+ initProp("INSTALL_REMOVE_ENVIRONMENT_RPATH");
+ initPropValue("INSTALL_RPATH", "");
+ initPropValue("INSTALL_RPATH_USE_LINK_PATH", "OFF");
+ initProp("INTERPROCEDURAL_OPTIMIZATION");
+ initPropValue("SKIP_BUILD_RPATH", "OFF");
+ initPropValue("BUILD_WITH_INSTALL_RPATH", "OFF");
+ initProp("ARCHIVE_OUTPUT_DIRECTORY");
+ initProp("LIBRARY_OUTPUT_DIRECTORY");
+ initProp("RUNTIME_OUTPUT_DIRECTORY");
+ initProp("PDB_OUTPUT_DIRECTORY");
+ initProp("COMPILE_PDB_OUTPUT_DIRECTORY");
+ initProp("FRAMEWORK");
+ initProp("Fortran_FORMAT");
+ initProp("Fortran_MODULE_DIRECTORY");
+ initProp("Fortran_COMPILER_LAUNCHER");
+ initProp("GNUtoMS");
+ initProp("OSX_ARCHITECTURES");
+ initProp("IOS_INSTALL_COMBINED");
+ initProp("AUTOMOC");
+ initProp("AUTOUIC");
+ initProp("AUTORCC");
+ initProp("AUTOGEN_ORIGIN_DEPENDS");
+ initProp("AUTOGEN_PARALLEL");
+ initProp("AUTOMOC_COMPILER_PREDEFINES");
+ initProp("AUTOMOC_DEPEND_FILTERS");
+ initProp("AUTOMOC_MACRO_NAMES");
+ initProp("AUTOMOC_MOC_OPTIONS");
+ initProp("AUTOUIC_OPTIONS");
+ initProp("AUTOUIC_SEARCH_PATHS");
+ initProp("AUTORCC_OPTIONS");
+ initProp("LINK_DEPENDS_NO_SHARED");
+ initProp("LINK_INTERFACE_LIBRARIES");
+ initProp("MSVC_RUNTIME_LIBRARY");
+ initProp("WIN32_EXECUTABLE");
+ initProp("MACOSX_BUNDLE");
+ initProp("MACOSX_RPATH");
+ initProp("NO_SYSTEM_FROM_IMPORTED");
+ initProp("BUILD_WITH_INSTALL_NAME_DIR");
+ initProp("C_CLANG_TIDY");
+ initProp("C_COMPILER_LAUNCHER");
+ initProp("C_CPPLINT");
+ initProp("C_CPPCHECK");
+ initProp("C_INCLUDE_WHAT_YOU_USE");
+ initProp("LINK_WHAT_YOU_USE");
+ initProp("C_STANDARD");
+ initProp("C_STANDARD_REQUIRED");
+ initProp("C_EXTENSIONS");
+ initProp("CXX_CLANG_TIDY");
+ initProp("CXX_COMPILER_LAUNCHER");
+ initProp("CXX_CPPLINT");
+ initProp("CXX_CPPCHECK");
+ initProp("CXX_INCLUDE_WHAT_YOU_USE");
+ initProp("CXX_STANDARD");
+ initProp("CXX_STANDARD_REQUIRED");
+ initProp("CXX_EXTENSIONS");
+ initProp("CUDA_STANDARD");
+ initProp("CUDA_STANDARD_REQUIRED");
+ initProp("CUDA_EXTENSIONS");
+ initProp("CUDA_COMPILER_LAUNCHER");
+ initProp("CUDA_SEPARABLE_COMPILATION");
+ initProp("CUDA_RESOLVE_DEVICE_SYMBOLS");
+ initProp("LINK_SEARCH_START_STATIC");
+ initProp("LINK_SEARCH_END_STATIC");
+ initProp("FOLDER");
+ initProp("Swift_LANGUAGE_VERSION");
+ initProp("Swift_MODULE_DIRECTORY");
+ initProp("VS_JUST_MY_CODE_DEBUGGING");
#ifdef __APPLE__
if (this->GetGlobalGenerator()->IsXcode()) {
- InitProperty("XCODE_GENERATE_SCHEME", nullptr);
- InitProperty("XCODE_SCHEME_ADDRESS_SANITIZER", nullptr);
- InitProperty("XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN", nullptr);
- InitProperty("XCODE_SCHEME_THREAD_SANITIZER", nullptr);
- InitProperty("XCODE_SCHEME_THREAD_SANITIZER_STOP", nullptr);
- InitProperty("XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER", nullptr);
- InitProperty("XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP", nullptr);
- InitProperty("XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER", nullptr);
- InitProperty("XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP", nullptr);
- InitProperty("XCODE_SCHEME_MALLOC_SCRIBBLE", nullptr);
- InitProperty("XCODE_SCHEME_MALLOC_GUARD_EDGES", nullptr);
- InitProperty("XCODE_SCHEME_GUARD_MALLOC", nullptr);
- InitProperty("XCODE_SCHEME_ZOMBIE_OBJECTS", nullptr);
- InitProperty("XCODE_SCHEME_MALLOC_STACK", nullptr);
- InitProperty("XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE", nullptr);
- InitProperty("XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS", nullptr);
+ initProp("XCODE_GENERATE_SCHEME");
+ initProp("XCODE_SCHEME_ADDRESS_SANITIZER");
+ initProp("XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN");
+ initProp("XCODE_SCHEME_THREAD_SANITIZER");
+ initProp("XCODE_SCHEME_THREAD_SANITIZER_STOP");
+ initProp("XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER");
+ initProp("XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP");
+ initProp("XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER");
+ initProp("XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP");
+ initProp("XCODE_SCHEME_MALLOC_SCRIBBLE");
+ initProp("XCODE_SCHEME_MALLOC_GUARD_EDGES");
+ initProp("XCODE_SCHEME_GUARD_MALLOC");
+ initProp("XCODE_SCHEME_ZOMBIE_OBJECTS");
+ initProp("XCODE_SCHEME_MALLOC_STACK");
+ initProp("XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE");
+ initProp("XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS");
}
#endif
}
@@ -375,9 +392,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
strcmp(prop, "MAP_IMPORTED_CONFIG_") != 0) {
continue;
}
- std::string property = prop;
- property += configUpper;
- InitProperty(property, nullptr);
+ std::string property = cmStrCat(prop, configUpper);
+ initProp(property);
}
// Initialize per-configuration name postfix property from the
@@ -387,9 +403,9 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
// property directly.
if (impl->TargetType != cmStateEnums::EXECUTABLE &&
impl->TargetType != cmStateEnums::INTERFACE_LIBRARY) {
- std::string property = cmSystemTools::UpperCase(configName);
- property += "_POSTFIX";
- InitProperty(property, nullptr);
+ std::string property =
+ cmStrCat(cmSystemTools::UpperCase(configName), "_POSTFIX");
+ initProp(property);
}
}
}
@@ -428,16 +444,16 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
this->GetType() != cmStateEnums::UTILITY) {
- InitProperty("C_VISIBILITY_PRESET", nullptr);
- InitProperty("CXX_VISIBILITY_PRESET", nullptr);
- InitProperty("CUDA_VISIBILITY_PRESET", nullptr);
- InitProperty("VISIBILITY_INLINES_HIDDEN", nullptr);
+ initProp("C_VISIBILITY_PRESET");
+ initProp("CXX_VISIBILITY_PRESET");
+ initProp("CUDA_VISIBILITY_PRESET");
+ initProp("VISIBILITY_INLINES_HIDDEN");
}
if (impl->TargetType == cmStateEnums::EXECUTABLE) {
- InitProperty("ANDROID_GUI", nullptr);
- InitProperty("CROSSCOMPILING_EMULATOR", nullptr);
- InitProperty("ENABLE_EXPORTS", nullptr);
+ initProp("ANDROID_GUI");
+ initProp("CROSSCOMPILING_EMULATOR");
+ initProp("ENABLE_EXPORTS");
}
if (impl->TargetType == cmStateEnums::SHARED_LIBRARY ||
impl->TargetType == cmStateEnums::MODULE_LIBRARY) {
@@ -445,12 +461,12 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
}
if (impl->TargetType == cmStateEnums::SHARED_LIBRARY ||
impl->TargetType == cmStateEnums::EXECUTABLE) {
- InitProperty("WINDOWS_EXPORT_ALL_SYMBOLS", nullptr);
+ initProp("WINDOWS_EXPORT_ALL_SYMBOLS");
}
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
this->GetType() != cmStateEnums::UTILITY) {
- InitProperty("POSITION_INDEPENDENT_CODE", nullptr);
+ initProp("POSITION_INDEPENDENT_CODE");
}
// Record current policies for later use.
@@ -466,12 +482,12 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
this->GetType() != cmStateEnums::UTILITY) {
- InitProperty("JOB_POOL_COMPILE", nullptr);
- InitProperty("JOB_POOL_LINK", nullptr);
+ initProp("JOB_POOL_COMPILE");
+ initProp("JOB_POOL_LINK");
}
if (impl->TargetType <= cmStateEnums::UTILITY) {
- InitProperty("DOTNET_TARGET_FRAMEWORK_VERSION", nullptr);
+ initProp("DOTNET_TARGET_FRAMEWORK_VERSION");
}
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
@@ -483,8 +499,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
if (globals) {
const std::string genName = mf->GetGlobalGenerator()->GetName();
if (cmHasLiteralPrefix(genName, "Visual Studio")) {
- std::vector<std::string> props;
- cmSystemTools::ExpandListArgument(globals, props);
+ std::vector<std::string> props = cmExpandedList(globals);
const std::string vsGlobal = "VS_GLOBAL_";
for (const std::string& i : props) {
// split NAME=VALUE
@@ -492,7 +507,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
if (assignment != std::string::npos) {
const std::string propName = vsGlobal + i.substr(0, assignment);
const std::string propValue = i.substr(assignment + 1);
- InitProperty(propName, propValue.c_str());
+ initPropValue(propName, propValue.c_str());
}
}
}
@@ -726,8 +741,7 @@ public:
bool operator()(std::string const& entry)
{
- std::vector<std::string> files;
- cmSystemTools::ExpandListArgument(entry, files);
+ std::vector<std::string> files = cmExpandedList(entry);
std::vector<cmSourceFileLocation> locations;
locations.reserve(files.size());
std::transform(files.begin(), files.end(), std::back_inserter(locations),
@@ -761,8 +775,7 @@ cmSourceFile* cmTarget::AddSource(const std::string& src, bool before)
void cmTarget::ClearDependencyInformation(cmMakefile& mf)
{
- std::string depname = this->GetName();
- depname += "_LIB_DEPENDS";
+ std::string depname = cmStrCat(this->GetName(), "_LIB_DEPENDS");
mf.RemoveCacheDefinition(depname);
}
@@ -930,8 +943,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, std::string const& lib,
impl->TargetType <= cmStateEnums::MODULE_LIBRARY &&
(this->GetPolicyStatusCMP0073() == cmPolicies::OLD ||
this->GetPolicyStatusCMP0073() == cmPolicies::WARN)) {
- std::string targetEntry = impl->Name;
- targetEntry += "_LIB_DEPENDS";
+ std::string targetEntry = cmStrCat(impl->Name, "_LIB_DEPENDS");
std::string dependencies;
const char* old_val = mf.GetDefinition(targetEntry);
if (old_val) {
@@ -1070,21 +1082,19 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
MAKE_STATIC_PROP(TYPE);
#undef MAKE_STATIC_PROP
if (prop == propMANUALLY_ADDED_DEPENDENCIES) {
- std::ostringstream e;
- e << "MANUALLY_ADDED_DEPENDENCIES property is read-only\n";
- impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ impl->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ "MANUALLY_ADDED_DEPENDENCIES property is read-only\n");
return;
}
if (prop == propNAME) {
- std::ostringstream e;
- e << "NAME property is read-only\n";
- impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR,
+ "NAME property is read-only\n");
return;
}
if (prop == propTYPE) {
- std::ostringstream e;
- e << "TYPE property is read-only\n";
- impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR,
+ "TYPE property is read-only\n");
return;
}
if (prop == propEXPORT_NAME && this->IsImported()) {
@@ -1174,7 +1184,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
impl->SourceBacktraces.push_back(lfbt);
}
} else if (prop == propIMPORTED_GLOBAL) {
- if (!cmSystemTools::IsOn(value)) {
+ if (!cmIsOn(value)) {
std::ostringstream e;
e << "IMPORTED_GLOBAL property can't be set to FALSE on targets (\""
<< impl->Name << "\")\n";
@@ -1211,9 +1221,8 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
return;
}
if (prop == "NAME") {
- std::ostringstream e;
- e << "NAME property is read-only\n";
- impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR,
+ "NAME property is read-only\n");
return;
}
if (prop == "EXPORT_NAME" && this->IsImported()) {
@@ -1496,7 +1505,6 @@ const char* cmTarget::GetComputedProperty(
const char* cmTarget::GetProperty(const std::string& prop) const
{
- static std::unordered_set<std::string> specialProps;
#define MAKE_STATIC_PROP(PROP) static const std::string prop##PROP = #PROP
MAKE_STATIC_PROP(LINK_LIBRARIES);
MAKE_STATIC_PROP(TYPE);
@@ -1514,23 +1522,23 @@ const char* cmTarget::GetProperty(const std::string& prop) const
MAKE_STATIC_PROP(SOURCE_DIR);
MAKE_STATIC_PROP(SOURCES);
#undef MAKE_STATIC_PROP
- if (specialProps.empty()) {
- specialProps.insert(propLINK_LIBRARIES);
- specialProps.insert(propTYPE);
- specialProps.insert(propINCLUDE_DIRECTORIES);
- specialProps.insert(propCOMPILE_FEATURES);
- specialProps.insert(propCOMPILE_OPTIONS);
- specialProps.insert(propCOMPILE_DEFINITIONS);
- specialProps.insert(propLINK_OPTIONS);
- specialProps.insert(propLINK_DIRECTORIES);
- specialProps.insert(propIMPORTED);
- specialProps.insert(propIMPORTED_GLOBAL);
- specialProps.insert(propMANUALLY_ADDED_DEPENDENCIES);
- specialProps.insert(propNAME);
- specialProps.insert(propBINARY_DIR);
- specialProps.insert(propSOURCE_DIR);
- specialProps.insert(propSOURCES);
- }
+ static std::unordered_set<std::string> const specialProps{
+ propLINK_LIBRARIES,
+ propTYPE,
+ propINCLUDE_DIRECTORIES,
+ propCOMPILE_FEATURES,
+ propCOMPILE_OPTIONS,
+ propCOMPILE_DEFINITIONS,
+ propLINK_OPTIONS,
+ propLINK_DIRECTORIES,
+ propIMPORTED,
+ propIMPORTED_GLOBAL,
+ propMANUALLY_ADDED_DEPENDENCIES,
+ propNAME,
+ propBINARY_DIR,
+ propSOURCE_DIR,
+ propSOURCES
+ };
if (specialProps.count(prop)) {
if (prop == propLINK_LIBRARIES) {
if (impl->LinkImplementationPropertyEntries.empty()) {
@@ -1655,7 +1663,7 @@ const char* cmTarget::GetSafeProperty(const std::string& prop) const
bool cmTarget::GetPropertyAsBool(const std::string& prop) const
{
- return cmSystemTools::IsOn(this->GetProperty(prop));
+ return cmIsOn(this->GetProperty(prop));
}
cmPropertyMap const& cmTarget::GetProperties() const
@@ -1663,6 +1671,16 @@ cmPropertyMap const& cmTarget::GetProperties() const
return impl->Properties;
}
+bool cmTarget::IsDLLPlatform() const
+{
+ return impl->IsDLLPlatform;
+}
+
+bool cmTarget::IsAIX() const
+{
+ return impl->IsAIX;
+}
+
bool cmTarget::IsImported() const
{
return impl->IsImportedTarget;
@@ -1704,7 +1722,8 @@ const char* cmTarget::GetSuffixVariableInternal(
? "CMAKE_SHARED_LIBRARY_SUFFIX"
: "CMAKE_EXECUTABLE_SUFFIX");
case cmStateEnums::ImportLibraryArtifact:
- return "CMAKE_IMPORT_LIBRARY_SUFFIX";
+ return (impl->IsAIX ? "CMAKE_AIX_IMPORT_FILE_SUFFIX"
+ : "CMAKE_IMPORT_LIBRARY_SUFFIX");
}
break;
default:
@@ -1744,7 +1763,8 @@ const char* cmTarget::GetPrefixVariableInternal(
? "CMAKE_SHARED_LIBRARY_PREFIX"
: "");
case cmStateEnums::ImportLibraryArtifact:
- return "CMAKE_IMPORT_LIBRARY_PREFIX";
+ return (impl->IsAIX ? "CMAKE_AIX_IMPORT_FILE_PREFIX"
+ : "CMAKE_IMPORT_LIBRARY_PREFIX");
}
break;
default:
@@ -1778,8 +1798,7 @@ std::string cmTarget::ImportedGetFullPath(
if (loc) {
result = loc;
} else {
- std::string impProp = "IMPORTED_LOCATION";
- impProp += suffix;
+ std::string impProp = cmStrCat("IMPORTED_LOCATION", suffix);
if (const char* config_location = this->GetProperty(impProp)) {
result = config_location;
} else if (const char* location =
@@ -1794,8 +1813,7 @@ std::string cmTarget::ImportedGetFullPath(
result = imp;
} else if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->IsExecutableWithExports()) {
- std::string impProp = "IMPORTED_IMPLIB";
- impProp += suffix;
+ std::string impProp = cmStrCat("IMPORTED_IMPLIB", suffix);
if (const char* config_implib = this->GetProperty(impProp)) {
result = config_implib;
} else if (const char* implib =
@@ -1808,8 +1826,7 @@ std::string cmTarget::ImportedGetFullPath(
}
if (result.empty()) {
- result = this->GetName();
- result += "-NOTFOUND";
+ result = cmStrCat(this->GetName(), "-NOTFOUND");
}
return result;
}
@@ -1863,24 +1880,23 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
}
// Track the configuration-specific property suffix.
- suffix = "_";
- suffix += config_upper;
+ suffix = cmStrCat('_', config_upper);
std::vector<std::string> mappedConfigs;
{
- std::string mapProp = "MAP_IMPORTED_CONFIG_";
- mapProp += config_upper;
+ std::string mapProp = cmStrCat("MAP_IMPORTED_CONFIG_", config_upper);
if (const char* mapValue = this->GetProperty(mapProp)) {
- cmSystemTools::ExpandListArgument(mapValue, mappedConfigs, true);
+ cmExpandList(mapValue, mappedConfigs, true);
}
}
// If we needed to find one of the mapped configurations but did not
// On a DLL platform there may be only IMPORTED_IMPLIB for a shared
// library or an executable with exports.
- bool allowImp = (impl->DLLPlatform &&
+ bool allowImp = (this->IsDLLPlatform() &&
(this->GetType() == cmStateEnums::SHARED_LIBRARY ||
- this->IsExecutableWithExports()));
+ this->IsExecutableWithExports())) ||
+ (this->IsAIX() && this->IsExecutableWithExports());
// If a mapping was found, check its configurations.
for (std::vector<std::string>::const_iterator mci = mappedConfigs.begin();
@@ -1899,19 +1915,16 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
}
} else {
std::string mcUpper = cmSystemTools::UpperCase(*mci);
- std::string locProp = locPropBase + "_";
- locProp += mcUpper;
+ std::string locProp = cmStrCat(locPropBase, '_', mcUpper);
*loc = this->GetProperty(locProp);
if (allowImp) {
- std::string impProp = "IMPORTED_IMPLIB_";
- impProp += mcUpper;
+ std::string impProp = cmStrCat("IMPORTED_IMPLIB_", mcUpper);
*imp = this->GetProperty(impProp);
}
// If it was found, use it for all properties below.
if (*loc || *imp) {
- suffix = "_";
- suffix += mcUpper;
+ suffix = cmStrCat('_', mcUpper);
}
}
}
@@ -1928,12 +1941,10 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
// If we have not yet found it then there are no mapped
// configurations. Look for an exact-match.
if (!*loc && !*imp) {
- std::string locProp = locPropBase;
- locProp += suffix;
+ std::string locProp = cmStrCat(locPropBase, suffix);
*loc = this->GetProperty(locProp);
if (allowImp) {
- std::string impProp = "IMPORTED_IMPLIB";
- impProp += suffix;
+ std::string impProp = cmStrCat("IMPORTED_IMPLIB", suffix);
*imp = this->GetProperty(impProp);
}
}
@@ -1957,19 +1968,16 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
if (!*loc && !*imp) {
std::vector<std::string> availableConfigs;
if (const char* iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS")) {
- cmSystemTools::ExpandListArgument(iconfigs, availableConfigs);
+ cmExpandList(iconfigs, availableConfigs);
}
for (std::vector<std::string>::const_iterator aci =
availableConfigs.begin();
!*loc && !*imp && aci != availableConfigs.end(); ++aci) {
- suffix = "_";
- suffix += cmSystemTools::UpperCase(*aci);
- std::string locProp = locPropBase;
- locProp += suffix;
+ suffix = cmStrCat('_', cmSystemTools::UpperCase(*aci));
+ std::string locProp = cmStrCat(locPropBase, suffix);
*loc = this->GetProperty(locProp);
if (allowImp) {
- std::string impProp = "IMPORTED_IMPLIB";
- impProp += suffix;
+ std::string impProp = cmStrCat("IMPORTED_IMPLIB", suffix);
*imp = this->GetProperty(impProp);
}
}