Repository: microsoft/vcpkg
Pull request #44319: [sleef] Allow to crosscompile
Author: login: daschuer
Labels: name: category:port-feature
description: The issue is with a library, which is requesting new capabilities that didn’t exist
name: info:needs-maintainer-attention
description: Lets the current 'on rotation' vcpkg maintainer know they need to look at this.
Created: 2025-03-11T23:17:47Z | Merged: 2025-03-17T13:29:49Z

- [x] Changes comply with the [maintainer guide](https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/contributing/maintainer-guide.md).
- [x] SHA512s are updated for each updated download.
- [x] The "supports" clause reflects platforms that may be fixed by this new version.
- [x] Any fixed [CI baseline](https://github.com/microsoft/vcpkg/blob/master/scripts/ci.baseline.txt) entries are removed from that file.
- [x] Any patches that are no longer applied are deleted from the port's directory.
- [x] The version database is fixed by rerunning `./vcpkg x-add-version --all` and committing the result.
- [x] Only one version is added to each modified port's versions file.



Diff:
diff --git a/ports/sleef/0001-Add-missing-exe-suffix-for-host-executables.patch b/ports/sleef/0001-Add-missing-exe-suffix-for-host-executables.patch
new file mode 100644
index 00000000000000..f582fbc34d71b5
--- /dev/null
+++ b/ports/sleef/0001-Add-missing-exe-suffix-for-host-executables.patch
@@ -0,0 +1,20 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 6f4f3e8..039e6fc 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -320,7 +320,11 @@ function(add_host_executable TARGETNAME)
+     endif()
+   else()
+     add_executable(${TARGETNAME} IMPORTED GLOBAL)
+-    set_property(TARGET ${TARGETNAME} PROPERTY IMPORTED_LOCATION ${NATIVE_BUILD_DIR}/bin/${TARGETNAME})
++    if(CMAKE_HOST_WIN32)
++      set_property(TARGET ${TARGETNAME} PROPERTY IMPORTED_LOCATION ${NATIVE_BUILD_DIR}/bin/${TARGETNAME}.exe)
++    else()
++      set_property(TARGET ${TARGETNAME} PROPERTY IMPORTED_LOCATION ${NATIVE_BUILD_DIR}/bin/${TARGETNAME})
++    endif()
+   endif()
+ endfunction()
+ 
+-- 
+2.34.1
+
diff --git a/ports/sleef/portfile.cmake b/ports/sleef/portfile.cmake
index e4b3469f1ae238..9b99688472719a 100644
--- a/ports/sleef/portfile.cmake
+++ b/ports/sleef/portfile.cmake
@@ -4,8 +4,15 @@ vcpkg_from_github(
     REF ${VERSION}
     SHA512 218b4e7e2eeb1f9b45e56c2fbb46062480480c55f49b6b0d138d910374e7791c7dd909b964fbf9e2e984a896a3b162eb5aabaaa770692e1db440627e7ad07945
     HEAD_REF master
+    PATCHES
+        0001-Add-missing-exe-suffix-for-host-executables.patch
 )
 
+set(CROSSCOMP_OPTIONS "")
+if(VCPKG_CROSSCOMPILING)
+    set(CROSSCOMP_OPTIONS "-DNATIVE_BUILD_DIR=${CURRENT_HOST_INSTALLED_DIR}/manual-tools/${PORT}")
+endif()
+
 vcpkg_cmake_configure(
     SOURCE_PATH "${SOURCE_PATH}"
     OPTIONS
@@ -14,37 +21,21 @@ vcpkg_cmake_configure(
         -DSLEEF_BUILD_QUAD=ON
         -DSLEEF_BUILD_GNUABI_LIBS=${VCPKG_TARGET_IS_LINUX}
         -DSLEEF_BUILD_TESTS=OFF
-        -DSLEEF_BUILD_INLINE_HEADERS=OFF
+        ${CROSSCOMP_OPTIONS}
 )
 
 vcpkg_cmake_install()
-vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/sleef)
 vcpkg_copy_pdbs()
+if(NOT VCPKG_CROSSCOMPILING)
+    vcpkg_copy_tools(
+        TOOL_NAMES mkrename qmkrename mkalias mkdispatch mkdisp qmkdisp mkunroll 
+        SEARCH_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bin"
+        DESTINATION "${CURRENT_PACKAGES_DIR}/manual-tools/${PORT}/bin"
+        AUTO_CLEAN)
+endif()    
+vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/sleef)
 vcpkg_fixup_pkgconfig()
 
 file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
 file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
 
