diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 6a87342b8..9d96fd936 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5406,8 +5406,10 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const continue; } cmTarget *objLib = this->Makefile->FindTargetToUse(objLibName.c_str()); - assert(objLib); - objlibs.push_back(objLib); + if(objLib) + { + objlibs.push_back(objLib); + } } } } diff --git a/Tests/RunCMake/CMP0026/ObjlibNotDefined-result.txt b/Tests/RunCMake/CMP0026/ObjlibNotDefined-result.txt new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/Tests/RunCMake/CMP0026/ObjlibNotDefined-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0026/ObjlibNotDefined-stderr.txt b/Tests/RunCMake/CMP0026/ObjlibNotDefined-stderr.txt new file mode 100644 index 000000000..87d198d00 --- /dev/null +++ b/Tests/RunCMake/CMP0026/ObjlibNotDefined-stderr.txt @@ -0,0 +1,12 @@ +CMake Warning \(dev\) at ObjlibNotDefined.cmake:[0-9]+ \(get_target_property\): + Policy CMP0026 is not set: Disallow use of the LOCATION target property. + Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + The LOCATION property should not be read from target "objlibuser". Use the + target name directly with add_custom_command, or use the generator + expression \$, as appropriate. + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0026/ObjlibNotDefined.cmake b/Tests/RunCMake/CMP0026/ObjlibNotDefined.cmake new file mode 100644 index 000000000..194760cd4 --- /dev/null +++ b/Tests/RunCMake/CMP0026/ObjlibNotDefined.cmake @@ -0,0 +1,13 @@ + +enable_language(CXX) + +add_executable(objlibuser + empty.cpp + $ +) + +get_target_property(_location objlibuser LOCATION) + +add_library(bar OBJECT + empty.cpp +) diff --git a/Tests/RunCMake/CMP0026/RunCMakeTest.cmake b/Tests/RunCMake/CMP0026/RunCMakeTest.cmake index 1824cc6aa..7c2582f7a 100644 --- a/Tests/RunCMake/CMP0026/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0026/RunCMakeTest.cmake @@ -9,3 +9,4 @@ run_cmake(CMP0026-CONFIG-LOCATION-WARN) run_cmake(CMP0026-LOCATION-CONFIG-NEW) run_cmake(CMP0026-LOCATION-CONFIG-OLD) run_cmake(CMP0026-LOCATION-CONFIG-WARN) +run_cmake(ObjlibNotDefined)