Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions ports/dlib/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment on lines +65 to +70
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR find_dependency() goes through find_package() goes through wrappers. There is no point in layering fragile fixup over poorly maintained patches when we can just fix the patches.

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")
Expand Down
1 change: 1 addition & 0 deletions ports/dlib/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2550,7 +2550,7 @@
},
"dlib": {
"baseline": "20.0.1",
"port-version": 0
"port-version": 1
},
"dlpack": {
"baseline": "1.3",
Expand Down
5 changes: 5 additions & 0 deletions versions/d-/dlib.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "a9c3155cf16d5545fc4e7e3ef1a98537c897bd66",
"version": "20.0.1",
"port-version": 1
},
{
"git-tree": "0eceb3fc9659854e88aa0a6cb2915c62c0fe1bf1",
"version": "20.0.1",
Expand Down