-# Install DLL and PDB files
-if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
-    if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
-        if(VCPKG_TARGET_IS_WINDOWS)
-            file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bin/sleef.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
-            file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bin/sleef.pdb" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
-            file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bin/sleefdft.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
-            file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bin/sleefdft.pdb" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
-            file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bin/sleefquad.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
-            file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bin/sleefquad.pdb" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
-        endif()
-    endif()
-    if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
-        if(VCPKG_TARGET_IS_WINDOWS)
-            file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/bin/sleef.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
-            file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/bin/sleef.pdb" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
-            file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/bin/sleefdft.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
-            file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/bin/sleefdft.pdb" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
-            file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/bin/sleefquad.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
-            file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/bin/sleefquad.pdb" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
-        endif()
-    endif()
-endif()
diff --git a/ports/sleef/vcpkg.json b/ports/sleef/vcpkg.json
index 8b951be830ad89..3dd3a216b73e2a 100644
--- a/ports/sleef/vcpkg.json
+++ b/ports/sleef/vcpkg.json
@@ -1,11 +1,16 @@
 {
   "name": "sleef",
   "version": "3.8",
+  "port-version": 1,
   "description": "SIMD Library for Evaluating Elementary Functions, vectorized libm and DFT",
   "homepage": "https://sleef.org/",
   "license": "BSL-1.0",
-  "supports": "!uwp & !(arm & windows) & !(arm64 & osx)",
+  "supports": "!(arm & windows)",
   "dependencies": [
+    {
+      "name": "sleef",
+      "host": true
+    },
     {
       "name": "vcpkg-cmake",
       "host": true
diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt
index 0d92379bdfb2dd..43b52077cf0e81 100644
--- a/scripts/ci.baseline.txt
+++ b/scripts/ci.baseline.txt
@@ -1044,7 +1044,6 @@ sjpeg:arm64-android=fail
 sjpeg:x64-android=fail
 sleef:arm-neon-android=fail
 sleef:arm64-android=fail
-sleef:x64-android=fail
 sleef:x86-windows=fail
 slikenet:arm-neon-android=fail
 slikenet:arm64-android=fail
diff --git a/versions/baseline.json b/versions/baseline.json
index 115fce9eba7640..07325bce37d88e 100644
--- a/versions/baseline.json
+++ b/versions/baseline.json
@@ -8546,7 +8546,7 @@
     },
     "sleef": {
       "baseline": "3.8",
-      "port-version": 0
+      "port-version": 1
     },
     "sleepy-discord": {
       "baseline": "2025-02-08",
diff --git a/versions/s-/sleef.json b/versions/s-/sleef.json
index 247a86495f0d63..b2cb95ac069cd6 100644
--- a/versions/s-/sleef.json
+++ b/versions/s-/sleef.json
@@ -1,5 +1,10 @@
 {
   "versions": [
+    {
+      "git-tree": "2cdaa4e9420352cd81759a054a7a19ec1200b336",
+      "version": "3.8",
+      "port-version": 1
+    },
     {
       "git-tree": "c89d656c909c14f1fc6acacfe75c13231d88bcea",
       "version": "3.8",


Reviews:
user: login: dg0yt
body: In several other ports, we put the (cross)build-internal tools into `manual-tools/${PORT}`.
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-12T03:35:48Z
user: login: dg0yt
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-13T07:55:55Z
user: login: Mengna-Li
state: CHANGES_REQUESTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-14T02:37:04Z
user: login: Mengna-Li
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-17T01:08:51Z

Review comments:
diff_hunk: @@ -6,6 +6,11 @@ vcpkg_from_github(
     HEAD_REF master
 )
 
+set(CROSSCOMP_OPTIONS "")
+if(VCPKG_CROSSCOMPILING)
+    set(CROSSCOMP_OPTIONS -DNATIVE_BUILD_DIR="${CURRENT_HOST_INSTALLED_DIR}/tools/${PORT}")
path: ports/sleef/portfile.cmake
user: login: dg0yt
body: Reminder: Quote for cmake language (whole item), not for the shell.
```suggestion
    set(CROSSCOMP_OPTIONS "-DNATIVE_BUILD_DIR=${CURRENT_HOST_INSTALLED_DIR}/tools/${PORT}")
```
created_at: 2025-03-12T02:58:30Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,29 @@
+From 725dd34cc4879b66f05dbb2addfe765bcaa29469 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
+Date: Wed, 12 Mar 2025 08:15:31 +0100
+Subject: [PATCH] Add missing exe suffix for host executables
+
+---
+ CMakeLists.txt | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 6f4f3e8..039e6fc 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -320,7 +320,11 @@ function(add_host_executable TARGETNAME)
+     endif()
+   else()
+     add_executable(${TARGETNAME} IMPORTED GLOBAL)
+-    set_property(TARGET ${TARGETNAME} PROPERTY IMPORTED_LOCATION ${NATIVE_BUILD_DIR}/bin/${TARGETNAME})
++    if(WIN32)
path: ports/sleef/0001-Add-missing-exe-suffix-for-host-executables.patch
user: login: dg0yt
body: ```suggestion
+    if(CMAKE_HOST_WIN32)
```
For cross-build support, you need the host executable suffix.
created_at: 2025-03-13T07:55:34Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,29 @@
+From 725dd34cc4879b66f05dbb2addfe765bcaa29469 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
+Date: Wed, 12 Mar 2025 08:15:31 +0100
+Subject: [PATCH] Add missing exe suffix for host executables
+
+---
+ CMakeLists.txt | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 6f4f3e8..039e6fc 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -320,7 +320,11 @@ function(add_host_executable TARGETNAME)
+     endif()
+   else()
+     add_executable(${TARGETNAME} IMPORTED GLOBAL)
+-    set_property(TARGET ${TARGETNAME} PROPERTY IMPORTED_LOCATION ${NATIVE_BUILD_DIR}/bin/${TARGETNAME})
++    if(CMAKE_HOST_WIN32)
++      set_property(TARGET ${TARGETNAME} PROPERTY IMPORTED_LOCATION ${NATIVE_BUILD_DIR}/bin/${TARGETNAME}.exe)
++    else()
++      set_property(TARGET ${TARGETNAME} PROPERTY IMPORTED_LOCATION ${NATIVE_BUILD_DIR}/bin/${TARGETNAME})
++    endif()
path: ports/sleef/0001-Add-missing-exe-suffix-for-host-executables.patch
user: login: Mengna-Li
body: Can you submit this to the upstream? Then we will wait for the upstream's response or merger.
created_at: 2025-03-14T02:36:01Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,29 @@
+From 725dd34cc4879b66f05dbb2addfe765bcaa29469 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
+Date: Wed, 12 Mar 2025 08:15:31 +0100
+Subject: [PATCH] Add missing exe suffix for host executables
+
+---
+ CMakeLists.txt | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
path: ports/sleef/0001-Add-missing-exe-suffix-for-host-executables.patch
user: login: Mengna-Li
body: Remove these, thank you.
created_at: 2025-03-14T02:36:42Z
author_association: CONTRIBUTOR

PR comments:
user: login: daschuer
created_at: 2025-03-13T07:11:30Z
body: All green, ready to go. 
author_association: CONTRIBUTOR
user: login: daschuer
created_at: 2025-03-15T15:50:39Z
body: https://github.com/shibatch/sleef/pull/660
author_association: CONTRIBUTOR
user: login: daschuer
created_at: 2025-03-15T23:59:05Z
body: The upstream fix has been merged. 
author_association: CONTRIBUTOR