538 out.write('\n#')
539 out.write(target.gn_name)
540 out.write('\n')
541
542 if target.cmake_type is None:
543 print ('Target %s has unknown target type %s, skipping.' %
544 ( target.gn_name, target.gn_type ) )
545 return
546
548
550
551 synthetic_dependencies =
set()
552 if target.gn_type == 'action':
553 WriteAction(out, target, project, sources, synthetic_dependencies)
554 if target.gn_type == 'action_foreach':
556 if target.gn_type == 'copy':
557 WriteCopy(out, target, project, sources, synthetic_dependencies)
558
559 out.write(target.cmake_type.command)
560 out.write('("${target}"')
561 if target.cmake_type.modifier is not None:
562 out.write(' ')
563 out.write(target.cmake_type.modifier)
564 for sources_type_name in sources.values():
566 if synthetic_dependencies:
567 out.write(' DEPENDS')
568 for synthetic_dependencie in synthetic_dependencies:
570 out.write(')\n')
571
572 if target.cmake_type.command != 'add_custom_target':
574
577
578 dependencies =
set(target.properties.get(
'deps', []))
579
580
581
582 object_dependencies =
set()
583 if target.gn_type != 'source_set':
584 project.GetObjectLibraryDependencies(target.gn_name, object_dependencies)
585 for object_dependency in object_dependencies:
586 dependencies.update(project.targets.get(object_dependency).
get(
'deps', []))
587
588 for dependency in dependencies:
589 gn_dependency_type = project.targets.get(dependency, {}).
get(
'type',
None)
590 cmake_dependency_type = cmake_target_types.get(gn_dependency_type, None)
591 cmake_dependency_name = project.GetCMakeTargetName(dependency)
592 if cmake_dependency_type.command != 'add_library':
593 nonlibraries.add(cmake_dependency_name)
594 elif cmake_dependency_type.modifier != 'OBJECT':
595 if target.cmake_type.is_linkable:
596 libraries.add(cmake_dependency_name)
597 else:
598 nonlibraries.add(cmake_dependency_name)
599
600
601 if nonlibraries:
602 out.write('add_dependencies("${target}"')
603 for nonlibrary in nonlibraries:
604 out.write('\n "')
605 out.write(nonlibrary)
606 out.write('"')
607 out.write(')\n')
608
609
610 combined_library_lists = [target.properties.get(key, []) for key in ['libs', 'frameworks']]
611 external_libraries = list(itertools.chain(*combined_library_lists))
612 if target.cmake_type.is_linkable and (external_libraries or libraries):
613 library_dirs = target.properties.get('lib_dirs', [])
614 if library_dirs:
616
617 system_libraries = []
618 for external_library in external_libraries:
619 if '/' in external_library:
620 libraries.add(project.GetAbsolutePath(external_library))
621 else:
622 if external_library.endswith('.framework'):
623 external_library = external_library[:-
len(
'.framework')]
624 system_library = 'library__' + external_library
625 if library_dirs:
626 system_library = system_library + '__for_${target}'
627 out.write('find_library("')
629 out.write('" "')
631 out.write('"')
632 if library_dirs:
633 out.write(' PATHS "')
635 out.write('"')
636 out.write(')\n')
637 system_libraries.append(system_library)
638 out.write('target_link_libraries("${target}"')
639 if (target.cmake_type.modifier == "INTERFACE"):
640 out.write(' INTERFACE')
641 for library in libraries:
642 out.write('\n "')
644 out.write('"')
645 for system_library in system_libraries:
647 out.write('"')
648 out.write(')\n')
649
650
const myers::Point & get(const myers::Segment &)