From 822c1e65122bab60d98067a82367a21ba4715979 Mon Sep 17 00:00:00 2001 From: hmelder Date: Sun, 19 Nov 2023 11:58:09 +0100 Subject: [PATCH 1/8] Add libdispatch.pc.in --- cmake/libdispatch.pc.in | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 cmake/libdispatch.pc.in 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} From f04dee4087e2133415c8094a1ff69a1de0cb1829 Mon Sep 17 00:00:00 2001 From: hmelder Date: Sun, 19 Nov 2023 11:58:32 +0100 Subject: [PATCH 2/8] Add pkgconfig generation --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57a37d3b5..2030d58d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -285,6 +285,10 @@ else() set(INSTALL_OS_HEADERS_DIR "include/os" CACHE PATH "Path where the headers will be installed") endif() +configure_file("${PROJECT_SOURCE_DIR}/cmake/libdispatch.pc.in" + "${PROJECT_BINARY_DIR}/libdispatch.pc") + +install(FILES ${PROJECT_BINARY_DIR}/libdispatch.pc DESTINATION ${INSTALL_LIBDIR}/pkgconfig) add_subdirectory(dispatch) add_subdirectory(man) From 944f0c9ccb45a6d4f4193ce13d0106da3645f035 Mon Sep 17 00:00:00 2001 From: hmelder Date: Sun, 19 Nov 2023 12:12:17 +0100 Subject: [PATCH 3/8] Restrict replacement in libdispatch.pc.in --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2030d58d7..9f368ce7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -286,7 +286,7 @@ else() endif() configure_file("${PROJECT_SOURCE_DIR}/cmake/libdispatch.pc.in" - "${PROJECT_BINARY_DIR}/libdispatch.pc") + "${PROJECT_BINARY_DIR}/libdispatch.pc" @ONLY) install(FILES ${PROJECT_BINARY_DIR}/libdispatch.pc DESTINATION ${INSTALL_LIBDIR}/pkgconfig) From 016f2aa868a10203cee4bb63a07ed36deccfa3bb Mon Sep 17 00:00:00 2001 From: hmelder Date: Sun, 19 Nov 2023 12:15:44 +0100 Subject: [PATCH 4/8] Fix install path of libdispatch.pc --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f368ce7e..547a808bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -288,7 +288,7 @@ endif() configure_file("${PROJECT_SOURCE_DIR}/cmake/libdispatch.pc.in" "${PROJECT_BINARY_DIR}/libdispatch.pc" @ONLY) -install(FILES ${PROJECT_BINARY_DIR}/libdispatch.pc DESTINATION ${INSTALL_LIBDIR}/pkgconfig) +install(FILES ${PROJECT_BINARY_DIR}/libdispatch.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) add_subdirectory(dispatch) add_subdirectory(man) From 16b4ed95caa65652a46260eea61059e115205df3 Mon Sep 17 00:00:00 2001 From: hmelder Date: Sun, 19 Nov 2023 12:20:58 +0100 Subject: [PATCH 5/8] Restrict PC generation to non-apple platforms --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 547a808bb..07bc78a85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -285,10 +285,12 @@ else() set(INSTALL_OS_HEADERS_DIR "include/os" CACHE PATH "Path where the headers will be installed") endif() -configure_file("${PROJECT_SOURCE_DIR}/cmake/libdispatch.pc.in" - "${PROJECT_BINARY_DIR}/libdispatch.pc" @ONLY) +if(NOT APPLE) + configure_file("${PROJECT_SOURCE_DIR}/cmake/libdispatch.pc.in" + "${PROJECT_BINARY_DIR}/libdispatch.pc" @ONLY) -install(FILES ${PROJECT_BINARY_DIR}/libdispatch.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install(FILES ${PROJECT_BINARY_DIR}/libdispatch.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif add_subdirectory(dispatch) add_subdirectory(man) From ae22f7f2c68b8796f693a5b52955f9ca785eea74 Mon Sep 17 00:00:00 2001 From: hmelder Date: Sun, 19 Nov 2023 12:23:06 +0100 Subject: [PATCH 6/8] Add missing () --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07bc78a85..53fcbfc21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -290,7 +290,7 @@ if(NOT APPLE) "${PROJECT_BINARY_DIR}/libdispatch.pc" @ONLY) install(FILES ${PROJECT_BINARY_DIR}/libdispatch.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -endif +endif() add_subdirectory(dispatch) add_subdirectory(man) From be4157c947cfbb4c12eda936a1b327b4c4251ecc Mon Sep 17 00:00:00 2001 From: hmelder Date: Fri, 24 Nov 2023 21:24:19 +0100 Subject: [PATCH 7/8] Move pkg config generation to cmake module --- CMakeLists.txt | 8 +------- cmake/modules/PkgConfigGeneration.cmake | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 cmake/modules/PkgConfigGeneration.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 53fcbfc21..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,13 +286,6 @@ else() set(INSTALL_OS_HEADERS_DIR "include/os" CACHE PATH "Path where the headers will be installed") endif() -if(NOT APPLE) - configure_file("${PROJECT_SOURCE_DIR}/cmake/libdispatch.pc.in" - "${PROJECT_BINARY_DIR}/libdispatch.pc" @ONLY) - - install(FILES ${PROJECT_BINARY_DIR}/libdispatch.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -endif() - add_subdirectory(dispatch) add_subdirectory(man) add_subdirectory(os) diff --git a/cmake/modules/PkgConfigGeneration.cmake b/cmake/modules/PkgConfigGeneration.cmake new file mode 100644 index 000000000..1aea2d9df --- /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() From 82e622baf036e53334bf15ed51a90031c1dd8189 Mon Sep 17 00:00:00 2001 From: hmelder Date: Fri, 24 Nov 2023 21:26:05 +0100 Subject: [PATCH 8/8] PkgConfigGeneration.cmake fix indentation --- cmake/modules/PkgConfigGeneration.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/PkgConfigGeneration.cmake b/cmake/modules/PkgConfigGeneration.cmake index 1aea2d9df..51b38b44d 100644 --- a/cmake/modules/PkgConfigGeneration.cmake +++ b/cmake/modules/PkgConfigGeneration.cmake @@ -12,7 +12,7 @@ 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()