diff --git a/ports/dlib/portfile.cmake b/ports/dlib/portfile.cmake index 3eedb5fd720b90..4e52f52167f662 100644 --- a/ports/dlib/portfile.cmake +++ b/ports/dlib/portfile.cmake @@ -62,6 +62,33 @@ endif() vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/dlib) +# Workaround: The fix-dependencies and fix-lapack patches insert find_dependency +# calls for BLAS/LAPACK AFTER the include of the targets file (dlib.cmake) in +# dlibConfig.cmake. CMake fails because LAPACK::LAPACK and BLAS::BLAS are +# referenced in dlib.cmake before they are defined. +# Fix: remove the misplaced calls and inject explicit find_package calls (which +# go through the vcpkg cmake wrappers) before the targets include block. +set(_dlib_config_file "${CURRENT_PACKAGES_DIR}/share/${PORT}/dlibConfig.cmake") +file(READ "${_dlib_config_file}" _dlib_config_contents) +# Remove original misplaced find_dependency calls +string(REPLACE "find_dependency(BLAS) +find_dependency(LAPACK)" "# BLAS/LAPACK: moved before targets include" _dlib_config_contents "${_dlib_config_contents}") +# Insert find_package calls before the targets file include +string(REPLACE "# Our library dependencies (contains definitions for IMPORTED targets)" [[ +find_package(BLAS) +if(NOT TARGET BLAS::BLAS AND BLAS_FOUND AND BLAS_LIBRARIES) + add_library(BLAS::BLAS INTERFACE IMPORTED) + set_target_properties(BLAS::BLAS PROPERTIES INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES}") +endif() +find_package(LAPACK) +if(NOT TARGET LAPACK::LAPACK AND LAPACK_FOUND AND LAPACK_LIBRARIES) + add_library(LAPACK::LAPACK INTERFACE IMPORTED) + set_target_properties(LAPACK::LAPACK PROPERTIES INTERFACE_LINK_LIBRARIES "${LAPACK_LIBRARIES}") +endif() + +# Our library dependencies (contains definitions for IMPORTED targets)]] _dlib_config_contents "${_dlib_config_contents}") +file(WRITE "${_dlib_config_file}" "${_dlib_config_contents}") + vcpkg_fixup_pkgconfig() file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") diff --git a/ports/dlib/vcpkg.json b/ports/dlib/vcpkg.json index bba25d7cceb37e..dccf21776d3b14 100644 --- a/ports/dlib/vcpkg.json +++ b/ports/dlib/vcpkg.json @@ -1,6 +1,7 @@ { "name": "dlib", "version": "20.0.1", + "port-version": 1, "description": "Modern C++ toolkit containing machine learning algorithms and tools for creating complex software in C++", "homepage": "https://github.com/davisking/dlib", "license": "BSL-1.0", diff --git a/versions/baseline.json b/versions/baseline.json index 151cf1ae68eef4..ab8621ea5356af 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -2550,7 +2550,7 @@ }, "dlib": { "baseline": "20.0.1", - "port-version": 0 + "port-version": 1 }, "dlpack": { "baseline": "1.3", diff --git a/versions/d-/dlib.json b/versions/d-/dlib.json index d1df012e8b4c0c..51b4c4d13c79f5 100644 --- a/versions/d-/dlib.json +++ b/versions/d-/dlib.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "a9c3155cf16d5545fc4e7e3ef1a98537c897bd66", + "version": "20.0.1", + "port-version": 1 + }, { "git-tree": "0eceb3fc9659854e88aa0a6cb2915c62c0fe1bf1", "version": "20.0.1",