5 from .util
import REPLACE_PACKAGES
9 '${CATKIN_GLOBAL_BIN_DESTINATION}':
'bin',
10 '${CATKIN_GLOBAL_INCLUDE_DESTINATION}':
'include',
11 '${CATKIN_GLOBAL_LIB_DESTINATION}':
'lib',
12 '${CATKIN_GLOBAL_LIBEXEC_DESTINATION}':
'lib',
13 '${CATKIN_GLOBAL_SHARE_DESTINATION}':
'share',
14 '${CATKIN_PACKAGE_BIN_DESTINATION}':
'lib/${PROJECT_NAME}',
15 '${CATKIN_PACKAGE_INCLUDE_DESTINATION}':
'include/${PROJECT_NAME}',
16 '${CATKIN_PACKAGE_LIB_DESTINATION}':
'lib',
17 '${CATKIN_PACKAGE_SHARE_DESTINATION}':
'share/${PROJECT_NAME}',
22 """Convert find_package commands to find one package at a time.""" 23 components = [
'ament_cmake']
24 for cmd
in cmake.content_map[
'find_package']:
25 tokens = cmd.get_tokens()
26 if not tokens
or tokens[0] !=
'catkin':
28 if cmd.get_section(
'REQUIRED'):
29 cmps = cmd.get_section(
'COMPONENTS')
31 components += cmps.values
33 cmake.remove_command(cmd)
35 for component
in components:
36 if component ==
'message_generation':
38 if component
in REPLACE_PACKAGES:
39 component = REPLACE_PACKAGES[component]
41 cmd.add_section(
'', [component])
42 cmd.add_section(
'REQUIRED')
43 cmake.add_command(cmd)
47 if not package.cmake.content_map[
'catkin_package']:
50 pkg_cmd = package.cmake.content_map[
'catkin_package'][0]
51 for sname, cmd_name
in [(
'CATKIN_DEPENDS',
'ament_export_dependencies'),
52 (
'INCLUDE_DIRS',
'ament_export_include_directories'),
53 (
'LIBRARIES',
'ament_export_libraries')]:
54 section = pkg_cmd.get_section(sname)
57 no_cpp = len(package.source_code.get_source_by_language(
'c++'))
58 if sname ==
'CATKIN_DEPENDS' and no_cpp == 0
and 'message_runtime' in section.values:
61 cmd.add_section(
'', [REPLACE_PACKAGES.get(k, k)
for k
in section.values])
62 package.cmake.add_command(cmd)
65 package.cmake.add_command(cmd)
69 for cmd
in cmake.content_map[
'install']:
70 for section
in cmd.get_sections(
'DESTINATION'):
71 for i, value
in enumerate(section.values):
72 if value
in CATKIN_CMAKE_VARS:
73 section.values[i] = CATKIN_CMAKE_VARS[value]
79 for cmd
in cmake.content_map[
'set_directory_properties']:
80 section = cmd.get_section(
'COMPILE_OPTIONS')
81 bits = list(filter(
None, section.values[0][1:-1].split(
';')))
82 if '-std=c++11' in bits:
83 bits.remove(
'-std=c++11')
87 section.values = [
'"%s"' %
';'.join(bits)]
90 cmake.remove_command(cmd)
94 return [REPLACE_PACKAGES.get(k, k)
for k
in package.source_code.get_build_dependencies()]
98 cat_var =
'${catkin_INCLUDE_DIRS}' 100 for cmd
in package.cmake.content_map[
'include_directories']:
101 section = cmd.sections[0]
102 if cat_var
in section.values:
103 section.values.remove(cat_var)
108 for cmd
in cmake.content_map[source_name]:
109 cmd.command_name = target_name
111 for name
in remove_sections:
112 cmd.remove_sections(name)
113 cmake.content_map[target_name] = cmake.content_map[source_name]
114 del cmake.content_map[source_name]
120 cat_var =
'${catkin_LIBRARIES}' 121 rename_commands(package.cmake,
'target_link_libraries',
'ament_target_dependencies')
122 for cmd
in package.cmake.content_map[
'ament_target_dependencies']:
123 for section
in cmd.get_real_sections():
124 if cat_var
in section.values:
125 section.values.remove(cat_var)
126 section.values += deps
131 for content
in package.cmake.content_map[
'group']:
132 if is_testing_group(content):
133 content.initial_tag.sections[0].name =
'BUILD_TESTING' 134 content.initial_tag.changed =
True 141 package.cmake.upgrade_minimum_version((3, 5))
151 for old_cmd_name
in [
'catkin_python_setup',
'add_dependencies',
'catkin_package']:
152 package.cmake.remove_all_commands(old_cmd_name)
153 enforce_cmake_ordering(package)
154 remove_empty_cmake_lines(package)