16
16
# Export targets to downstream packages.
17
17
#
18
18
# Each export name must have been used to install targets using
19
- # ``install(TARGETS ... EXPORT name ...)``.
19
+ # ``install(TARGETS ... EXPORT name NAMESPACE my_namespace ...)``.
20
20
# The ``install(EXPORT ...)`` invocation is handled by this macros.
21
21
#
22
22
# :param HAS_LIBRARY_TARGET: if set, an environment variable will be defined
23
23
# so that the library can be found at runtime
24
24
# :type HAS_LIBRARY_TARGET: option
25
+ # :keyword NAMESPACE: the exported namespace for the target if set.
26
+ # The default is the value of ``${PROJECT_NAME}::``.
27
+ # This is an advanced option. It should be used carefully and clearly documented
28
+ # in a usage guide for any package that makes use of this option.
29
+ # :type NAMESPACE: string
25
30
# :param ARGN: a list of export names
26
31
# :type ARGN: list of strings
27
32
#
@@ -32,14 +37,21 @@ macro(ament_export_targets)
32
37
message (FATAL_ERROR
33
38
"ament_export_targets() must be called before ament_package()" )
34
39
endif ()
35
- cmake_parse_arguments (_ARG "HAS_LIBRARY_TARGET" "" "" ${ARGN} )
40
+ cmake_parse_arguments (_ARG "HAS_LIBRARY_TARGET" "NAMESPACE " "" ${ARGN} )
36
41
37
42
if (${ARGC} GREATER 0)
38
43
_ament_cmake_export_targets_register_package_hook()
39
44
foreach (_arg ${_ARG_UNPARSED_ARGUMENTS} )
40
45
list (APPEND _AMENT_CMAKE_EXPORT_TARGETS "${_arg} " )
41
46
endforeach ()
42
47
48
+ set (_AMENT_CMAKE_EXPORT_TARGETS_NAMESPACE ${_ARG_NAMESPACE} )
49
+
50
+ # Allow optionally overriding default namespace
51
+ if (NOT DEFINED _AMENT_CMAKE_EXPORT_TARGETS_NAMESPACE)
52
+ set (_AMENT_CMAKE_EXPORT_TARGETS_NAMESPACE "${PROJECT_NAME} ::" )
53
+ endif ()
54
+
43
55
# if the export name contains is a library target
44
56
# make sure to register an environment hook
45
57
if (${_ARG_HAS_LIBRARY_TARGET} )
0 commit comments