Don't add / to start of pkg-config file path when DESTDIR is unset

This broke installation on Windows, because the suddenly started
with a '/' instead of a drive letter.

Closes #3019
This commit is contained in:
Martin Hořeňovský
2025-08-21 20:55:27 +02:00
parent 3e82ef9317
commit 78a9518a28

View File

@@ -195,17 +195,23 @@ if(NOT_SUBPROJECT)
"set(include_dir \"${CMAKE_INSTALL_INCLUDEDIR}\")"
"set(lib_dir \"${CMAKE_INSTALL_LIBDIR}\")"
[[
message(STATUS "DESTDIR: $ENV{DESTDIR}")
set(DESTDIR_PREFIX "")
if (DEFINED ENV{DESTDIR})
set(DESTDIR_PREFIX "$ENV{DESTDIR}")
endif ()
message(STATUS "PREFIX: ${DESTDIR_PREFIX}")
set(lib_name "$<TARGET_FILE_BASE_NAME:Catch2>")
configure_file(
"${impl_pc_file}"
"$ENV{DESTDIR}/${CMAKE_INSTALL_PREFIX}/${install_pkgconfdir}/catch2.pc"
"${DESTDIR_PREFIX}${CMAKE_INSTALL_PREFIX}/${install_pkgconfdir}/catch2.pc"
@ONLY
)
set(lib_name "$<TARGET_FILE_BASE_NAME:Catch2WithMain>")
configure_file(
"${main_pc_file}"
"$ENV{DESTDIR}/${CMAKE_INSTALL_PREFIX}/${install_pkgconfdir}/catch2-with-main.pc"
"${DESTDIR_PREFIX}${CMAKE_INSTALL_PREFIX}/${install_pkgconfdir}/catch2-with-main.pc"
@ONLY
)
]]