From 17af6e88e7d194b23792b2513571525bcb93689d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 16 Jun 2021 12:50:53 +0200 Subject: [PATCH 1/3] Added upstream pthreads port as overlay to fix the linkage issue microsoft#17011 --- overlay/ports/pthreads/fix-arm-macro.patch | 13 + overlay/ports/pthreads/fix-uwp-linkage.patch | 17 ++ overlay/ports/pthreads/portfile.cmake | 108 +++++++++ overlay/ports/pthreads/usage | 9 + overlay/ports/pthreads/use-md.patch | 33 +++ overlay/ports/pthreads/use-mt.patch | 33 +++ .../ports/pthreads/vcpkg-cmake-wrapper.cmake | 224 ++++++++++++++++++ overlay/ports/pthreads/vcpkg.json | 7 + 8 files changed, 444 insertions(+) create mode 100644 overlay/ports/pthreads/fix-arm-macro.patch create mode 100644 overlay/ports/pthreads/fix-uwp-linkage.patch create mode 100644 overlay/ports/pthreads/portfile.cmake create mode 100644 overlay/ports/pthreads/usage create mode 100644 overlay/ports/pthreads/use-md.patch create mode 100644 overlay/ports/pthreads/use-mt.patch create mode 100644 overlay/ports/pthreads/vcpkg-cmake-wrapper.cmake create mode 100644 overlay/ports/pthreads/vcpkg.json diff --git a/overlay/ports/pthreads/fix-arm-macro.patch b/overlay/ports/pthreads/fix-arm-macro.patch new file mode 100644 index 00000000000000..559b385794729a --- /dev/null +++ b/overlay/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/overlay/ports/pthreads/fix-uwp-linkage.patch b/overlay/ports/pthreads/fix-uwp-linkage.patch new file mode 100644 index 00000000000000..77d3a5b15a5e38 --- /dev/null +++ b/overlay/ports/pthreads/fix-uwp-linkage.patch @@ -0,0 +1,17 @@ +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/overlay/ports/pthreads/portfile.cmake b/overlay/ports/pthreads/portfile.cmake new file mode 100644 index 00000000000000..47493940e6a292 --- /dev/null +++ b/overlay/ports/pthreads/portfile.cmake @@ -0,0 +1,108 @@ +if(NOT VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_MINGW) + set(VCPKG_POLICY_EMPTY_PACKAGE enabled) + return() +endif() + +set(PTHREADS4W_VERSION "3.0.0") + +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${PTHREADS4W_VERSION}.zip" + SHA512 49e541b66c26ddaf812edb07b61d0553e2a5816ab002edc53a38a897db8ada6d0a096c98a9af73a8f40c94283df53094f76b429b09ac49862465d8697ed20013 + PATCHES + fix-arm-macro.patch + ${PATCH_FILES} +) + +find_program(NMAKE nmake REQUIRED) + +################ +# Release build +################ +message(STATUS "Building ${TARGET_TRIPLET}-rel") +file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}" INST_DIR_REL) +vcpkg_execute_required_process( + COMMAND ${NMAKE} -f Makefile all install + "DESTROOT=\"${INST_DIR_REL}\"" + WORKING_DIRECTORY ${SOURCE_PATH} + LOGNAME nmake-build-${TARGET_TRIPLET}-release +) +message(STATUS "Building ${TARGET_TRIPLET}-rel done") + +################ +# Debug build +################ +message(STATUS "Building ${TARGET_TRIPLET}-dbg") +file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}/debug" INST_DIR_DBG) +vcpkg_execute_required_process( + COMMAND ${NMAKE} /G -f Makefile all install + "DESTROOT=\"${INST_DIR_DBG}\"" + WORKING_DIRECTORY ${SOURCE_PATH} + LOGNAME nmake-build-${TARGET_TRIPLET}-debug +) +message(STATUS "Building ${TARGET_TRIPLET}-dbg done") + +file(REMOVE "${CURRENT_PACKAGES_DIR}/bin/pthreadVC3d.dll") +file(REMOVE "${CURRENT_PACKAGES_DIR}/bin/pthreadVCE3d.dll") +file(REMOVE "${CURRENT_PACKAGES_DIR}/bin/pthreadVSE3d.dll") +file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/pthreadVC3.dll") +file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/pthreadVCE3.dll") +file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/pthreadVSE3.dll") + +file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libpthreadVC3d.lib") +file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libpthreadVCE3d.lib") +file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libpthreadVSE3d.lib") +file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVC3.lib") +file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVCE3.lib") +file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVSE3.lib") + +file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/pthreadVC3d.lib") +file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/pthreadVCE3d.lib") +file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/pthreadVSE3d.lib") +file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/pthreadVC3.lib") +file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/pthreadVCE3.lib") +file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/pthreadVSE3.lib") + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libpthreadVC3.lib") + file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libpthreadVCE3.lib") + file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libpthreadVSE3.lib") + file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVC3d.lib") + file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVCE3d.lib") + file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVSE3d.lib") +endif() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin") + file(RENAME ${CURRENT_PACKAGES_DIR}/lib/libpthreadVC3.lib ${CURRENT_PACKAGES_DIR}/lib/pthreadVC3.lib) + file(RENAME ${CURRENT_PACKAGES_DIR}/lib/libpthreadVCE3.lib ${CURRENT_PACKAGES_DIR}/lib/pthreadVCE3.lib) + file(RENAME ${CURRENT_PACKAGES_DIR}/lib/libpthreadVSE3.lib ${CURRENT_PACKAGES_DIR}/lib/pthreadVSE3.lib) + file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVC3d.lib ${CURRENT_PACKAGES_DIR}/debug/lib/pthreadVC3d.lib) + file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVCE3d.lib ${CURRENT_PACKAGES_DIR}/debug/lib/pthreadVCE3d.lib) + file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVSE3d.lib ${CURRENT_PACKAGES_DIR}/debug/lib/pthreadVSE3d.lib) +endif() + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) + +file(COPY ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/pthread) +file(COPY ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/pthreads) +file(COPY ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/pthreads_windows) + +file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) + +set(VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS enabled) diff --git a/overlay/ports/pthreads/usage b/overlay/ports/pthreads/usage new file mode 100644 index 00000000000000..343c97f4406e59 --- /dev/null +++ b/overlay/ports/pthreads/usage @@ -0,0 +1,9 @@ +The package pthreads provides CMake targets: + + find_package(pthreads REQUIRED) + + target_link_libraries(main PRIVATE PThreads4W::PThreads4W) + #or + target_link_libraries(main PRIVATE PThreads4W::PThreads4W_CXXEXC) + #or + target_link_libraries(main PRIVATE PThreads4W::PThreads4W_STRUCTEXC) \ No newline at end of file diff --git a/overlay/ports/pthreads/use-md.patch b/overlay/ports/pthreads/use-md.patch new file mode 100644 index 00000000000000..b25a744a8ce44b --- /dev/null +++ b/overlay/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/overlay/ports/pthreads/use-mt.patch b/overlay/ports/pthreads/use-mt.patch new file mode 100644 index 00000000000000..41154e0311a529 --- /dev/null +++ b/overlay/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/overlay/ports/pthreads/vcpkg-cmake-wrapper.cmake b/overlay/ports/pthreads/vcpkg-cmake-wrapper.cmake new file mode 100644 index 00000000000000..12d390a7ae2182 --- /dev/null +++ b/overlay/ports/pthreads/vcpkg-cmake-wrapper.cmake @@ -0,0 +1,224 @@ +#.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) +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}) + find_library(PThreads4W_LIBRARY_DEBUG NAMES pthreadVC${PThreads4W_MAJOR_VERSION}d) + select_library_configurations(PThreads4W) +endif() +if(NOT PThreads4W_CXXEXC_LIBRARY) + find_library(PThreads4W_CXXEXC_LIBRARY_RELEASE NAMES pthreadVCE${PThreads4W_MAJOR_VERSION}) + find_library(PThreads4W_CXXEXC_LIBRARY_DEBUG NAMES pthreadVCE${PThreads4W_MAJOR_VERSION}d) + select_library_configurations(PThreads4W_CXXEXC) +endif() +if(NOT PThreads4W_STRUCTEXC_LIBRARY) + find_library(PThreads4W_STRUCTEXC_LIBRARY_RELEASE NAMES pthreadVSE${PThreads4W_MAJOR_VERSION}) + find_library(PThreads4W_STRUCTEXC_LIBRARY_DEBUG NAMES pthreadVSE${PThreads4W_MAJOR_VERSION}d) + 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}") + +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_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_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_DLL_DIR}) + +#Compatibility definitions, deprecated +set(PTHREAD_INCLUDE_DIR ${PThreads4W_INCLUDE_DIR} CACHE PATH "") +set(PTHREADS_INCLUDE_DIR ${PThreads4W_INCLUDE_DIR} CACHE PATH "") +set(PThreads_windows_INCLUDE_DIR ${PThreads4W_INCLUDE_DIR} CACHE PATH "") +set(PTHREAD_LIBRARIES ${PThreads4W_LIBRARY} CACHE STRING "") +set(PTHREADS_LIBRARIES ${PThreads4W_LIBRARY} CACHE STRING "") +set(PTHREAD_LIBRARY ${PThreads4W_LIBRARY} CACHE STRING "") +set(PTHREADS_LIBRARY ${PThreads4W_LIBRARY} CACHE STRING "") +set(LIBPTHREAD ${PThreads4W_LIBRARY} CACHE STRING "") +set(LIBPTHREADS ${PThreads4W_LIBRARY} CACHE STRING "") +set(PThreads_windows_LIBRARY ${PThreads4W_LIBRARY} CACHE STRING "") +set(PThreads_VERSION "${PThreads4W_VERSION}") +if(PThreads4W_FOUND) + set(PThreads_windows_FOUND TRUE) +endif() + +#TARGETS +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() + +#Compatibility targets, deprecated +if( PThreads4W_FOUND AND 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() diff --git a/overlay/ports/pthreads/vcpkg.json b/overlay/ports/pthreads/vcpkg.json new file mode 100644 index 00000000000000..77b950b1422229 --- /dev/null +++ b/overlay/ports/pthreads/vcpkg.json @@ -0,0 +1,7 @@ +{ + "name": "pthreads", + "version": "3.0.0", + "port-version": 9, + "description": "pthreads for windows", + "homepage": "https://sourceware.org/pub/pthreads-win32/" +} From 38ad648b2f2af5d4483c81caf39ef21a683e1b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 17 Jun 2021 08:37:23 +0200 Subject: [PATCH 2/3] [pthreads] fix debug dll lookup path --- overlay/ports/pthreads/vcpkg-cmake-wrapper.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/overlay/ports/pthreads/vcpkg-cmake-wrapper.cmake b/overlay/ports/pthreads/vcpkg-cmake-wrapper.cmake index 12d390a7ae2182..f9818d38456d1b 100644 --- a/overlay/ports/pthreads/vcpkg-cmake-wrapper.cmake +++ b/overlay/ports/pthreads/vcpkg-cmake-wrapper.cmake @@ -77,13 +77,16 @@ mark_as_advanced(PThreads4W_INCLUDE_DIR PThreads4W_LIBRARY PThreads4W_CXXEXC_LIB 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_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_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_DLL_DIR}) +find_file(PThreads4W_STRUCTEXC_LIBRARY_DEBUG_DLL NAMES pthreadVSE${PThreads4W_MAJOR_VERSION}d.dll PATHS ${PThreads4W_DEBUG_DLL_DIR}) #Compatibility definitions, deprecated set(PTHREAD_INCLUDE_DIR ${PThreads4W_INCLUDE_DIR} CACHE PATH "") From 38b634979f09aa970edd30a0d347d81e39c2d7c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 18 Jun 2021 10:44:26 +0200 Subject: [PATCH 3/3] bump pthreads vcpkg versio to 11 --- overlay/ports/pthreads/vcpkg.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overlay/ports/pthreads/vcpkg.json b/overlay/ports/pthreads/vcpkg.json index 77b950b1422229..494e6e1dcc3522 100644 --- a/overlay/ports/pthreads/vcpkg.json +++ b/overlay/ports/pthreads/vcpkg.json @@ -1,7 +1,7 @@ { "name": "pthreads", "version": "3.0.0", - "port-version": 9, + "port-version": 11, "description": "pthreads for windows", "homepage": "https://sourceware.org/pub/pthreads-win32/" }