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 all commits
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
13 changes: 6 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 All @@ -100,6 +93,12 @@ macro(gz_add_get_install_prefix_impl)
option(GZ_ENABLE_RELOCATABLE_INSTALL "If ON, enable the feature of providing a relocatable install prefix in shared library." OFF)

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()

# We can't query the LOCATION property of the target due to https://cmake.org/cmake/help/v3.25/policy/CMP0026.html
# We can only access the directory of the library at generation time via $<TARGET_FILE_DIR:tgt>
file(GENERATE OUTPUT "${gz_add_get_install_prefix_impl_GENERATED_CPP}"
Expand Down