Merge topic 'empty-LINK_LIBRARIES'

7aa9e80e set_property: Fix crash when setting LINK_LIBRARIES to nothing
This commit is contained in:
Brad King 2015-07-09 09:17:17 -04:00 committed by CMake Topic Stage
commit 6b4fccd1a6
5 changed files with 26 additions and 6 deletions

View File

@ -1739,9 +1739,12 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
else if (prop == "LINK_LIBRARIES") else if (prop == "LINK_LIBRARIES")
{ {
this->Internal->LinkImplementationPropertyEntries.clear(); this->Internal->LinkImplementationPropertyEntries.clear();
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); if (value)
cmValueWithOrigin entry(value, lfbt); {
this->Internal->LinkImplementationPropertyEntries.push_back(entry); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmValueWithOrigin entry(value, lfbt);
this->Internal->LinkImplementationPropertyEntries.push_back(entry);
}
} }
else if (prop == "SOURCES") else if (prop == "SOURCES")
{ {
@ -1825,9 +1828,12 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
} }
else if (prop == "LINK_LIBRARIES") else if (prop == "LINK_LIBRARIES")
{ {
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); if (value)
cmValueWithOrigin entry(value, lfbt); {
this->Internal->LinkImplementationPropertyEntries.push_back(entry); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmValueWithOrigin entry(value, lfbt);
this->Internal->LinkImplementationPropertyEntries.push_back(entry);
}
} }
else if (prop == "SOURCES") else if (prop == "SOURCES")
{ {

View File

@ -185,6 +185,7 @@ add_RunCMake_test(list)
add_RunCMake_test(message) add_RunCMake_test(message)
add_RunCMake_test(project) add_RunCMake_test(project)
add_RunCMake_test(return) add_RunCMake_test(return)
add_RunCMake_test(set_property)
add_RunCMake_test(string) add_RunCMake_test(string)
add_RunCMake_test(try_compile) add_RunCMake_test(try_compile)
add_RunCMake_test(try_run) add_RunCMake_test(try_run)

View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.2)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@ -0,0 +1,7 @@
add_custom_target(CustomTarget)
set_property(TARGET CustomTarget PROPERTY LINK_LIBRARIES)
set_property(TARGET CustomTarget APPEND PROPERTY LINK_LIBRARIES)
get_property(val TARGET CustomTarget PROPERTY LINK_LIBRARIES)
if (NOT "${val}" STREQUAL "")
message(FATAL_ERROR "LINK_LIBRARIES value is '${val}' but should be ''")
endif()

View File

@ -0,0 +1,3 @@
include(RunCMake)
run_cmake(LINK_LIBRARIES)