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

Generate pkg-config file during install builds #3371

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
31 changes: 31 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,35 @@ if(ENABLE_GLSLANG_INSTALL)
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
)

# Generate a pkg-config file, so that software projects which use
# pkg-config to locate dependencies can find glslang

# This template is filled-in by CMake's `configure_file(... @ONLY)`.
# The `@...@` are substituted by CMake's configure_file(), either
# from variables set in CMakeLists.txt or by CMake itself.
# (Based on: https://www.scivision.dev/cmake-generate-pkg-config/)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc.in" [=[
prefix="@CMAKE_INSTALL_PREFIX@"
exec_prefix="${prefix}"
libdir="${prefix}/lib"
Copy link

Choose a reason for hiding this comment

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

Please use ${prefix}/@CMAKE_INSTALL_LIBDIR@ to avoid hardcoding 'lib'.

includedir="${prefix}/include"
Copy link

Choose a reason for hiding this comment

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

Please use ${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ for the same reason.


Name: @PROJECT_NAME@
Description: official reference compiler front end for the OpenGL ES and OpenGL shading languages
Version: @PROJECT_VERSION@
Cflags: -I"${includedir}"
Libs: -L"${libdir}" -l@PROJECT_NAME@
]=])
configure_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
@ONLY
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/pkgconfig"
)
endif()