Skip to content

Commit

Permalink
cmake: Update tweaks to fix fedora glslang issues.
Browse files Browse the repository at this point in the history
Fedora 39 fixed the problem where it couldn't parse the glslang.pc
file at all because of leading spaces, but it introduced a new problem
because it still requires linking against libraries that are no longer
part of the distribution.  Change the first fix to only apply to
Fedora 38 or earlier, and add a fix for the new problem.

View this diff using the "-w" flag.
  • Loading branch information
linuxdude42 committed Sep 1, 2024
1 parent ed0f440 commit 7af1bf5
Showing 1 changed file with 39 additions and 17 deletions.
56 changes: 39 additions & 17 deletions mythtv/cmake/FedoraGlsLangHack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,42 @@
if(NOT LSB_RELEASE_ID STREQUAL "fedora")
return()
endif()

# glslang.pc on fedora is unusable due to leading spaces in the file. Find and
# fix (which is a no-op elsewhere), then use.
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/share/pkgconfig)
foreach(_name IN ITEMS glslang spirv)
find_file(
_pc_${_name} ${_name}.pc
PATHS /usr/lib64/pkgconfig /usr/lib/pkgconfig /usr/share/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib64/x86_64-linux-gnu/pkgconfig)
if(EXISTS ${_pc_${_name}})
execute_process(
COMMAND sed "-e" "s/^ *//g" "${_pc_${_name}}"
OUTPUT_FILE ${PROJECT_BINARY_DIR}/share/pkgconfig/${_name}.pc
COMMAND_ERROR_IS_FATAL ANY)
endif()
endforeach()
if(LSB_RELEASE_VERSION_ID LESS_EQUAL 38)
# glslang.pc on fedora is unusable due to leading spaces in the file. Find and
# fix (which is a no-op elsewhere), then use. This error seems to be fixed in
# a later version of pkgconf.
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/share/pkgconfig)
foreach(_name IN ITEMS glslang spirv)
find_file(
_pc_${_name} ${_name}.pc
PATHS /usr/lib64/pkgconfig /usr/lib/pkgconfig /usr/share/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib64/x86_64-linux-gnu/pkgconfig)
if(EXISTS ${_pc_${_name}})
execute_process(
COMMAND sed "-e" "s/^ *//g" "${_pc_${_name}}"
OUTPUT_FILE ${PROJECT_BINARY_DIR}/share/pkgconfig/${_name}.pc
COMMAND_ERROR_IS_FATAL ANY)
endif()
endforeach()
else()
# Fedora fixed the above error in version 39, but they introduced a new one.
# The version of glslang shipped in this versions no longer contains the HLSL
# or OGLCompiler libraries, but those libraries are still listed in the
# pkg-config file as libraries that need to be linked.
# https://bugzilla.redhat.com/show_bug.cgi?id=2308904
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/share/pkgconfig)
foreach(_name IN ITEMS glslang spirv)
find_file(
_pc_${_name} ${_name}.pc
PATHS /usr/lib64/pkgconfig /usr/lib/pkgconfig /usr/share/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib64/x86_64-linux-gnu/pkgconfig)
if(EXISTS ${_pc_${_name}})
execute_process(
COMMAND sed "-e" "s/-lHLSL -lOGLCompiler //g" "${_pc_${_name}}"
OUTPUT_FILE ${PROJECT_BINARY_DIR}/share/pkgconfig/${_name}.pc
COMMAND_ERROR_IS_FATAL ANY)
endif()
endforeach()
endif()

1 comment on commit 7af1bf5

@garybuhrmaster
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The (Fedora/Debian) patch being used for generating the (now broken) pkg-config file was not accepted upstream, but an alternative PR is being worked: KhronosGroup/glslang#3371

Please sign in to comment.