Skip to content

Commit

Permalink
[nsync] Export cmake targets (#23811)
Browse files Browse the repository at this point in the history
* [nsync] Export cmake targets

* version

* Forgot the patch

* version

* Also export the include path

* version
  • Loading branch information
JackBoosY authored Mar 28, 2022
1 parent 16659d0 commit 2be2546
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 8 deletions.
36 changes: 36 additions & 0 deletions ports/nsync/export-targets.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 328f9b6..6a71b5b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,6 +41,9 @@ function (set_cpp_target tgtname files)
"${PROJECT_SOURCE_DIR}/platform/c++11.futex"
)
endif ()
+
+ target_include_directories("${tgtname}" PUBLIC $<INSTALL_INTERFACE:include>)
+

target_compile_definitions ("${tgtname}" PRIVATE "${NSYNC_CPP_DEFINITIONS}")

@@ -399,14 +402,19 @@ endif ()
# By default, install nsync always
# set (CMAKE_SKIP_INSTALL_ALL_DEPENDENCY ON)

-install (TARGETS nsync
+install (TARGETS nsync EXPORT unofficial-nsyncConfig
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development)

-install (TARGETS nsync_cpp OPTIONAL
+install (TARGETS nsync_cpp OPTIONAL EXPORT unofficial-nsyncConfig
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development)

+install(EXPORT unofficial-nsyncConfig
+ NAMESPACE unofficial::nsync::
+ DESTINATION share/unofficial-nsync
+)
+
set (NSYNC_INCLUDES
"public/nsync.h"
"public/nsync_atomic.h"
14 changes: 8 additions & 6 deletions ports/nsync/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ vcpkg_from_github(
HEAD_REF master
PATCHES
fix-install.patch
export-targets.patch
)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DNSYNC_ENABLE_TESTS=OFF
)
vcpkg_install_cmake()
vcpkg_cmake_install()
vcpkg_copy_pdbs()

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-nsync CONFIG_PATH share/unofficial-nsync)

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
14 changes: 13 additions & 1 deletion ports/nsync/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
{
"name": "nsync",
"version": "1.24.0",
"port-version": 1,
"description": "nsync is a C library that exports various synchronization primitives, such as mutexes",
"homepage": "https://github.com/google/nsync"
"homepage": "https://github.com/google/nsync",
"license": "Apache-2.0",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4862,7 +4862,7 @@
},
"nsync": {
"baseline": "1.24.0",
"port-version": 0
"port-version": 1
},
"nt-wrapper": {
"baseline": "2019-08-10",
Expand Down
5 changes: 5 additions & 0 deletions versions/n-/nsync.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "f2333cb932309608aa164aadaacb8d4592c71068",
"version": "1.24.0",
"port-version": 1
},
{
"git-tree": "65f07dbc95a609c95de7befffbf37da598652cee",
"version": "1.24.0",
Expand Down

0 comments on commit 2be2546

Please sign in to comment.