diff options
| author | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
|---|---|---|
| committer | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
| commit | 54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch) | |
| tree | d915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/dlib | |
Diffstat (limited to 'vcpkg/ports/dlib')
| -rw-r--r-- | vcpkg/ports/dlib/find_blas.patch | 13 | ||||
| -rw-r--r-- | vcpkg/ports/dlib/fix-dependencies.patch | 80 | ||||
| -rw-r--r-- | vcpkg/ports/dlib/fix-lapack.patch | 98 | ||||
| -rw-r--r-- | vcpkg/ports/dlib/portfile.cmake | 88 | ||||
| -rw-r--r-- | vcpkg/ports/dlib/vcpkg.json | 48 |
5 files changed, 327 insertions, 0 deletions
diff --git a/vcpkg/ports/dlib/find_blas.patch b/vcpkg/ports/dlib/find_blas.patch new file mode 100644 index 0000000..47b07a4 --- /dev/null +++ b/vcpkg/ports/dlib/find_blas.patch @@ -0,0 +1,13 @@ +diff --git a/dlib/cmake_utils/find_blas.cmake b/dlib/cmake_utils/find_blas.cmake +index 806b938..507f871 100644 +--- a/dlib/cmake_utils/find_blas.cmake ++++ b/dlib/cmake_utils/find_blas.cmake +@@ -438,7 +438,7 @@ endif() + # If using lapack, determine whether to mangle functions + if (lapack_found) + include(CheckFortranFunctionExists) +- set(CMAKE_REQUIRED_LIBRARIES ${lapack_libraries}) ++ set(CMAKE_REQUIRED_LIBRARIES ${lapack_libraries} ${blas_libraries}) + + check_function_exists("sgesv" LAPACK_FOUND_C_UNMANGLED) + check_function_exists("sgesv_" LAPACK_FOUND_C_MANGLED) diff --git a/vcpkg/ports/dlib/fix-dependencies.patch b/vcpkg/ports/dlib/fix-dependencies.patch new file mode 100644 index 0000000..06e17db --- /dev/null +++ b/vcpkg/ports/dlib/fix-dependencies.patch @@ -0,0 +1,80 @@ +diff --git a/dlib/CMakeLists.txt b/dlib/CMakeLists.txt +index cfe6ad9..75cfd54 100644 +--- a/dlib/CMakeLists.txt ++++ b/dlib/CMakeLists.txt +@@ -293,6 +293,7 @@ if (NOT TARGET dlib) + set(dlib_needed_public_ldflags) + set(dlib_needed_private_libraries) + set(dlib_needed_private_includes) ++ set(pkg_config_dlib_requires_private "") + + if (DLIB_ISO_CPP_ONLY) + add_library(dlib ${source_files} ) +@@ -833,6 +834,10 @@ if (NOT TARGET dlib) + + + if (DLIB_LINK_WITH_SQLITE3) ++ find_package(unofficial-sqlite3 CONFIG REQUIRED) ++ list(APPEND dlib_needed_libraries unofficial::sqlite3::sqlite3) ++ string(APPEND pkg_config_dlib_requires_private " sqlite3") ++ elseif(0) + find_library(sqlite sqlite3) + # make sure sqlite3.h is in the include path + find_path(sqlite_path sqlite3.h) +@@ -848,6 +853,10 @@ if (NOT TARGET dlib) + + + if (DLIB_USE_FFTW) ++ find_package(FFTW3 CONFIG REQUIRED) ++ list(APPEND dlib_needed_libraries FFTW3::fftw3) ++ string(APPEND pkg_config_dlib_requires_private " fftw3") ++ elseif(0) + find_library(fftw fftw3) + # make sure fftw3.h is in the include path + find_path(fftw_path fftw3.h) +@@ -998,6 +1007,8 @@ if (NOT TARGET dlib) + + ## dlib-1.pc generation and installation + ++ string (REGEX REPLACE " m " " -lm " pkg_config_dlib_needed_libraries "${pkg_config_dlib_needed_libraries} ") ++ string (REGEX REPLACE "[^ ]*::[^ ]*" "" pkg_config_dlib_needed_libraries "${pkg_config_dlib_needed_libraries}") + configure_file("cmake_utils/dlib.pc.in" "dlib-1.pc" @ONLY) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dlib-1.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") +@@ -1011,7 +1022,7 @@ if (NOT TARGET dlib) + + endif() + +-if (MSVC) ++if (0) + # Give the output library files names that are unique functions of the + # visual studio mode that compiled them. We do this so that people who + # compile dlib and then copy the .lib files around (which they shouldn't be +diff --git a/dlib/cmake_utils/dlib.pc.in b/dlib/cmake_utils/dlib.pc.in +index 9060110..2ec27e8 100644 +--- a/dlib/cmake_utils/dlib.pc.in ++++ b/dlib/cmake_utils/dlib.pc.in +@@ -6,3 +6,4 @@ Description: Numerical and networking C++ library + Version: @VERSION@ + Libs: -L${libdir} -ldlib @pkg_config_dlib_needed_libraries@ + Cflags: -I${includedir} @pkg_config_dlib_needed_includes@ ++Requires.private: @pkg_config_dlib_requires_private@ +diff --git a/dlib/cmake_utils/dlibConfig.cmake.in b/dlib/cmake_utils/dlibConfig.cmake.in +index 2667a2e..cc7b4a2 100644 +--- a/dlib/cmake_utils/dlibConfig.cmake.in ++++ b/dlib/cmake_utils/dlibConfig.cmake.in +@@ -31,6 +31,14 @@ if(NOT TARGET dlib-shared AND NOT dlib_BINARY_DIR) + unset(dlib_deps_threads_check) + endif() + ++include(CMakeFindDependencyMacro) ++if("@DLIB_USE_FFTW@") ++ find_dependency(FFTW3 CONFIG) ++endif() ++if("@DLIB_LINK_WITH_SQLITE3@") ++ find_dependency(unofficial-sqlite3 CONFIG) ++endif() ++ + set(dlib_LIBRARIES dlib::dlib) + set(dlib_LIBS dlib::dlib) + set(dlib_INCLUDE_DIRS "@CMAKE_INSTALL_FULL_INCLUDEDIR@" "@dlib_needed_includes@") diff --git a/vcpkg/ports/dlib/fix-lapack.patch b/vcpkg/ports/dlib/fix-lapack.patch new file mode 100644 index 0000000..6643c09 --- /dev/null +++ b/vcpkg/ports/dlib/fix-lapack.patch @@ -0,0 +1,98 @@ +diff --git a/dlib/CMakeLists.txt b/dlib/CMakeLists.txt +index 5a3135b3b8..0ce2996f9a 100644 +--- a/dlib/CMakeLists.txt ++++ b/dlib/CMakeLists.txt +@@ -612,18 +612,10 @@ if (NOT TARGET dlib) + # Try to find BLAS, LAPACK and MKL + include(cmake_utils/find_blas.cmake) + +- if (DLIB_USE_BLAS) +- if (blas_found) +- list (APPEND dlib_needed_public_libraries ${blas_libraries}) +- else() +- set(DLIB_USE_BLAS OFF CACHE STRING ${DLIB_USE_BLAS_STR} FORCE ) +- toggle_preprocessor_switch(DLIB_USE_BLAS) +- endif() +- endif() +- + if (DLIB_USE_LAPACK) + if (lapack_found) + list (APPEND dlib_needed_public_libraries ${lapack_libraries}) ++ string(APPEND pkg_config_dlib_requires_private " lapack") + if (lapack_with_underscore) + set(LAPACK_FORCE_UNDERSCORE 1) + enable_preprocessor_switch(LAPACK_FORCE_UNDERSCORE) +@@ -637,6 +629,16 @@ if (NOT TARGET dlib) + endif() + endif() + ++ if (DLIB_USE_BLAS) ++ if (blas_found) ++ list (APPEND dlib_needed_public_libraries ${blas_libraries}) ++ string(APPEND pkg_config_dlib_requires_private " blas") ++ else() ++ set(DLIB_USE_BLAS OFF CACHE STRING ${DLIB_USE_BLAS_STR} FORCE ) ++ toggle_preprocessor_switch(DLIB_USE_BLAS) ++ endif() ++ endif() ++ + if (DLIB_USE_MKL_FFT) + if (found_intel_mkl AND found_intel_mkl_headers) + list (APPEND dlib_needed_public_includes ${mkl_include_dir}) +diff --git a/dlib/cmake_utils/dlibConfig.cmake.in b/dlib/cmake_utils/dlibConfig.cmake.in +index cc7b4a21d7..918707a418 100644 +--- a/dlib/cmake_utils/dlibConfig.cmake.in ++++ b/dlib/cmake_utils/dlibConfig.cmake.in +@@ -38,6 +38,8 @@ endif() + if("@DLIB_LINK_WITH_SQLITE3@") + find_dependency(unofficial-sqlite3 CONFIG) + endif() ++find_dependency(BLAS) ++find_dependency(LAPACK) + + set(dlib_LIBRARIES dlib::dlib) + set(dlib_LIBS dlib::dlib) +diff --git a/dlib/cmake_utils/find_blas.cmake b/dlib/cmake_utils/find_blas.cmake +index 21edbdbe42..92858951d8 100644 +--- a/dlib/cmake_utils/find_blas.cmake ++++ b/dlib/cmake_utils/find_blas.cmake +@@ -32,7 +32,7 @@ SET(lapack_without_underscore 0) + message(STATUS "Searching for BLAS and LAPACK") + INCLUDE(CheckFunctionExists) + +-if (UNIX OR MINGW) ++if (0) + message(STATUS "Searching for BLAS and LAPACK") + + if (BUILDING_MATLAB_MEX_FILE) +@@ -296,7 +296,7 @@ if (UNIX OR MINGW) + + + +-elseif(WIN32 AND NOT MINGW) ++elseif(0) + message(STATUS "Searching for BLAS and LAPACK") + + include(CheckTypeSize) +@@ -435,19 +435,18 @@ endif() + if (NOT blas_found) + find_package(BLAS QUIET) + if (${BLAS_FOUND}) +- set(blas_libraries ${BLAS_LIBRARIES}) ++ set(blas_libraries BLAS::BLAS) + set(blas_found 1) + if (NOT lapack_found) + find_package(LAPACK QUIET) + if (${LAPACK_FOUND}) +- set(lapack_libraries ${LAPACK_LIBRARIES}) ++ set(lapack_libraries LAPACK::LAPACK) + set(lapack_found 1) + endif() + endif() + endif() + endif() + +- + # If using lapack, determine whether to mangle functions + if (lapack_found) + include(CheckFortranFunctionExists) diff --git a/vcpkg/ports/dlib/portfile.cmake b/vcpkg/ports/dlib/portfile.cmake new file mode 100644 index 0000000..684be91 --- /dev/null +++ b/vcpkg/ports/dlib/portfile.cmake @@ -0,0 +1,88 @@ +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO davisking/dlib + REF "v${VERSION}" + SHA512 a4bcb2d013bd2b0000530d684c9c4b9f047f9fa6216174b3cb26d96f66c4a302d0bd1733d0ba35626d57133d9159f90114ab51a3af8fb9c493ff3e74dcc73911 + HEAD_REF master + PATCHES + fix-dependencies.patch + find_blas.patch + fix-lapack.patch +) + +file(REMOVE_RECURSE "${SOURCE_PATH}/dlib/external") + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + "sqlite3" DLIB_LINK_WITH_SQLITE3 + "fftw3" DLIB_USE_FFTW + "cuda" DLIB_USE_CUDA +) + +if (VCPKG_TARGET_IS_WINDOWS AND VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") + set(COMMON_OPTIONS -DUSE_SSE2_INSTRUCTIONS=OFF) +endif() + +set(dbg_opts "") +if(VCPKG_TARGET_IS_WINDOWS) + set(dbg_opts -DDLIB_ENABLE_ASSERTS=ON) +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${FEATURE_OPTIONS} + ${COMMON_OPTIONS} + -DDLIB_PNG_SUPPORT=ON + -DCMAKE_REQUIRE_FIND_PACKAGE_PNG=ON + -DDLIB_JPEG_SUPPORT=ON + -DCMAKE_REQUIRE_FIND_PACKAGE_JPEG=ON + -DDLIB_USE_BLAS=ON + -DDLIB_USE_LAPACK=ON + -DDLIB_GIF_SUPPORT=OFF + -DDLIB_WEBP_SUPPORT=OFF + -DDLIB_USE_MKL_FFT=OFF + -DDLIB_USE_FFMPEG=OFF + -DDLIB_NO_GUI_SUPPORT=ON + OPTIONS_DEBUG + ${dbg_opts} + #-DDLIB_ENABLE_STACK_TRACE=ON +) + +vcpkg_cmake_install() + +if(VCPKG_TARGET_IS_WINDOWS) + # Dlib encodes debug/release in its config.h. Patch it to respond to the NDEBUG macro instead. <- The below is using _DEBUG but there is no correct way to switch this on !windows + # Only windows defines _DEBUG in debug builds. + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/dlib/config.h" "/* #undef ENABLE_ASSERTS */" "#if defined(_DEBUG)\n#define ENABLE_ASSERTS\n#endif") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/dlib/config.h" "#define DLIB_DISABLE_ASSERTS" "#if !defined(_DEBUG)\n#define DLIB_DISABLE_ASSERTS\n#endif") +endif() + +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/dlib) + +vcpkg_fixup_pkgconfig() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share/doc") + +# Remove other files not required in package +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/dlib/all") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/dlib/appveyor") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/dlib/test") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/dlib/travis") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/dlib/cmake_utils/test_for_neon") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/dlib/cmake_utils/test_for_cudnn") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/dlib/cmake_utils/test_for_cuda") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/dlib/cmake_utils/test_for_cpp11") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/dlib/cmake_utils/test_for_avx") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/dlib/cmake_utils/test_for_sse4") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/dlib/cmake_utils/test_for_libjpeg") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/dlib/cmake_utils/test_for_libpng") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/dlib/cmake_utils/test_for_libjxl") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/dlib/cmake_utils/test_for_libwebp") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/dlib/external/libpng/arm") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/dlib/LICENSE.txt") diff --git a/vcpkg/ports/dlib/vcpkg.json b/vcpkg/ports/dlib/vcpkg.json new file mode 100644 index 0000000..d348708 --- /dev/null +++ b/vcpkg/ports/dlib/vcpkg.json @@ -0,0 +1,48 @@ +{ + "name": "dlib", + "version": "20.0", + "port-version": 3, + "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", + "supports": "!uwp", + "dependencies": [ + "blas", + "lapack", + "libjpeg-turbo", + "libpng", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + "fftw3", + "sqlite3" + ], + "features": { + "cuda": { + "description": "CUDA support for dlib", + "dependencies": [ + "cuda", + "cudnn" + ] + }, + "fftw3": { + "description": "fftw3 support for dlib", + "dependencies": [ + "fftw3" + ] + }, + "sqlite3": { + "description": "sqlite3 support for dlib", + "dependencies": [ + "sqlite3" + ] + } + } +} |