diff --git a/CMakeLists.txt b/CMakeLists.txt index 57a37d3b5..cca3db73d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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) diff --git a/cmake/libdispatch.pc.in b/cmake/libdispatch.pc.in new file mode 100644 index 000000000..801c148cf --- /dev/null +++ b/cmake/libdispatch.pc.in @@ -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} diff --git a/cmake/modules/PkgConfigGeneration.cmake b/cmake/modules/PkgConfigGeneration.cmake new file mode 100644 index 000000000..51b38b44d --- /dev/null +++ b/cmake/modules/PkgConfigGeneration.cmake @@ -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()