Fix CMake generation for minimal CMake version (3.2.3)

Unfortunately `execute_process(COMMAND pkg-config ...)` used for
CMake versions lower than 3.4 appends a trailing newline ('\n')
to the output variable which must be removed.

Replace double slash '//' returned by pkg-config with a single '/'
for consistency (applies to all CMake versions).

Tested with CMake 3.2.3 but we should probably raise the minimal
CMake version to a more recent version in the future.
This commit is contained in:
Albrecht Schlosser 2023-04-10 16:19:09 +02:00
parent 027e738655
commit 3835b72e2f
1 changed files with 4 additions and 0 deletions

View File

@ -646,7 +646,11 @@ if (UNIX AND OPTION_USE_WAYLAND)
else()
execute_process(COMMAND pkg-config --variable=pkgdatadir wayland-protocols
OUTPUT_VARIABLE PROTOCOLS)
# strip trailing newline
string (REPLACE "\n" "" PROTOCOLS ${PROTOCOLS})
endif (NOT (CMAKE_VERSION VERSION_LESS 3.4))
# replace "//" with "/"
string (REPLACE "//" "/" PROTOCOLS ${PROTOCOLS})
if (NOT(EXISTS ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml))
message(WARNING "Install necessary file ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml")
endif ()