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

Compute relative path for cmake extras #362

Merged
merged 2 commits into from
Jul 6, 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
28 changes: 19 additions & 9 deletions cmake/GzConfigureProject.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,24 @@ macro(gz_configure_project)
list(APPEND extras ${gz_configure_project_CONFIG_EXTRAS})
endif()

#============================================================================
# Identify the operating system
gz_check_os()

#============================================================================
# Create package information
_gz_setup_packages()

#============================================================================
# Configure and install cmake extras files
# Do this after _gz_setup_packages() to ensure GNUInstallDirs has been called
set(PROJECT_CMAKE_EXTRAS_INSTALL_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/${PROJECT_NAME})
file(RELATIVE_PATH
PROJECT_CMAKE_EXTRAS_PATH_TO_PREFIX
"${PROJECT_CMAKE_EXTRAS_INSTALL_DIR}"
"${CMAKE_INSTALL_PREFIX}"
)

foreach(extra ${extras})
_gz_assert_file_exists("${extra}"
"gz_configure_project() called with extra file '${extra}' which does not exist")
Expand Down Expand Up @@ -180,7 +198,7 @@ macro(gz_configure_project)
if(is_cmake)
install(FILES
${extra}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/
DESTINATION ${PROJECT_CMAKE_EXTRAS_INSTALL_DIR}
)
get_filename_component(extra_filename "${extra}" NAME)
list(APPEND PACKAGE_CONFIG_EXTRA_FILES "${extra_filename}")
Expand All @@ -190,14 +208,6 @@ macro(gz_configure_project)
endif()
endforeach()

#============================================================================
# Identify the operating system
gz_check_os()

#============================================================================
# Create package information
_gz_setup_packages()

#============================================================================
# Initialize build errors/warnings
# NOTE: We no longer use CACHE for these variables because it was set to
Expand Down