diff options
| author | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
|---|---|---|
| committer | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
| commit | 54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch) | |
| tree | d915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/pthreads | |
Diffstat (limited to 'vcpkg/ports/pthreads')
| -rw-r--r-- | vcpkg/ports/pthreads/PThreads4WConfig.cmake | 179 | ||||
| -rw-r--r-- | vcpkg/ports/pthreads/fix-arm-macro.patch | 13 | ||||
| -rw-r--r-- | vcpkg/ports/pthreads/fix-arm64-version_rc.patch | 22 | ||||
| -rw-r--r-- | vcpkg/ports/pthreads/fix-install.patch | 53 | ||||
| -rw-r--r-- | vcpkg/ports/pthreads/fix-pthread_getname_np.patch | 26 | ||||
| -rw-r--r-- | vcpkg/ports/pthreads/fix-uwp-linkage.patch | 37 | ||||
| -rw-r--r-- | vcpkg/ports/pthreads/portfile.cmake | 68 | ||||
| -rw-r--r-- | vcpkg/ports/pthreads/usage | 4 | ||||
| -rw-r--r-- | vcpkg/ports/pthreads/use-md.patch | 33 | ||||
| -rw-r--r-- | vcpkg/ports/pthreads/use-mt.patch | 33 | ||||
| -rw-r--r-- | vcpkg/ports/pthreads/vcpkg-cmake-wrapper-pthread.cmake | 13 | ||||
| -rw-r--r-- | vcpkg/ports/pthreads/vcpkg-cmake-wrapper-pthreads-windows.cmake | 39 | ||||
| -rw-r--r-- | vcpkg/ports/pthreads/vcpkg-cmake-wrapper-pthreads.cmake | 39 | ||||
| -rw-r--r-- | vcpkg/ports/pthreads/vcpkg.json | 14 | ||||
| -rw-r--r-- | vcpkg/ports/pthreads/whitespace_in_path.patch | 27 |
15 files changed, 600 insertions, 0 deletions
diff --git a/vcpkg/ports/pthreads/PThreads4WConfig.cmake b/vcpkg/ports/pthreads/PThreads4WConfig.cmake new file mode 100644 index 0000000..a3a132e --- /dev/null +++ b/vcpkg/ports/pthreads/PThreads4WConfig.cmake @@ -0,0 +1,179 @@ +#.rst: +# PThreads4W config wrap for vcpkg +# ------------ +# +# Find the PThread4W includes and library. +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This script defines the following variables: +# +# ``PThreads4W_FOUND`` +# True if PThreads4W library found +# +# ``PThreads4W_VERSION`` +# Containing the PThreads4W version tag (manually defined) +# +# ``PThreads4W_INCLUDE_DIR`` +# Location of PThreads4W headers +# +# ``PThreads4W_LIBRARY`` +# List of libraries to link with when using PThreads4W (no exception handling) +# +# ``PThreads4W_CXXEXC_LIBRARY`` +# List of libraries to link with when using PThreads4W (C++ exception handling) +# +# ``PThreads4W_STRUCTEXC_LIBRARY`` +# List of libraries to link with when using PThreads4W (struct exception handling) +# +# Result Targets +# ^^^^^^^^^^^^^^^^ +# +# This script defines the following targets: +# +# ``PThreads4W::PThreads4W`` +# Target to use PThreads4W (no exception handling) +# +# ``PThreads4W::PThreads4W_CXXEXC`` +# Target to use PThreads4W (C++ exception handling) +# +# ``PThreads4W::PThreads4W_STRUCTEXC`` +# Target to use PThreads4W (struct exception handling) +# + +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) +include(${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake) + +if(NOT PThreads4W_INCLUDE_DIR) + find_path(PThreads4W_INCLUDE_DIR NAMES pthread.h PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include" NO_DEFAULT_PATH) +endif() + +set(PThreads4W_MAJOR_VERSION 3) +set(PThreads4W_MINOR_VERSION 0) +set(PThreads4W_PATCH_VERSION 0) +set(PThreads4W_VERSION "${PThreads4W_MAJOR_VERSION}.${PThreads4W_MINOR_VERSION}.${PThreads4W_PATCH_VERSION}") + +# Allow libraries to be set manually +if(NOT PThreads4W_LIBRARY) + find_library(PThreads4W_LIBRARY_RELEASE NAMES pthreadVC${PThreads4W_MAJOR_VERSION} PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib" NO_DEFAULT_PATH) + find_library(PThreads4W_LIBRARY_DEBUG NAMES pthreadVC${PThreads4W_MAJOR_VERSION}d PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib" NO_DEFAULT_PATH) + select_library_configurations(PThreads4W) +endif() +if(NOT PThreads4W_CXXEXC_LIBRARY) + find_library(PThreads4W_CXXEXC_LIBRARY_RELEASE NAMES pthreadVCE${PThreads4W_MAJOR_VERSION} PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib" NO_DEFAULT_PATH) + find_library(PThreads4W_CXXEXC_LIBRARY_DEBUG NAMES pthreadVCE${PThreads4W_MAJOR_VERSION}d PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib" NO_DEFAULT_PATH) + select_library_configurations(PThreads4W_CXXEXC) +endif() +if(NOT PThreads4W_STRUCTEXC_LIBRARY) + find_library(PThreads4W_STRUCTEXC_LIBRARY_RELEASE NAMES pthreadVSE${PThreads4W_MAJOR_VERSION} PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib" NO_DEFAULT_PATH) + find_library(PThreads4W_STRUCTEXC_LIBRARY_DEBUG NAMES pthreadVSE${PThreads4W_MAJOR_VERSION}d PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib" NO_DEFAULT_PATH) + select_library_configurations(PThreads4W_STRUCTEXC) +endif() + +find_package_handle_standard_args(PThreads4W DEFAULT_MSG PThreads4W_LIBRARY PThreads4W_CXXEXC_LIBRARY PThreads4W_STRUCTEXC_LIBRARY PThreads4W_INCLUDE_DIR) +mark_as_advanced(PThreads4W_INCLUDE_DIR PThreads4W_LIBRARY PThreads4W_CXXEXC_LIBRARY PThreads4W_STRUCTEXC_LIBRARY) + +set(PThreads4W_DLL_DIR ${PThreads4W_INCLUDE_DIR}) +list(TRANSFORM PThreads4W_DLL_DIR APPEND "/../bin") +message(STATUS "PThreads4W_DLL_DIR: ${PThreads4W_DLL_DIR}") +set(PThreads4W_DEBUG_DLL_DIR ${PThreads4W_INCLUDE_DIR}) +list(TRANSFORM PThreads4W_DEBUG_DLL_DIR APPEND "/../debug/bin") +message(STATUS "PThreads4W_DEBUG_DLL_DIR: ${PThreads4W_DEBUG_DLL_DIR}") + +find_file(PThreads4W_LIBRARY_RELEASE_DLL NAMES pthreadVC${PThreads4W_MAJOR_VERSION}.dll PATHS ${PThreads4W_DLL_DIR}) +find_file(PThreads4W_LIBRARY_DEBUG_DLL NAMES pthreadVC${PThreads4W_MAJOR_VERSION}d.dll PATHS ${PThreads4W_DEBUG_DLL_DIR}) +find_file(PThreads4W_CXXEXC_LIBRARY_RELEASE_DLL NAMES pthreadVCE${PThreads4W_MAJOR_VERSION}.dll PATHS ${PThreads4W_DLL_DIR}) +find_file(PThreads4W_CXXEXC_LIBRARY_DEBUG_DLL NAMES pthreadVCE${PThreads4W_MAJOR_VERSION}d.dll PATHS ${PThreads4W_DEBUG_DLL_DIR}) +find_file(PThreads4W_STRUCTEXC_LIBRARY_RELEASE_DLL NAMES pthreadVSE${PThreads4W_MAJOR_VERSION}.dll PATHS ${PThreads4W_DLL_DIR}) +find_file(PThreads4W_STRUCTEXC_LIBRARY_DEBUG_DLL NAMES pthreadVSE${PThreads4W_MAJOR_VERSION}d.dll PATHS ${PThreads4W_DEBUG_DLL_DIR}) + +if( PThreads4W_FOUND AND NOT TARGET PThreads4W::PThreads4W_CXXEXC ) + if( EXISTS "${PThreads4W_CXXEXC_LIBRARY_RELEASE_DLL}" ) + add_library( PThreads4W::PThreads4W_CXXEXC SHARED IMPORTED ) + set_target_properties( PThreads4W::PThreads4W_CXXEXC PROPERTIES + IMPORTED_LOCATION_RELEASE "${PThreads4W_CXXEXC_LIBRARY_RELEASE_DLL}" + IMPORTED_IMPLIB "${PThreads4W_CXXEXC_LIBRARY_RELEASE}" + INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" + IMPORTED_CONFIGURATIONS Release + IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) + if( EXISTS "${PThreads4W_CXXEXC_LIBRARY_DEBUG_DLL}" ) + set_property( TARGET PThreads4W::PThreads4W_CXXEXC APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) + set_target_properties( PThreads4W::PThreads4W_CXXEXC PROPERTIES + IMPORTED_LOCATION_DEBUG "${PThreads4W_CXXEXC_LIBRARY_DEBUG_DLL}" + IMPORTED_IMPLIB_DEBUG "${PThreads4W_CXXEXC_LIBRARY_DEBUG}" ) + endif() + else() + add_library( PThreads4W::PThreads4W_CXXEXC UNKNOWN IMPORTED ) + set_target_properties( PThreads4W::PThreads4W_CXXEXC PROPERTIES + IMPORTED_LOCATION_RELEASE "${PThreads4W_CXXEXC_LIBRARY_RELEASE}" + INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" + IMPORTED_CONFIGURATIONS Release + IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) + if( EXISTS "${PThreads4W_CXXEXC_LIBRARY_DEBUG}" ) + set_property( TARGET PThreads4W::PThreads4W_CXXEXC APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) + set_target_properties( PThreads4W::PThreads4W_CXXEXC PROPERTIES + IMPORTED_LOCATION_DEBUG "${PThreads4W_CXXEXC_LIBRARY_DEBUG}" ) + endif() + endif() +endif() + +if( PThreads4W_FOUND AND NOT TARGET PThreads4W::PThreads4W_STRUCTEXC ) + if( EXISTS "${PThreads4W_STRUCTEXC_LIBRARY_RELEASE_DLL}" ) + add_library( PThreads4W::PThreads4W_STRUCTEXC SHARED IMPORTED ) + set_target_properties( PThreads4W::PThreads4W_STRUCTEXC PROPERTIES + IMPORTED_LOCATION_RELEASE "${PThreads4W_STRUCTEXC_LIBRARY_RELEASE_DLL}" + IMPORTED_IMPLIB "${PThreads4W_STRUCTEXC_LIBRARY_RELEASE}" + INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" + IMPORTED_CONFIGURATIONS Release + IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) + if( EXISTS "${PThreads4W_STRUCTEXC_LIBRARY_DEBUG_DLL}" ) + set_property( TARGET PThreads4W::PThreads4W_STRUCTEXC APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) + set_target_properties( PThreads4W::PThreads4W_STRUCTEXC PROPERTIES + IMPORTED_LOCATION_DEBUG "${PThreads4W_STRUCTEXC_LIBRARY_DEBUG_DLL}" + IMPORTED_IMPLIB_DEBUG "${PThreads4W_STRUCTEXC_LIBRARY_DEBUG}" ) + endif() + else() + add_library( PThreads4W::PThreads4W_STRUCTEXC UNKNOWN IMPORTED ) + set_target_properties( PThreads4W::PThreads4W_STRUCTEXC PROPERTIES + IMPORTED_LOCATION_RELEASE "${PThreads4W_STRUCTEXC_LIBRARY_RELEASE}" + INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" + IMPORTED_CONFIGURATIONS Release + IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) + if( EXISTS "${PThreads4W_STRUCTEXC_LIBRARY_DEBUG}" ) + set_property( TARGET PThreads4W::PThreads4W_STRUCTEXC APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) + set_target_properties( PThreads4W::PThreads4W_STRUCTEXC PROPERTIES + IMPORTED_LOCATION_DEBUG "${PThreads4W_STRUCTEXC_LIBRARY_DEBUG}" ) + endif() + endif() +endif() + +if( PThreads4W_FOUND AND NOT TARGET PThreads4W::PThreads4W ) + if( EXISTS "${PThreads4W_LIBRARY_RELEASE_DLL}" ) + add_library( PThreads4W::PThreads4W SHARED IMPORTED ) + set_target_properties( PThreads4W::PThreads4W PROPERTIES + IMPORTED_LOCATION_RELEASE "${PThreads4W_LIBRARY_RELEASE_DLL}" + IMPORTED_IMPLIB "${PThreads4W_LIBRARY_RELEASE}" + INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" + IMPORTED_CONFIGURATIONS Release + IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) + if( EXISTS "${PThreads4W_LIBRARY_DEBUG_DLL}" ) + set_property( TARGET PThreads4W::PThreads4W APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) + set_target_properties( PThreads4W::PThreads4W PROPERTIES + IMPORTED_LOCATION_DEBUG "${PThreads4W_LIBRARY_DEBUG_DLL}" + IMPORTED_IMPLIB_DEBUG "${PThreads4W_LIBRARY_DEBUG}" ) + endif() + else() + add_library( PThreads4W::PThreads4W UNKNOWN IMPORTED ) + set_target_properties( PThreads4W::PThreads4W PROPERTIES + IMPORTED_LOCATION_RELEASE "${PThreads4W_LIBRARY_RELEASE}" + INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" + IMPORTED_CONFIGURATIONS Release + IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) + if( EXISTS "${PThreads4W_LIBRARY_DEBUG}" ) + set_property( TARGET PThreads4W::PThreads4W APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) + set_target_properties( PThreads4W::PThreads4W PROPERTIES + IMPORTED_LOCATION_DEBUG "${PThreads4W_LIBRARY_DEBUG}" ) + endif() + endif() +endif() diff --git a/vcpkg/ports/pthreads/fix-arm-macro.patch b/vcpkg/ports/pthreads/fix-arm-macro.patch new file mode 100644 index 0000000..559b385 --- /dev/null +++ b/vcpkg/ports/pthreads/fix-arm-macro.patch @@ -0,0 +1,13 @@ +diff --git a/context.h b/context.h +index 33294c1..318b689 100644 +--- a/context.h ++++ b/context.h +@@ -62,7 +62,7 @@ + #endif + + #if defined(_ARM_) || defined(ARM) || defined(_M_ARM) || defined(_M_ARM64) +-#define PTW32_PROGCTR(Context) ((Context).Pc) ++#define __PTW32_PROGCTR(Context) ((Context).Pc) + #endif + + #if !defined (__PTW32_PROGCTR) diff --git a/vcpkg/ports/pthreads/fix-arm64-version_rc.patch b/vcpkg/ports/pthreads/fix-arm64-version_rc.patch new file mode 100644 index 0000000..696b1ad --- /dev/null +++ b/vcpkg/ports/pthreads/fix-arm64-version_rc.patch @@ -0,0 +1,22 @@ +diff --git a/version.rc b/version.rc +index aa0596c..9c8231e 100644 +--- a/version.rc ++++ b/version.rc +@@ -63,6 +63,17 @@ + # define __PTW32_VERSIONINFO_NAME "pthreadVSE2.DLL\0" + # define __PTW32_VERSIONINFO_DESCRIPTION "MS C SEH x86\0" + # endif ++# elif defined (__PTW32_ARCHARM64) ++# if defined(__PTW32_CLEANUP_C) ++# define __PTW32_VERSIONINFO_NAME "pthreadVC2.DLL\0" ++# define __PTW32_VERSIONINFO_DESCRIPTION "MS C arm64\0" ++# elif defined(__PTW32_CLEANUP_CXX) ++# define __PTW32_VERSIONINFO_NAME "pthreadVCE2.DLL\0" ++# define __PTW32_VERSIONINFO_DESCRIPTION "MS C++ arm64\0" ++# elif defined(__PTW32_CLEANUP_SEH) ++# define __PTW32_VERSIONINFO_NAME "pthreadVSE2.DLL\0" ++# define __PTW32_VERSIONINFO_DESCRIPTION "MS C SEH arm64\0" ++# endif + # endif + #elif defined(__GNUC__) + # if defined(_M_X64) diff --git a/vcpkg/ports/pthreads/fix-install.patch b/vcpkg/ports/pthreads/fix-install.patch new file mode 100644 index 0000000..afccae9 --- /dev/null +++ b/vcpkg/ports/pthreads/fix-install.patch @@ -0,0 +1,53 @@ +diff --git a/Makefile b/Makefile +index a703b9c..b7b5ea7 100644 +--- a/Makefile ++++ b/Makefile +@@ -80,18 +80,27 @@ help: + @ echo nmake clean VSE-static-debug + + all: ++!IF DEFINED(BUILD_STATIC) ++! IF DEFINED(BUILD_RELEASE) + $(MAKE) /E clean VC-static + $(MAKE) /E clean VCE-static + $(MAKE) /E clean VSE-static ++! ELSE + $(MAKE) /E clean VC-static-debug + $(MAKE) /E clean VCE-static-debug + $(MAKE) /E clean VSE-static-debug ++! ENDIF ++!ELSE ++! IF DEFINED(BUILD_RELEASE) + $(MAKE) /E clean VC + $(MAKE) /E clean VCE + $(MAKE) /E clean VSE ++! ELSE + $(MAKE) /E clean VC-debug + $(MAKE) /E clean VCE-debug + $(MAKE) /E clean VSE-debug ++! ENDIF ++!ENDIF + $(MAKE) /E clean + + TEST_ENV = CFLAGS="$(CFLAGS) /DNO_ERROR_DIALOGS" +@@ -218,8 +227,7 @@ install: + if not exist $(LIBDEST) mkdir $(LIBDEST) + if not exist $(HDRDEST) mkdir $(HDRDEST) + if exist pthreadV*.dll copy pthreadV*.dll $(DLLDEST) +- copy pthreadV*.lib $(LIBDEST) +- copy libpthreadV*.lib $(LIBDEST) ++ if exist pthreadV*.lib copy pthreadV*.lib $(LIBDEST) + copy _ptw32.h $(HDRDEST) + copy pthread.h $(HDRDEST) + copy sched.h $(HDRDEST) +@@ -229,8 +237,8 @@ $(DLLS): $(DLL_OBJS) + $(CC) /LDd /Zi $(DLL_OBJS) /link /implib:$*.lib $(XLIBS) /out:$@ + + $(INLINED_STATIC_STAMPS): $(STATIC_OBJS) +- if exist lib$*.lib del lib$*.lib +- lib $(STATIC_OBJS) /out:lib$*.lib ++ if exist $*.lib del $*.lib ++ lib $(STATIC_OBJS) /out:$*.lib + echo. >$@ + + $(SMALL_STATIC_STAMPS): $(STATIC_OBJS_SMALL) diff --git a/vcpkg/ports/pthreads/fix-pthread_getname_np.patch b/vcpkg/ports/pthreads/fix-pthread_getname_np.patch new file mode 100644 index 0000000..7eaadea --- /dev/null +++ b/vcpkg/ports/pthreads/fix-pthread_getname_np.patch @@ -0,0 +1,26 @@ +diff --git a/pthread_getname_np.c b/pthread_getname_np.c +index 8fc32b1..7c18655 100644 +--- a/pthread_getname_np.c ++++ b/pthread_getname_np.c +@@ -59,10 +59,18 @@ pthread_getname_np(pthread_t thr, char *name, int len) + + __ptw32_mcs_lock_acquire (&tp->threadLock, &threadLock); + +- for (s = tp->name, d = name; *s && d < &name[len - 1]; *d++ = *s++) +- {} ++ if(tp->name) ++ { ++ for (s = tp->name, d = name; *s && d < &name[len - 1]; *d++ = *s++) ++ {} ++ ++ *d = '\0'; ++ } ++ else ++ { ++ *name = '\0'; ++ } + +- *d = '\0'; + __ptw32_mcs_lock_release (&threadLock); + + return result; diff --git a/vcpkg/ports/pthreads/fix-uwp-linkage.patch b/vcpkg/ports/pthreads/fix-uwp-linkage.patch new file mode 100644 index 0000000..22a12f8 --- /dev/null +++ b/vcpkg/ports/pthreads/fix-uwp-linkage.patch @@ -0,0 +1,37 @@ +diff --git a/implement.h b/implement.h +index 1579376..3a7d29b 100644 +--- a/implement.h ++++ b/implement.h +@@ -36,6 +36,12 @@ + #if !defined(_IMPLEMENT_H) + #define _IMPLEMENT_H + ++#if 1 // The condition should be `defined(__cplusplus_winrt)` when compile option is provided correctly. ++// porvide 2 static libs to resolve link error. 'kernel32' and 'windowsapp' ++#pragma comment(lib, "kernel32") ++#pragma comment(lib, "WindowsApp") ++#endif ++ + #if !defined (__PTW32_CONFIG_H) + # error "config.h was not #included" + #endif + +diff --git a/pthread_cancel.c b/pthread_cancel.c +index fddf216..bf16870 100644 +--- a/pthread_cancel.c ++++ b/pthread_cancel.c +@@ -64,12 +64,12 @@ __ptw32_cancel_callback (ULONG_PTR unused) + DWORD + __ptw32_Registercancellation (PAPCFUNC unused1, HANDLE threadH, DWORD unused2) + { +- CONTEXT context; ++ /*CONTEXT context; + + context.ContextFlags = CONTEXT_CONTROL; + GetThreadContext (threadH, &context); + __PTW32_PROGCTR (context) = (DWORD_PTR) __ptw32_cancel_self; +- SetThreadContext (threadH, &context); ++ SetThreadContext (threadH, &context);*/ + return 0; + } + diff --git a/vcpkg/ports/pthreads/portfile.cmake b/vcpkg/ports/pthreads/portfile.cmake new file mode 100644 index 0000000..682ffa0 --- /dev/null +++ b/vcpkg/ports/pthreads/portfile.cmake @@ -0,0 +1,68 @@ +if(NOT VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_MINGW) + set(VCPKG_POLICY_EMPTY_PACKAGE enabled) + return() +endif() + +if(VCPKG_TARGET_IS_UWP) + list(APPEND PATCH_FILES fix-uwp-linkage.patch) + # Inject linker option using the `LINK` environment variable + # https://docs.microsoft.com/en-us/cpp/build/reference/linker-options + # https://docs.microsoft.com/en-us/cpp/build/reference/linking#link-environment-variables + set(ENV{LINK} "/APPCONTAINER") +endif() + +if (VCPKG_CRT_LINKAGE STREQUAL dynamic) + list(APPEND PATCH_FILES use-md.patch) +else() + list(APPEND PATCH_FILES use-mt.patch) +endif() + +vcpkg_from_sourceforge( + OUT_SOURCE_PATH SOURCE_PATH + REPO pthreads4w + FILENAME "pthreads4w-code-v${VERSION}.zip" + SHA512 49e541b66c26ddaf812edb07b61d0553e2a5816ab002edc53a38a897db8ada6d0a096c98a9af73a8f40c94283df53094f76b429b09ac49862465d8697ed20013 + PATCHES + fix-arm-macro.patch + fix-arm64-version_rc.patch # https://sourceforge.net/p/pthreads4w/code/merge-requests/6/ + fix-pthread_getname_np.patch + fix-install.patch + whitespace_in_path.patch + ${PATCH_FILES} +) + +file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}/debug" DESTROOT_DEBUG) +file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}" DESTROOT_RELEASE) + +vcpkg_list(SET OPTIONS_DEBUG "DESTROOT=${DESTROOT_DEBUG}") +vcpkg_list(SET OPTIONS_RELEASE "DESTROOT=${DESTROOT_RELEASE}" "BUILD_RELEASE=1") + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + vcpkg_list(APPEND OPTIONS_DEBUG "BUILD_STATIC=1") + vcpkg_list(APPEND OPTIONS_RELEASE "BUILD_STATIC=1") +endif() + +vcpkg_install_nmake( + CL_LANGUAGE C + SOURCE_PATH "${SOURCE_PATH}" + PROJECT_NAME Makefile + OPTIONS_DEBUG ${OPTIONS_DEBUG} + OPTIONS_RELEASE ${OPTIONS_RELEASE} +) + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") +endif() + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/PThreads4WConfig.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/PThreads4W") +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper-pthread.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/pthread" RENAME vcpkg-cmake-wrapper.cmake) +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper-pthreads.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/pthreads" RENAME vcpkg-cmake-wrapper.cmake) +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper-pthreads-windows.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/PThreads_windows" RENAME vcpkg-cmake-wrapper.cmake) + +file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") + +set(VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS enabled) diff --git a/vcpkg/ports/pthreads/usage b/vcpkg/ports/pthreads/usage new file mode 100644 index 0000000..69dcfd0 --- /dev/null +++ b/vcpkg/ports/pthreads/usage @@ -0,0 +1,4 @@ +The package pthreads provides CMake targets:
+
+ find_package(PThreads4W REQUIRED)
+ target_link_libraries(main PRIVATE PThreads4W::PThreads4W)
diff --git a/vcpkg/ports/pthreads/use-md.patch b/vcpkg/ports/pthreads/use-md.patch new file mode 100644 index 0000000..b25a744 --- /dev/null +++ b/vcpkg/ports/pthreads/use-md.patch @@ -0,0 +1,33 @@ +diff --git a/Makefile b/Makefile +index a703b9c..ff81e7c 100644 +--- a/Makefile ++++ b/Makefile +@@ -173,22 +173,22 @@ VC-debug: + # @ $(MAKE) /E /nologo XCFLAGS="/MTd" EHFLAGS="$(VCFLAGSD) /D__PTW32_STATIC_LIB" CLEANUP=__PTW32_CLEANUP_C pthreadVC$(PTW32_VER_DEBUG).small_static_stamp + + VCE-static: +- @ $(MAKE) /E /nologo XCFLAGS="/MT" EHFLAGS="$(VCEFLAGS) /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_CXX pthreadVCE$(PTW32_VER).inlined_static_stamp ++ @ $(MAKE) /E /nologo XCFLAGS="/MD" EHFLAGS="$(VCEFLAGS) /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_CXX pthreadVCE$(PTW32_VER).inlined_static_stamp + + VCE-static-debug: +- @ $(MAKE) /E /nologo XCFLAGS="/MTd" EHFLAGS="$(VCEFLAGSD) /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_CXX pthreadVCE$(PTW32_VER_DEBUG).inlined_static_stamp ++ @ $(MAKE) /E /nologo XCFLAGS="/MDd" EHFLAGS="$(VCEFLAGSD) /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_CXX pthreadVCE$(PTW32_VER_DEBUG).inlined_static_stamp + + VSE-static: +- @ $(MAKE) /E /nologo XCFLAGS="/MT" EHFLAGS="$(VSEFLAGS) /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_SEH pthreadVSE$(PTW32_VER).inlined_static_stamp ++ @ $(MAKE) /E /nologo XCFLAGS="/MD" EHFLAGS="$(VSEFLAGS) /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_SEH pthreadVSE$(PTW32_VER).inlined_static_stamp + + VSE-static-debug: +- @ $(MAKE) /E /nologo XCFLAGS="/MTd" EHFLAGS="$(VSEFLAGSD) /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_SEH pthreadVSE$(PTW32_VER_DEBUG).inlined_static_stamp ++ @ $(MAKE) /E /nologo XCFLAGS="/MDd" EHFLAGS="$(VSEFLAGSD) /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_SEH pthreadVSE$(PTW32_VER_DEBUG).inlined_static_stamp + + VC-static: +- @ $(MAKE) /E /nologo XCFLAGS="/MT" EHFLAGS="$(VCFLAGS) /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_C pthreadVC$(PTW32_VER).inlined_static_stamp ++ @ $(MAKE) /E /nologo XCFLAGS="/MD" EHFLAGS="$(VCFLAGS) /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_C pthreadVC$(PTW32_VER).inlined_static_stamp + + VC-static-debug: +- @ $(MAKE) /E /nologo XCFLAGS="/MTd" EHFLAGS="$(VCFLAGSD) /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_C pthreadVC$(PTW32_VER_DEBUG).inlined_static_stamp ++ @ $(MAKE) /E /nologo XCFLAGS="/MDd" EHFLAGS="$(VCFLAGSD) /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_C pthreadVC$(PTW32_VER_DEBUG).inlined_static_stamp + + + realclean: clean diff --git a/vcpkg/ports/pthreads/use-mt.patch b/vcpkg/ports/pthreads/use-mt.patch new file mode 100644 index 0000000..41154e0 --- /dev/null +++ b/vcpkg/ports/pthreads/use-mt.patch @@ -0,0 +1,33 @@ +diff --git a/Makefile b/Makefile +index a703b9c..502275f 100644 +--- a/Makefile ++++ b/Makefile +@@ -134,22 +134,22 @@ all-tests-mt: + @ echo $@ completed successfully. + + VCE: +- @ $(MAKE) /E /nologo XCFLAGS="/MD" EHFLAGS="$(VCEFLAGS) /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_CXX pthreadVCE$(PTW32_VER).dll ++ @ $(MAKE) /E /nologo XCFLAGS="/MT" EHFLAGS="$(VCEFLAGS) /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_CXX pthreadVCE$(PTW32_VER).dll + + VCE-debug: +- @ $(MAKE) /E /nologo XCFLAGS="/MDd" EHFLAGS="$(VCEFLAGSD) /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_CXX pthreadVCE$(PTW32_VER_DEBUG).dll ++ @ $(MAKE) /E /nologo XCFLAGS="/MTd" EHFLAGS="$(VCEFLAGSD) /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_CXX pthreadVCE$(PTW32_VER_DEBUG).dll + + VSE: +- @ $(MAKE) /E /nologo XCFLAGS="/MD" EHFLAGS="$(VSEFLAGS) /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_SEH pthreadVSE$(PTW32_VER).dll ++ @ $(MAKE) /E /nologo XCFLAGS="/MT" EHFLAGS="$(VSEFLAGS) /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_SEH pthreadVSE$(PTW32_VER).dll + + VSE-debug: +- @ $(MAKE) /E /nologo XCFLAGS="/MDd" EHFLAGS="$(VSEFLAGSD) /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_SEH pthreadVSE$(PTW32_VER_DEBUG).dll ++ @ $(MAKE) /E /nologo XCFLAGS="/MTd" EHFLAGS="$(VSEFLAGSD) /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_SEH pthreadVSE$(PTW32_VER_DEBUG).dll + + VC: +- @ $(MAKE) /E /nologo XCFLAGS="/MD" EHFLAGS="$(VCFLAGS) /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_C pthreadVC$(PTW32_VER).dll ++ @ $(MAKE) /E /nologo XCFLAGS="/MT" EHFLAGS="$(VCFLAGS) /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_C pthreadVC$(PTW32_VER).dll + + VC-debug: +- @ $(MAKE) /E /nologo XCFLAGS="/MDd" EHFLAGS="$(VCFLAGSD) /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_C pthreadVC$(PTW32_VER_DEBUG).dll ++ @ $(MAKE) /E /nologo XCFLAGS="/MTd" EHFLAGS="$(VCFLAGSD) /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_C pthreadVC$(PTW32_VER_DEBUG).dll + + # + # Static builds diff --git a/vcpkg/ports/pthreads/vcpkg-cmake-wrapper-pthread.cmake b/vcpkg/ports/pthreads/vcpkg-cmake-wrapper-pthread.cmake new file mode 100644 index 0000000..0d0515c --- /dev/null +++ b/vcpkg/ports/pthreads/vcpkg-cmake-wrapper-pthread.cmake @@ -0,0 +1,13 @@ +_find_package(PThreads4W) +set(PTHREAD_INCLUDE_DIR "${PThreads4W_INCLUDE_DIR}") +set(PTHREAD_LIBRARY "${PThreads4W_LIBRARY}") +set(PTHREAD_LIBRARIES "${PThreads4W_LIBRARY}") +set(PTHREAD_VERSION "${PThreads4W_VERSION}") +set(LIBPTHREAD "${PThreads4W_LIBRARY}") +set(LIBPTHREADS "${PThreads4W_LIBRARY}") + +if(PThreads4W_FOUND) + set(PTHREAD_FOUND TRUE) + set(LIBPTHREAD_FOUND TRUE) + set(LIBPTHREADS_FOUND TRUE) +endif() diff --git a/vcpkg/ports/pthreads/vcpkg-cmake-wrapper-pthreads-windows.cmake b/vcpkg/ports/pthreads/vcpkg-cmake-wrapper-pthreads-windows.cmake new file mode 100644 index 0000000..e648ecf --- /dev/null +++ b/vcpkg/ports/pthreads/vcpkg-cmake-wrapper-pthreads-windows.cmake @@ -0,0 +1,39 @@ +_find_package(PThreads4W) +set(PThreads_windows_INCLUDE_DIR "${PThreads4W_INCLUDE_DIR}") +set(PThreads_windows_LIBRARY "${PThreads4W_LIBRARY}") +set(PThreads_windows_LIBRARIES "${PThreads4W_LIBRARY}") +set(PThreads_windows_VERSION "${PThreads4W_VERSION}") + +if(PThreads4W_FOUND) + set(PThreads_windows_FOUND TRUE) + + if(NOT TARGET PThreads_windows::PThreads_windows) + if( EXISTS "${PThreads4W_LIBRARY_RELEASE_DLL}" ) + add_library( PThreads_windows::PThreads_windows SHARED IMPORTED ) + set_target_properties( PThreads_windows::PThreads_windows PROPERTIES + IMPORTED_LOCATION_RELEASE "${PThreads4W_LIBRARY_RELEASE_DLL}" + IMPORTED_IMPLIB "${PThreads4W_LIBRARY_RELEASE}" + INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" + IMPORTED_CONFIGURATIONS Release + IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) + if( EXISTS "${PThreads4W_LIBRARY_DEBUG_DLL}" ) + set_property( TARGET PThreads_windows::PThreads_windows APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) + set_target_properties( PThreads_windows::PThreads_windows PROPERTIES + IMPORTED_LOCATION_DEBUG "${PThreads4W_LIBRARY_DEBUG_DLL}" + IMPORTED_IMPLIB_DEBUG "${PThreads4W_LIBRARY_DEBUG}" ) + endif() + else() + add_library( PThreads_windows::PThreads_windows UNKNOWN IMPORTED ) + set_target_properties( PThreads_windows::PThreads_windows PROPERTIES + IMPORTED_LOCATION_RELEASE "${PThreads4W_LIBRARY_RELEASE}" + INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" + IMPORTED_CONFIGURATIONS Release + IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) + if( EXISTS "${PThreads4W_LIBRARY_DEBUG}" ) + set_property( TARGET PThreads_windows::PThreads_windows APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) + set_target_properties( PThreads_windows::PThreads_windows PROPERTIES + IMPORTED_LOCATION_DEBUG "${PThreads4W_LIBRARY_DEBUG}" ) + endif() + endif() + endif() +endif() diff --git a/vcpkg/ports/pthreads/vcpkg-cmake-wrapper-pthreads.cmake b/vcpkg/ports/pthreads/vcpkg-cmake-wrapper-pthreads.cmake new file mode 100644 index 0000000..453c5c2 --- /dev/null +++ b/vcpkg/ports/pthreads/vcpkg-cmake-wrapper-pthreads.cmake @@ -0,0 +1,39 @@ +_find_package(PThreads4W) +set(pthreads_INCLUDE_DIR "${PThreads4W_INCLUDE_DIR}") +set(pthreads_LIBRARY "${PThreads4W_LIBRARY}") +set(pthreads_LIBRARIES "${PThreads4W_LIBRARY}") +set(pthreads_VERSION "${PThreads4W_VERSION}") + +if(PThreads4W_FOUND) + set(pthreads_FOUND TRUE) + + if(NOT TARGET PThreads_windows::PThreads_windows) + if( EXISTS "${PThreads4W_LIBRARY_RELEASE_DLL}" ) + add_library( PThreads_windows::PThreads_windows SHARED IMPORTED ) + set_target_properties( PThreads_windows::PThreads_windows PROPERTIES + IMPORTED_LOCATION_RELEASE "${PThreads4W_LIBRARY_RELEASE_DLL}" + IMPORTED_IMPLIB "${PThreads4W_LIBRARY_RELEASE}" + INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" + IMPORTED_CONFIGURATIONS Release + IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) + if( EXISTS "${PThreads4W_LIBRARY_DEBUG_DLL}" ) + set_property( TARGET PThreads_windows::PThreads_windows APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) + set_target_properties( PThreads_windows::PThreads_windows PROPERTIES + IMPORTED_LOCATION_DEBUG "${PThreads4W_LIBRARY_DEBUG_DLL}" + IMPORTED_IMPLIB_DEBUG "${PThreads4W_LIBRARY_DEBUG}" ) + endif() + else() + add_library( PThreads_windows::PThreads_windows UNKNOWN IMPORTED ) + set_target_properties( PThreads_windows::PThreads_windows PROPERTIES + IMPORTED_LOCATION_RELEASE "${PThreads4W_LIBRARY_RELEASE}" + INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" + IMPORTED_CONFIGURATIONS Release + IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) + if( EXISTS "${PThreads4W_LIBRARY_DEBUG}" ) + set_property( TARGET PThreads_windows::PThreads_windows APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) + set_target_properties( PThreads_windows::PThreads_windows PROPERTIES + IMPORTED_LOCATION_DEBUG "${PThreads4W_LIBRARY_DEBUG}" ) + endif() + endif() + endif() +endif() diff --git a/vcpkg/ports/pthreads/vcpkg.json b/vcpkg/ports/pthreads/vcpkg.json new file mode 100644 index 0000000..40c9c97 --- /dev/null +++ b/vcpkg/ports/pthreads/vcpkg.json @@ -0,0 +1,14 @@ +{ + "name": "pthreads", + "version": "3.0.0", + "port-version": 14, + "description": "Meta-package that provides PThreads4W on Windows, or assumes presence of system pthreads on POSIX systems.", + "homepage": "https://sourceforge.net/projects/pthreads4w/", + "license": "Apache-2.0", + "dependencies": [ + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/vcpkg/ports/pthreads/whitespace_in_path.patch b/vcpkg/ports/pthreads/whitespace_in_path.patch new file mode 100644 index 0000000..77a24c1 --- /dev/null +++ b/vcpkg/ports/pthreads/whitespace_in_path.patch @@ -0,0 +1,27 @@ +--- a/Makefile Sat Apr 29 09:21:07 2023
++++ b/Makefile Sat Apr 29 09:19:07 2023
+@@ -223,15 +223,15 @@
+
+ # Very basic install. It assumes "realclean" was done just prior to build target.
+ install:
+- if not exist $(DLLDEST) mkdir $(DLLDEST)
+- if not exist $(LIBDEST) mkdir $(LIBDEST)
+- if not exist $(HDRDEST) mkdir $(HDRDEST)
+- if exist pthreadV*.dll copy pthreadV*.dll $(DLLDEST)
+- if exist pthreadV*.lib copy pthreadV*.lib $(LIBDEST)
+- copy _ptw32.h $(HDRDEST)
+- copy pthread.h $(HDRDEST)
+- copy sched.h $(HDRDEST)
+- copy semaphore.h $(HDRDEST)
++ if not exist "$(DLLDEST)" mkdir "$(DLLDEST)"
++ if not exist "$(LIBDEST)" mkdir "$(LIBDEST)"
++ if not exist "$(HDRDEST)" mkdir "$(HDRDEST)"
++ if exist pthreadV*.dll copy pthreadV*.dll "$(DLLDEST)"
++ if exist pthreadV*.lib copy pthreadV*.lib "$(LIBDEST)"
++ copy _ptw32.h "$(HDRDEST)"
++ copy pthread.h "$(HDRDEST)"
++ copy sched.h "$(HDRDEST)"
++ copy semaphore.h "$(HDRDEST)"
+
+ $(DLLS): $(DLL_OBJS)
+ $(CC) /LDd /Zi $(DLL_OBJS) /link /implib:$*.lib $(XLIBS) /out:$@
|