MCPcopy Create free account
hub / github.com/Kitware/CMake / GenerateImportTargetCode

Method GenerateImportTargetCode

Source/cmExportCMakeConfigGenerator.cxx:264–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262}
263
264void cmExportCMakeConfigGenerator::GenerateImportTargetCode(
265 std::ostream& os, cmGeneratorTarget const* target,
266 cmStateEnums::TargetType targetType)
267{
268 // Construct the imported target name.
269 std::string targetName = this->Namespace;
270
271 targetName += target->GetExportName();
272
273 // Create the imported target.
274 os << "# Create imported target " << targetName << "\n";
275 switch (targetType) {
276 case cmStateEnums::EXECUTABLE:
277 os << "add_executable(" << targetName << " IMPORTED)\n";
278 break;
279 case cmStateEnums::STATIC_LIBRARY:
280 os << "add_library(" << targetName << " STATIC IMPORTED)\n";
281 break;
282 case cmStateEnums::SHARED_LIBRARY:
283 os << "add_library(" << targetName << " SHARED IMPORTED)\n";
284 break;
285 case cmStateEnums::MODULE_LIBRARY:
286 os << "add_library(" << targetName << " MODULE IMPORTED)\n";
287 break;
288 case cmStateEnums::UNKNOWN_LIBRARY:
289 os << "add_library(" << targetName << " UNKNOWN IMPORTED)\n";
290 break;
291 case cmStateEnums::OBJECT_LIBRARY:
292 os << "add_library(" << targetName << " OBJECT IMPORTED)\n";
293 break;
294 case cmStateEnums::INTERFACE_LIBRARY:
295 if (target->IsSymbolic()) {
296 os << "if(CMAKE_VERSION VERSION_GREATER_EQUAL \"4.2.0\")\n"
297 " add_library("
298 << targetName << " INTERFACE SYMBOLIC IMPORTED)\n"
299 << "elseif(CMAKE_VERSION VERSION_GREATER_EQUAL 3.2.0)\n"
300 << " add_library(" << targetName << " INTERFACE IMPORTED)\n"
301 << " set_target_properties(" << targetName
302 << " PROPERTIES SYMBOLIC TRUE)\n"
303 << "endif()\n";
304 } else {
305 os << "add_library(" << targetName << " INTERFACE IMPORTED)\n";
306 }
307 break;
308 default: // should never happen
309 break;
310 }
311
312 // Mark the imported executable if it has exports.
313 if (target->IsExecutableWithExports() ||
314 (target->IsSharedLibraryWithExports() && target->HasImportLibrary(""))) {
315 os << "set_property(TARGET " << targetName
316 << " PROPERTY ENABLE_EXPORTS 1)\n";
317 }
318
319 // Mark the imported library if it is a framework.
320 if (target->IsFrameworkOnApple()) {
321 os << "set_property(TARGET " << targetName << " PROPERTY FRAMEWORK 1)\n";

Callers 3

GenerateMainFileMethod · 0.45
GenerateMainFileMethod · 0.45
GenerateMainFileMethod · 0.45

Calls 13

GetExportNameMethod · 0.80
HasImportLibraryMethod · 0.80
IsCFBundleOnAppleMethod · 0.80
IsDeprecatedMethod · 0.80
GetDeprecationMethod · 0.80
IsSymbolicMethod · 0.45
IsFrameworkOnAppleMethod · 0.45
IsAppBundleOnAppleMethod · 0.45

Tested by

no test coverage detected