| 1356 | } |
| 1357 | |
| 1358 | bool cmGeneratorTarget::NeedRelinkBeforeInstall( |
| 1359 | std::string const& config) const |
| 1360 | { |
| 1361 | // Only executables and shared libraries can have an rpath and may |
| 1362 | // need relinking. |
| 1363 | if (this->GetType() != cmStateEnums::EXECUTABLE && |
| 1364 | this->GetType() != cmStateEnums::SHARED_LIBRARY && |
| 1365 | this->GetType() != cmStateEnums::MODULE_LIBRARY) { |
| 1366 | return false; |
| 1367 | } |
| 1368 | |
| 1369 | // If there is no install location this target will not be installed |
| 1370 | // and therefore does not need relinking. |
| 1371 | if (!this->Target->GetHaveInstallRule()) { |
| 1372 | return false; |
| 1373 | } |
| 1374 | |
| 1375 | // If skipping all rpaths completely then no relinking is needed. |
| 1376 | if (this->Makefile->IsOn("CMAKE_SKIP_RPATH")) { |
| 1377 | return false; |
| 1378 | } |
| 1379 | |
| 1380 | // If building with the install-tree rpath no relinking is needed. |
| 1381 | if (this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) { |
| 1382 | return false; |
| 1383 | } |
| 1384 | |
| 1385 | // If chrpath is going to be used no relinking is needed. |
| 1386 | if (this->IsChrpathUsed(config)) { |
| 1387 | return false; |
| 1388 | } |
| 1389 | |
| 1390 | // Check for rpath support on this platform. |
| 1391 | std::string ll = this->GetLinkerLanguage(config); |
| 1392 | if (!ll.empty()) { |
| 1393 | std::string flagVar = |
| 1394 | cmStrCat("CMAKE_SHARED_LIBRARY_RUNTIME_", ll, "_FLAG"); |
| 1395 | if (!this->Makefile->IsSet(flagVar)) { |
| 1396 | // There is no rpath support on this platform so nothing needs |
| 1397 | // relinking. |
| 1398 | return false; |
| 1399 | } |
| 1400 | } else { |
| 1401 | // No linker language is known. This error will be reported by |
| 1402 | // other code. |
| 1403 | return false; |
| 1404 | } |
| 1405 | |
| 1406 | // If either a build or install tree rpath is set then the rpath |
| 1407 | // will likely change between the build tree and install tree and |
| 1408 | // this target must be relinked. |
| 1409 | bool have_rpath = |
| 1410 | this->HaveBuildTreeRPATH(config) || this->HaveInstallTreeRPATH(config); |
| 1411 | bool is_ninja = this->LocalGenerator->GetGlobalGenerator()->IsNinja(); |
| 1412 | |
| 1413 | if (have_rpath && is_ninja) { |
| 1414 | std::ostringstream w; |
| 1415 | /* clang-format off */ |
no test coverage detected