From 9b4daabad53356a4b4b1378d1832938c474da740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Tassoux?= Date: Fri, 23 Oct 2020 20:50:19 +0200 Subject: [PATCH] [directxmesh] Use CMake build system and add dx12 feature (#13976) Co-authored-by: Nicole Mazzuca --- ports/directxmesh/CONTROL | 7 ++- ports/directxmesh/portfile.cmake | 82 ++++++++++---------------------- 2 files changed, 31 insertions(+), 58 deletions(-) diff --git a/ports/directxmesh/CONTROL b/ports/directxmesh/CONTROL index f4470fe6a0..b72a514eb5 100644 --- a/ports/directxmesh/CONTROL +++ b/ports/directxmesh/CONTROL @@ -1,4 +1,9 @@ Source: directxmesh Version: aug2020 +Port-Version: 1 Homepage: https://walbourn.github.io/directxmesh -Description: DirectXMesh geometry processing library \ No newline at end of file +Description: DirectXMesh geometry processing library +Build-Depends: directxmesh[core,dx12](arm64|uwp) + +Feature: dx12 +Description: Build with DirectX12 support for Windows 10 diff --git a/ports/directxmesh/portfile.cmake b/ports/directxmesh/portfile.cmake index 56f6ab6ac4..3017d39e6d 100644 --- a/ports/directxmesh/portfile.cmake +++ b/ports/directxmesh/portfile.cmake @@ -8,68 +8,36 @@ vcpkg_from_github( HEAD_REF master ) -IF (TRIPLET_SYSTEM_ARCH MATCHES "x86") - SET(BUILD_ARCH "Win32") -ELSE() - SET(BUILD_ARCH ${TRIPLET_SYSTEM_ARCH}) -ENDIF() - -if (VCPKG_PLATFORM_TOOLSET STREQUAL "v140") - set(VS_VERSION "2015") -elseif (VCPKG_PLATFORM_TOOLSET STREQUAL "v141") - set(VS_VERSION "2017") -elseif (VCPKG_PLATFORM_TOOLSET STREQUAL "v142") - set(VS_VERSION "2019") -else() - message(FATAL_ERROR "Unsupported platform toolset.") -endif() - -if(VCPKG_TARGET_IS_UWP) - set(SLN_NAME "Windows10_${VS_VERSION}") -else() - if(TRIPLET_SYSTEM_ARCH STREQUAL "arm64") - set(SLN_NAME "Desktop_${VS_VERSION}_Win10") - else() - set(SLN_NAME "Desktop_${VS_VERSION}") - - # fix solution file to include DirectX 12 in build - file(READ ${SOURCE_PATH}/DirectXMesh/DirectXMesh_${SLN_NAME}.vcxproj _contents) - string(REPLACE "_WIN32_WINNT=0x0601" "_WIN32_WINNT=0x0A00" _contents "${_contents}") - file(WRITE ${SOURCE_PATH}/DirectXMesh/DirectXMesh_${SLN_NAME}.vcxproj "${_contents}") - - # fix solution file to include DirectX 12 in build - file(READ ${SOURCE_PATH}/Meshconvert/Meshconvert_${SLN_NAME}.vcxproj _contents) - string(REPLACE "_WIN32_WINNT=0x0601" "_WIN32_WINNT=0x0A00" _contents "${_contents}") - file(WRITE ${SOURCE_PATH}/Meshconvert/Meshconvert_${SLN_NAME}.vcxproj "${_contents}") - endif() -endif() - -vcpkg_build_msbuild( - PROJECT_PATH ${SOURCE_PATH}/DirectXMesh_${SLN_NAME}.sln - PLATFORM ${TRIPLET_SYSTEM_ARCH} +vcpkg_check_features( + OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + dx12 BUILD_DX12 ) -file(INSTALL - ${SOURCE_PATH}/DirectXMesh/DirectXMesh.h - ${SOURCE_PATH}/DirectXMesh/DirectXMesh.inl - DESTINATION ${CURRENT_PACKAGES_DIR}/include +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS ${FEATURE_OPTIONS} ) -file(INSTALL - ${SOURCE_PATH}/DirectXMesh/Bin/${SLN_NAME}/${BUILD_ARCH}/Debug/DirectXMesh.lib - ${SOURCE_PATH}/DirectXMesh/Bin/${SLN_NAME}/${BUILD_ARCH}/Debug/DirectXMesh.pdb - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) -file(INSTALL - ${SOURCE_PATH}/DirectXMesh/Bin/${SLN_NAME}/${BUILD_ARCH}/Release/DirectXMesh.lib - ${SOURCE_PATH}/DirectXMesh/Bin/${SLN_NAME}/${BUILD_ARCH}/Release/DirectXMesh.pdb - DESTINATION ${CURRENT_PACKAGES_DIR}/lib) +if(NOT VCPKG_TARGET_IS_UWP AND NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") + vcpkg_build_cmake() +else() + vcpkg_build_cmake(TARGET DirectXMesh) +endif() -if(NOT VCPKG_TARGET_IS_UWP AND NOT TRIPLET_SYSTEM_ARCH STREQUAL "arm64") - set(TOOL_PATH ${CURRENT_PACKAGES_DIR}/tools/directxmesh) - file(MAKE_DIRECTORY ${TOOL_PATH}) - file(INSTALL - ${SOURCE_PATH}/Meshconvert/Bin/${SLN_NAME}/${BUILD_ARCH}/Release/Meshconvert.exe - DESTINATION ${TOOL_PATH}) +file(INSTALL ${SOURCE_PATH}/DirectXMesh/DirectXMesh.h DESTINATION ${CURRENT_PACKAGES_DIR}/include) +file(INSTALL ${SOURCE_PATH}/DirectXMesh/DirectXMesh.inl DESTINATION ${CURRENT_PACKAGES_DIR}/include) + +file(GLOB_RECURSE DEBUG_LIB ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/bin/CMake/*.lib) +file(GLOB_RECURSE RELEASE_LIB ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bin/CMake/*.lib) +file(INSTALL ${DEBUG_LIB} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) +file(INSTALL ${RELEASE_LIB} DESTINATION ${CURRENT_PACKAGES_DIR}/lib) +if(NOT VCPKG_TARGET_IS_UWP AND NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") + vcpkg_copy_tools( + TOOL_NAMES Meshconvert + SEARCH_DIR ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bin/CMake + ) endif() file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)