-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add new macro to export ts libraries through different CMake variable #284
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
rosidl_cmake/cmake/rosidl_cmake_export_typesupport_libraries-extras.cmake.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# generated from | ||
# rosidl_cmake/cmake/template/rosidl_cmake_export_typesupport_libraries.cmake.in | ||
|
||
set(_exported_typesupport_libraries | ||
"@_ROSIDL_CMAKE_EXPORT_TYPESUPPORT_LIBRARIES@") | ||
|
||
# populate @PROJECT_NAME@_LIBRARIES_<suffix> | ||
if(NOT _exported_typesupport_libraries STREQUAL "") | ||
# loop over typesupport libraries | ||
foreach(_tuple ${_exported_typesupport_libraries}) | ||
string(REPLACE ":" ";" _tuple "${_tuple}") | ||
list(GET _tuple 0 _suffix) | ||
list(GET _tuple 1 _library) | ||
|
||
if(NOT IS_ABSOLUTE "${_library}") | ||
# search for library target relative to this CMake file | ||
set(_lib "NOTFOUND") | ||
find_library( | ||
_lib NAMES "${_library}" | ||
PATHS "${@PROJECT_NAME@_DIR}/../../../lib" | ||
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH | ||
) | ||
|
||
if(NOT _lib) | ||
# the library wasn't found | ||
message(FATAL_ERROR "Package '@PROJECT_NAME@' exports the typesupport library '${_library}' which couldn't be found") | ||
elseif(NOT IS_ABSOLUTE "${_lib}") | ||
# the found library must be an absolute path | ||
message(FATAL_ERROR "Package '@PROJECT_NAME@' found the typesupport library '${_library}' at '${_lib}' which is not an absolute path") | ||
elseif(NOT EXISTS "${_lib}") | ||
# the found library must exist | ||
message(FATAL_ERROR "Package '@PROJECT_NAME@' found the typesupport library '${_lib}' which doesn't exist") | ||
else() | ||
list(APPEND @PROJECT_NAME@_LIBRARIES${_suffix} ${_cfg} "${_lib}") | ||
endif() | ||
|
||
else() | ||
if(NOT EXISTS "${_library}") | ||
# the found library must exist | ||
message(WARNING "Package '@PROJECT_NAME@' exports the typesupport library '${_library}' which doesn't exist") | ||
else() | ||
list(APPEND @PROJECT_NAME@_LIBRARIES${_suffix} "${_library}") | ||
endif() | ||
endif() | ||
endforeach() | ||
endif() |
23 changes: 23 additions & 0 deletions
23
rosidl_cmake/cmake/rosidl_cmake_export_typesupport_libraries_package_hook.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2018 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# generate and register extra file for typesupport libraries | ||
set(_generated_extra_file | ||
"${CMAKE_CURRENT_BINARY_DIR}/rosidl_cmake/rosidl_cmake_export_typesupport_libraries-extras.cmake") | ||
configure_file( | ||
"${rosidl_cmake_DIR}/rosidl_cmake_export_typesupport_libraries-extras.cmake.in" | ||
"${_generated_extra_file}" | ||
@ONLY | ||
) | ||
list(APPEND ${PROJECT_NAME}_CONFIG_EXTRAS "${_generated_extra_file}") |
51 changes: 51 additions & 0 deletions
51
rosidl_cmake/cmake/rosidl_export_typesupport_libraries.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright 2018 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# | ||
# Export typesupport libraries to downstream packages. | ||
# | ||
# :param library_suffix: the suffix of the library | ||
# :param ARGN: a list of libraries. | ||
# Each element must be a CMake library target. | ||
# :type ARGN: list of strings | ||
# | ||
# @public | ||
# | ||
macro(rosidl_export_typesupport_libraries library_suffix) | ||
if(_${PROJECT_NAME}_AMENT_PACKAGE) | ||
message(FATAL_ERROR | ||
"rosidl_export_typesupport_libraries() must be called before " | ||
"ament_package()") | ||
endif() | ||
|
||
if(${ARGC} GREATER 0) | ||
_rosidl_cmake_export_typesupport_libraries_register_package_hook() | ||
# loop over libraries | ||
foreach(_lib ${ARGN}) | ||
if(NOT TARGET "${_lib}") | ||
message(FATAL_ERROR | ||
"rosidl_export_typesupport_libraries() must be called with targets") | ||
endif() | ||
|
||
get_target_property(_is_imported "${_lib}" IMPORTED) | ||
if(_is_imported) | ||
message(FATAL_ERROR | ||
"rosidl_export_typesupport_libraries() must be called with " | ||
"not-imported targets") | ||
endif() | ||
|
||
list(APPEND _ROSIDL_CMAKE_EXPORT_TYPESUPPORT_LIBRARIES "${library_suffix}:${_lib}") | ||
endforeach() | ||
endif() | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this maco be here? Rather than its own file or in the
rosidl_export_typesupport_libraries.cmake
file?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is the CMake extra file of the
rosidl_cmake
package. Therefore I just added it there. It could be placed into a second-extras.cmake
file but it would be rather uncommon that a single CMake package has multiple extra files.