parent
75f5d0bbec
commit
4a4017ccdc
2 changed files with 85 additions and 0 deletions
@ -0,0 +1,48 @@ |
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 827ca29..cfd1b9c 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -15,7 +15,7 @@ else ()
|
||||
endif ()
|
||||
|
||||
# Some builds need position-independent code.
|
||||
-set (CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
+
|
||||
|
||||
# Allow nsync users to turn the tests on or off.
|
||||
option (NSYNC_ENABLE_TESTS "Enable for building tests" ON)
|
||||
@@ -90,7 +90,9 @@ endif ()
|
||||
# Pick the include directory for the operating system.
|
||||
if ("${CMAKE_SYSTEM_NAME}X" STREQUAL "WindowsX")
|
||||
include_directories ("${PROJECT_SOURCE_DIR}/platform/win32")
|
||||
- set (NSYNC_CPP_FLAGS "/TP")
|
||||
+ if (MSVC)
|
||||
+ set (NSYNC_CPP_FLAGS "/TP")
|
||||
+ endif()
|
||||
|
||||
set (NSYNC_OS_SRC
|
||||
${NSYNC_POSIX_SRC}
|
||||
@@ -125,7 +127,6 @@ elseif ("${CMAKE_SYSTEM_NAME}X" STREQUAL "DarwinX")
|
||||
${NSYNC_OS_CPP_SRC}
|
||||
"platform/c++11/src/nsync_semaphore_mutex.cc"
|
||||
"platform/posix/src/clock_gettime.c"
|
||||
- "platform/posix/src/nsync_semaphore_mutex.c"
|
||||
)
|
||||
elseif ("${CMAKE_SYSTEM_NAME}X" STREQUAL "LinuxX")
|
||||
set (NSYNC_POSIX ON)
|
||||
@@ -402,11 +403,13 @@ set (CMAKE_SKIP_INSTALL_ALL_DEPENDENCY ON)
|
||||
|
||||
install (TARGETS nsync EXPORT nsync
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries
|
||||
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development)
|
||||
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development
|
||||
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
install (TARGETS nsync_cpp EXPORT nsync_cpp OPTIONAL
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries
|
||||
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development)
|
||||
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development
|
||||
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
set (NSYNC_INCLUDES
|
||||
"public/nsync.h"
|
@ -0,0 +1,37 @@ |
||||
package("nsync") |
||||
set_homepage("https://github.com/google/nsync") |
||||
set_description("nsync is a C library that exports various synchronization primitives, such as mutexes") |
||||
set_license("Apache-2.0") |
||||
|
||||
add_urls("https://github.com/google/nsync/archive/refs/tags/$(version).tar.gz", |
||||
"https://github.com/google/nsync.git") |
||||
|
||||
add_versions("1.28.1", "0011fc00820088793b6a9ba97536173a25cffd3df2dc62616fb3a2824b3c43f5") |
||||
|
||||
add_patches("1.28.1", "patches/1.28.1/cmake.patch", "626a89a5a60884b7aaf44011494e7ba5dbfcdae9fcdb5afcef5b5d1f893b4600") |
||||
|
||||
if is_plat("linux", "bsd") then |
||||
add_syslinks("m", "pthread") |
||||
end |
||||
|
||||
add_deps("cmake") |
||||
|
||||
on_install(function (package) |
||||
local configs = {"-DNSYNC_ENABLE_TESTS=OFF"} |
||||
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) |
||||
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) |
||||
if package:config("shared") and package:is_plat("windows") then |
||||
table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON") |
||||
end |
||||
import("package.tools.cmake").install(package, configs) |
||||
end) |
||||
|
||||
on_test(function (package) |
||||
assert(package:has_cfuncs("nsync_mu_init", {includes = "nsync.h"})) |
||||
assert(package:check_cxxsnippets({test = [[ |
||||
void test() { |
||||
nsync::nsync_mu testing_mu; |
||||
nsync::nsync_mu_init (&testing_mu); |
||||
} |
||||
]]}, {configs = {languages = "c++11"}, includes = "nsync.h"})) |
||||
end) |
Loading…
Reference in new issue