Skip to content
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

Move DL fatal message #382

Merged
merged 3 commits into from
Aug 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions cmake/GzRelocatableBinaries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,12 @@ macro(gz_add_get_install_prefix_impl)
"gz_add_get_install_prefix_impl: missing parameter OVERRIDE_INSTALL_PREFIX_ENV_VARIABLE")
endif()


if(NOT TARGET ${PROJECT_LIBRARY_TARGET_NAME})
message(FATAL_ERROR
"Target ${PROJECT_LIBRARY_TARGET_NAME} required by gz_add_get_install_prefix_impl\n"
"does not exist.")
endif()

if(NOT TARGET ${DL_TARGET})
mjcarroll marked this conversation as resolved.
Show resolved Hide resolved
message(FATAL_ERROR
"gz_add_get_install_prefix_impl called without DL_TARGET defined,\n"
"please add gz_find_package(DL) if you want to use gz_add_get_install_prefix_impl.")
endif()

get_target_property(target_type ${PROJECT_LIBRARY_TARGET_NAME} TYPE)
if(NOT (target_type STREQUAL "STATIC_LIBRARY" OR target_type STREQUAL "MODULE_LIBRARY" OR target_type STREQUAL "SHARED_LIBRARY"))
message(FATAL_ERROR "gz_add_get_install_prefix_impl: library ${_library} is of unsupported type ${target_type}")
Expand Down Expand Up @@ -208,7 +201,16 @@ endif()
# Add cpp to library
target_sources(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE ${gz_add_get_install_prefix_impl_GENERATED_CPP})

# Only link DL in the case that it is needed.
if ((target_type STREQUAL "MODULE_LIBRARY" OR target_type STREQUAL "SHARED_LIBRARY") AND GZ_ENABLE_RELOCATABLE_INSTALL)
if(NOT TARGET ${DL_TARGET})
message(FATAL_ERROR
"gz_add_get_install_prefix_impl called without DL_TARGET defined,\n"
"please add gz_find_package(DL) if you want to use gz_add_get_install_prefix_impl.")
endif()

# Link DL_TARGET that provides dladdr
target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE ${DL_TARGET})
endif()

endmacro()