Skip to content
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()