Files
qt6-migration-pipeline/external/rti_connext_dds-7.7.0/resource/cmake/ConnextDdsGetSharedLibraryId.cmake
T
torstenandCopilot 342ffd3e5c Update submodule to latest BUILD_RTI fixes
- HandlerMinelayerData: BUILD_RTI Guards für RTI-Abhängigkeiten
- svcTabCommon: Export-Header-Fix via Fallback-Target
- TrainingAreaBase: Stub-Header für BUILD_RTI=OFF
- ddsfts: Include-Pfad und Dependency-Fixes
- BUILD_RTI=OFF Compilation vollständig unterstützt

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Entire-Checkpoint: 01M0JNZA586SACX1PRZ2DJAE5S
2026-08-21 19:30:20 +02:00

81 lines
2.4 KiB
CMake

# (c) 2021 Copyright, Real-Time Innovations, Inc. All rights reserved.
# No duplications, whole or partial, manual or electronic, may be made
# without express written permission. Any such copies, or revisions thereof,
# must display this notice unaltered.
# This code contains trade secrets of Real-Time Innovations, Inc.
#[[.rst:
.. _connextdds_get_shared_library_id:
ConnextDdsGetSharedLibraryId
----------------------------
connextdds_get_shared_library_id
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Get a shared library's identifier::
connextdds_get_shared_library_id(
LIBRARY <shared_library>
IDENTIFIER <output_id>
)
Helper function to extract the shared library ID.
#]]
include(FindPackageHandleStandardArgs)
include(ConnextDdsImportedTargets)
function(connextdds_get_shared_library_id library outvar)
if(BUILD_SHARED_LIBS)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# We use `otool` for this task.
# otool: object file displaying tool.
find_program(OTOOL
NAMES
"otool"
DOC "The otool program"
)
if(NOT OTOOL)
connextdds_log_message(FATAL_ERROR "otool not found")
endif()
execute_process(
COMMAND
${OTOOL} -D ${library} -X
OUTPUT_VARIABLE otool_output
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE otool_retcode
)
# If everything goes properly, the return code is 0
if(otool_retcode)
connextdds_log_message(FATAL_ERROR "Failed to run otool")
endif()
string(REPLACE "\n" "" shared_library_id ${otool_output})
# Get the path to the real library
set(${outvar} "${shared_library_id}" PARENT_SCOPE)
elseif(NOT WIN32)
# Get the path to the real library
get_filename_component(
resolved_library_full ${library} REALPATH
)
set(${outvar} ${resolved_library_full} PARENT_SCOPE)
else()
connextdds_log_message(
FATAL_ERROR
"This functionality is not supported in Windows"
)
endif()
else()
connextdds_log_message(
FATAL_ERROR
"This functionality is only supported for shared libs"
)
endif()
endfunction()