Skip to content

Commit d6864a5

Browse files
committed
Generate pkg-config file during install builds
This commit causes CMake to generate a pkg-config file when ENABLE_GLSLANG_INSTALL is enabled. This allows software projects that use pkg-config (and not CMake) to find external dependencies (e.g., Godot 4.x), to find and properly link to a pre-built glslang package. Closes #1715.
1 parent 7fa0731 commit d6864a5

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

CMakeLists.txt

+30
Original file line numberDiff line numberDiff line change
@@ -370,4 +370,34 @@ if(ENABLE_GLSLANG_INSTALL)
370370
DESTINATION
371371
"${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
372372
)
373+
374+
# Generate a pkg-config file, so that software projects which use
375+
# pkg-config to locate dependencies can find glslang
376+
377+
# This template is filled-in by CMake's `configure_file(... @ONLY)`.
378+
# The `@...@` are substituted by CMake's configure_file(), either
379+
# from variables set in CMakeLists.txt or by CMake itself.
380+
# (Based on: https://www.scivision.dev/cmake-generate-pkg-config/)
381+
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc.in" [=[
382+
prefix="@CMAKE_INSTALL_PREFIX@"
383+
exec_prefix="${prefix}"
384+
libdir="${prefix}/lib"
385+
includedir="${prefix}/include"
386+
387+
Name: @PROJECT_NAME@
388+
Description: official reference compiler front end for the OpenGL ES and OpenGL shading languages
389+
Version: @PROJECT_VERSION@
390+
Cflags: -I"${includedir}"
391+
Libs: -L"${libdir}" -l@PROJECT_NAME@
392+
]=])
393+
configure_file(
394+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc.in"
395+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
396+
@ONLY)
397+
install(
398+
FILES
399+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
400+
DESTINATION
401+
"${CMAKE_INSTALL_LIBDIR}/pkgconfig"
402+
)
373403
endif()

0 commit comments

Comments
 (0)