|
| 1 | +# generated from catkin/cmake/template/pkgConfig.cmake.in |
| 2 | + |
| 3 | +# append elements to a list and remove existing duplicates from the list |
| 4 | +# copied from catkin/cmake/list_append_deduplicate.cmake to keep pkgConfig |
| 5 | +# self contained |
| 6 | +macro(_list_append_deduplicate listname) |
| 7 | + if(NOT "${ARGN}" STREQUAL "") |
| 8 | + if(${listname}) |
| 9 | + list(REMOVE_ITEM ${listname} ${ARGN}) |
| 10 | + endif() |
| 11 | + list(APPEND ${listname} ${ARGN}) |
| 12 | + endif() |
| 13 | +endmacro() |
| 14 | + |
| 15 | +# append elements to a list if they are not already in the list |
| 16 | +# copied from catkin/cmake/list_append_unique.cmake to keep pkgConfig |
| 17 | +# self contained |
| 18 | +macro(_list_append_unique listname) |
| 19 | + foreach(_item ${ARGN}) |
| 20 | + list(FIND ${listname} ${_item} _index) |
| 21 | + if(_index EQUAL -1) |
| 22 | + list(APPEND ${listname} ${_item}) |
| 23 | + endif() |
| 24 | + endforeach() |
| 25 | +endmacro() |
| 26 | + |
| 27 | +# pack a list of libraries with optional build configuration keywords |
| 28 | +# copied from catkin/cmake/catkin_libraries.cmake to keep pkgConfig |
| 29 | +# self contained |
| 30 | +macro(_pack_libraries_with_build_configuration VAR) |
| 31 | + set(${VAR} "") |
| 32 | + set(_argn ${ARGN}) |
| 33 | + list(LENGTH _argn _count) |
| 34 | + set(_index 0) |
| 35 | + while(${_index} LESS ${_count}) |
| 36 | + list(GET _argn ${_index} lib) |
| 37 | + if("${lib}" MATCHES "^(debug|optimized|general)$") |
| 38 | + math(EXPR _index "${_index} + 1") |
| 39 | + if(${_index} EQUAL ${_count}) |
| 40 | + message(FATAL_ERROR "_pack_libraries_with_build_configuration() the list of libraries '${ARGN}' ends with '${lib}' which is a build configuration keyword and must be followed by a library") |
| 41 | + endif() |
| 42 | + list(GET _argn ${_index} library) |
| 43 | + list(APPEND ${VAR} "${lib}${CATKIN_BUILD_CONFIGURATION_KEYWORD_SEPARATOR}${library}") |
| 44 | + else() |
| 45 | + list(APPEND ${VAR} "${lib}") |
| 46 | + endif() |
| 47 | + math(EXPR _index "${_index} + 1") |
| 48 | + endwhile() |
| 49 | +endmacro() |
| 50 | + |
| 51 | +# unpack a list of libraries with optional build configuration keyword prefixes |
| 52 | +# copied from catkin/cmake/catkin_libraries.cmake to keep pkgConfig |
| 53 | +# self contained |
| 54 | +macro(_unpack_libraries_with_build_configuration VAR) |
| 55 | + set(${VAR} "") |
| 56 | + foreach(lib ${ARGN}) |
| 57 | + string(REGEX REPLACE "^(debug|optimized|general)${CATKIN_BUILD_CONFIGURATION_KEYWORD_SEPARATOR}(.+)$" "\\1;\\2" lib "${lib}") |
| 58 | + list(APPEND ${VAR} "${lib}") |
| 59 | + endforeach() |
| 60 | +endmacro() |
| 61 | + |
| 62 | + |
| 63 | +if(kobuki_description_CONFIG_INCLUDED) |
| 64 | + return() |
| 65 | +endif() |
| 66 | +set(kobuki_description_CONFIG_INCLUDED TRUE) |
| 67 | + |
| 68 | +# set variables for source/devel/install prefixes |
| 69 | +if("FALSE" STREQUAL "TRUE") |
| 70 | + set(kobuki_description_SOURCE_PREFIX /tmp/binarydeb/ros-kinetic-kobuki-description-0.7.6) |
| 71 | + set(kobuki_description_DEVEL_PREFIX /tmp/binarydeb/ros-kinetic-kobuki-description-0.7.6/obj-x86_64-linux-gnu/devel) |
| 72 | + set(kobuki_description_INSTALL_PREFIX "") |
| 73 | + set(kobuki_description_PREFIX ${kobuki_description_DEVEL_PREFIX}) |
| 74 | +else() |
| 75 | + set(kobuki_description_SOURCE_PREFIX "") |
| 76 | + set(kobuki_description_DEVEL_PREFIX "") |
| 77 | + set(kobuki_description_INSTALL_PREFIX /opt/ros/kinetic) |
| 78 | + set(kobuki_description_PREFIX ${kobuki_description_INSTALL_PREFIX}) |
| 79 | +endif() |
| 80 | + |
| 81 | +# warn when using a deprecated package |
| 82 | +if(NOT "" STREQUAL "") |
| 83 | + set(_msg "WARNING: package 'kobuki_description' is deprecated") |
| 84 | + # append custom deprecation text if available |
| 85 | + if(NOT "" STREQUAL "TRUE") |
| 86 | + set(_msg "${_msg} ()") |
| 87 | + endif() |
| 88 | + message("${_msg}") |
| 89 | +endif() |
| 90 | + |
| 91 | +# flag project as catkin-based to distinguish if a find_package()-ed project is a catkin project |
| 92 | +set(kobuki_description_FOUND_CATKIN_PROJECT TRUE) |
| 93 | + |
| 94 | +if(NOT " " STREQUAL " ") |
| 95 | + set(kobuki_description_INCLUDE_DIRS "") |
| 96 | + set(_include_dirs "") |
| 97 | + if(NOT "https://github.com/yujinrobot/kobuki/issues " STREQUAL " ") |
| 98 | + set(_report "Check the issue tracker 'https://github.com/yujinrobot/kobuki/issues' and consider creating a ticket if the problem has not been reported yet.") |
| 99 | + elseif(NOT "http://ros.org/wiki/kobuki_description " STREQUAL " ") |
| 100 | + set(_report "Check the website 'http://ros.org/wiki/kobuki_description' for information and consider reporting the problem.") |
| 101 | + else() |
| 102 | + set(_report "Report the problem to the maintainer 'Younghun Ju <[email protected]>' and request to fix the problem.") |
| 103 | + endif() |
| 104 | + foreach(idir ${_include_dirs}) |
| 105 | + if(IS_ABSOLUTE ${idir} AND IS_DIRECTORY ${idir}) |
| 106 | + set(include ${idir}) |
| 107 | + elseif("${idir} " STREQUAL "include ") |
| 108 | + get_filename_component(include "${kobuki_description_DIR}/../../../include" ABSOLUTE) |
| 109 | + if(NOT IS_DIRECTORY ${include}) |
| 110 | + message(FATAL_ERROR "Project 'kobuki_description' specifies '${idir}' as an include dir, which is not found. It does not exist in '${include}'. ${_report}") |
| 111 | + endif() |
| 112 | + else() |
| 113 | + message(FATAL_ERROR "Project 'kobuki_description' specifies '${idir}' as an include dir, which is not found. It does neither exist as an absolute directory nor in '/opt/ros/kinetic/${idir}'. ${_report}") |
| 114 | + endif() |
| 115 | + _list_append_unique(kobuki_description_INCLUDE_DIRS ${include}) |
| 116 | + endforeach() |
| 117 | +endif() |
| 118 | + |
| 119 | +set(libraries "") |
| 120 | +foreach(library ${libraries}) |
| 121 | + # keep build configuration keywords, target names and absolute libraries as-is |
| 122 | + if("${library}" MATCHES "^(debug|optimized|general)$") |
| 123 | + list(APPEND kobuki_description_LIBRARIES ${library}) |
| 124 | + elseif(TARGET ${library}) |
| 125 | + list(APPEND kobuki_description_LIBRARIES ${library}) |
| 126 | + elseif(IS_ABSOLUTE ${library}) |
| 127 | + list(APPEND kobuki_description_LIBRARIES ${library}) |
| 128 | + else() |
| 129 | + set(lib_path "") |
| 130 | + set(lib "${library}-NOTFOUND") |
| 131 | + # since the path where the library is found is returned we have to iterate over the paths manually |
| 132 | + foreach(path /opt/ros/kinetic/lib;/opt/ros/kinetic/lib) |
| 133 | + find_library(lib ${library} |
| 134 | + PATHS ${path} |
| 135 | + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) |
| 136 | + if(lib) |
| 137 | + set(lib_path ${path}) |
| 138 | + break() |
| 139 | + endif() |
| 140 | + endforeach() |
| 141 | + if(lib) |
| 142 | + _list_append_unique(kobuki_description_LIBRARY_DIRS ${lib_path}) |
| 143 | + list(APPEND kobuki_description_LIBRARIES ${lib}) |
| 144 | + else() |
| 145 | + # as a fall back for non-catkin libraries try to search globally |
| 146 | + find_library(lib ${library}) |
| 147 | + if(NOT lib) |
| 148 | + message(FATAL_ERROR "Project '${PROJECT_NAME}' tried to find library '${library}'. The library is neither a target nor built/installed properly. Did you compile project 'kobuki_description'? Did you find_package() it before the subdirectory containing its code is included?") |
| 149 | + endif() |
| 150 | + list(APPEND kobuki_description_LIBRARIES ${lib}) |
| 151 | + endif() |
| 152 | + endif() |
| 153 | +endforeach() |
| 154 | + |
| 155 | +set(kobuki_description_EXPORTED_TARGETS "") |
| 156 | +# create dummy targets for exported code generation targets to make life of users easier |
| 157 | +foreach(t ${kobuki_description_EXPORTED_TARGETS}) |
| 158 | + if(NOT TARGET ${t}) |
| 159 | + add_custom_target(${t}) |
| 160 | + endif() |
| 161 | +endforeach() |
| 162 | + |
| 163 | +set(depends "urdf;xacro") |
| 164 | +foreach(depend ${depends}) |
| 165 | + string(REPLACE " " ";" depend_list ${depend}) |
| 166 | + # the package name of the dependency must be kept in a unique variable so that it is not overwritten in recursive calls |
| 167 | + list(GET depend_list 0 kobuki_description_dep) |
| 168 | + list(LENGTH depend_list count) |
| 169 | + if(${count} EQUAL 1) |
| 170 | + # simple dependencies must only be find_package()-ed once |
| 171 | + if(NOT ${kobuki_description_dep}_FOUND) |
| 172 | + find_package(${kobuki_description_dep} REQUIRED NO_MODULE) |
| 173 | + endif() |
| 174 | + else() |
| 175 | + # dependencies with components must be find_package()-ed again |
| 176 | + list(REMOVE_AT depend_list 0) |
| 177 | + find_package(${kobuki_description_dep} REQUIRED NO_MODULE ${depend_list}) |
| 178 | + endif() |
| 179 | + _list_append_unique(kobuki_description_INCLUDE_DIRS ${${kobuki_description_dep}_INCLUDE_DIRS}) |
| 180 | + |
| 181 | + # merge build configuration keywords with library names to correctly deduplicate |
| 182 | + _pack_libraries_with_build_configuration(kobuki_description_LIBRARIES ${kobuki_description_LIBRARIES}) |
| 183 | + _pack_libraries_with_build_configuration(_libraries ${${kobuki_description_dep}_LIBRARIES}) |
| 184 | + _list_append_deduplicate(kobuki_description_LIBRARIES ${_libraries}) |
| 185 | + # undo build configuration keyword merging after deduplication |
| 186 | + _unpack_libraries_with_build_configuration(kobuki_description_LIBRARIES ${kobuki_description_LIBRARIES}) |
| 187 | + |
| 188 | + _list_append_unique(kobuki_description_LIBRARY_DIRS ${${kobuki_description_dep}_LIBRARY_DIRS}) |
| 189 | + list(APPEND kobuki_description_EXPORTED_TARGETS ${${kobuki_description_dep}_EXPORTED_TARGETS}) |
| 190 | +endforeach() |
| 191 | + |
| 192 | +set(pkg_cfg_extras "") |
| 193 | +foreach(extra ${pkg_cfg_extras}) |
| 194 | + if(NOT IS_ABSOLUTE ${extra}) |
| 195 | + set(extra ${kobuki_description_DIR}/${extra}) |
| 196 | + endif() |
| 197 | + include(${extra}) |
| 198 | +endforeach() |
0 commit comments