Commit 2428422c authored by Brad King's avatar Brad King
Browse files

Fix regression in target output file naming logic

Refactoring in commit f4ff60a8

 (cmMakefile: Make GetSafeDefinition
return std::string const&, 2018-09-05) accidentally changed the logic
for target artifact prefix and suffix names such that setting a PREFIX
or SUFFIX target property would cause an empty value to be used.  Revert
that part of the change and use a simpler alternative.  Add a test case.
Reported-by: Alan W. Irwin's avatarAlan W. Irwin <irwin@beluga.phys.uvic.ca>
parent d686f81e
...@@ -3488,13 +3488,12 @@ void cmGeneratorTarget::GetFullNameInternal( ...@@ -3488,13 +3488,12 @@ void cmGeneratorTarget::GetFullNameInternal(
} }
// if there is no prefix on the target use the cmake definition // if there is no prefix on the target use the cmake definition
std::string targetPrefix2, targetSuffix2;
if (!targetPrefix && prefixVar) { if (!targetPrefix && prefixVar) {
targetPrefix2 = this->Makefile->GetSafeDefinition(prefixVar); targetPrefix = this->Makefile->GetSafeDefinition(prefixVar).c_str();
} }
// if there is no suffix on the target use the cmake definition // if there is no suffix on the target use the cmake definition
if (!targetSuffix && suffixVar) { if (!targetSuffix && suffixVar) {
targetSuffix2 = this->Makefile->GetSafeDefinition(suffixVar); targetSuffix = this->Makefile->GetSafeDefinition(suffixVar).c_str();
} }
// frameworks have directory prefix but no suffix // frameworks have directory prefix but no suffix
...@@ -3502,19 +3501,19 @@ void cmGeneratorTarget::GetFullNameInternal( ...@@ -3502,19 +3501,19 @@ void cmGeneratorTarget::GetFullNameInternal(
if (this->IsFrameworkOnApple()) { if (this->IsFrameworkOnApple()) {
fw_prefix = this->GetFrameworkDirectory(config, ContentLevel); fw_prefix = this->GetFrameworkDirectory(config, ContentLevel);
fw_prefix += "/"; fw_prefix += "/";
targetPrefix2 = fw_prefix; targetPrefix = fw_prefix.c_str();
targetSuffix2.clear(); targetSuffix = nullptr;
} }
if (this->IsCFBundleOnApple()) { if (this->IsCFBundleOnApple()) {
fw_prefix = this->GetCFBundleDirectory(config, FullLevel); fw_prefix = this->GetCFBundleDirectory(config, FullLevel);
fw_prefix += "/"; fw_prefix += "/";
targetPrefix2 = fw_prefix; targetPrefix = fw_prefix.c_str();
targetSuffix2.clear(); targetSuffix = nullptr;
} }
// Begin the final name with the prefix. // Begin the final name with the prefix.
outPrefix = targetPrefix2; outPrefix = targetPrefix ? targetPrefix : "";
// Append the target name or property-specified name. // Append the target name or property-specified name.
outBase += this->GetOutputName(config, artifact); outBase += this->GetOutputName(config, artifact);
...@@ -3533,7 +3532,7 @@ void cmGeneratorTarget::GetFullNameInternal( ...@@ -3533,7 +3532,7 @@ void cmGeneratorTarget::GetFullNameInternal(
} }
// Append the suffix. // Append the suffix.
outSuffix = targetSuffix2; outSuffix = targetSuffix ? targetSuffix : "";
} }
std::string cmGeneratorTarget::GetLinkerLanguage( std::string cmGeneratorTarget::GetLinkerLanguage(
......
...@@ -368,6 +368,7 @@ if(BUILD_TESTING) ...@@ -368,6 +368,7 @@ if(BUILD_TESTING)
ADD_TEST_MACRO(CxxSubdirC CxxSubdirC) ADD_TEST_MACRO(CxxSubdirC CxxSubdirC)
ADD_TEST_MACRO(IPO COnly/COnly) ADD_TEST_MACRO(IPO COnly/COnly)
ADD_TEST_MACRO(OutDir runtime/OutDir) ADD_TEST_MACRO(OutDir runtime/OutDir)
ADD_TEST_MACRO(OutName exe.OutName.exe)
ADD_TEST_MACRO(ObjectLibrary UseCshared) ADD_TEST_MACRO(ObjectLibrary UseCshared)
ADD_TEST_MACRO(NewlineArgs NewlineArgs) ADD_TEST_MACRO(NewlineArgs NewlineArgs)
ADD_TEST_MACRO(SetLang SetLang) ADD_TEST_MACRO(SetLang SetLang)
......
cmake_minimum_required(VERSION 3.12)
project(OutName C)
add_executable(OutName main.c)
set_property(TARGET OutName PROPERTY PREFIX exe.)
set_property(TARGET OutName PROPERTY SUFFIX .exe)
int main(void)
{
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment