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 libdispatch.pc on non-apple platforms #801

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ include(DispatchSanitization)
include(DispatchCompilerWarnings)
include(DTrace)
include(SwiftSupport)
include(PkgConfigGeneration)

# NOTE(abdulras) this is the CMake supported way to control whether we generate
# shared or static libraries. This impacts the behaviour of `add_library` in
Expand Down Expand Up @@ -285,7 +286,6 @@ else()
set(INSTALL_OS_HEADERS_DIR "include/os" CACHE PATH "Path where the headers will be installed")
endif()


add_subdirectory(dispatch)
add_subdirectory(man)
add_subdirectory(os)
Expand Down
10 changes: 10 additions & 0 deletions cmake/libdispatch.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

Name: libdispatch
Description: libdispatch (a.k.a. Grand Central Dispatch)
Version: @PROJECT_VERSION@
Libs: -L${libdir} -ldispatch
Cflags: -I${includedir}
18 changes: 18 additions & 0 deletions cmake/modules/PkgConfigGeneration.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#.rst:
# PkgConfigGeneration
# -------------------
#
# Generate the pkg-config file for libdispatch.
#
# The script generates a pkg-config file on non-Apple UNIX-like systems.
#

# Check if the system is UNIX-based and not Apple
if(UNIX AND NOT APPLE)
# Configure the pkg-config file from the template
configure_file("${PROJECT_SOURCE_DIR}/cmake/libdispatch.pc.in"
"${PROJECT_BINARY_DIR}/libdispatch.pc" @ONLY)

# Install the generated pkg-config file to the appropriate directory
install(FILES "${PROJECT_BINARY_DIR}/libdispatch.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endif()