[dlib] Fix pc file, cleanup, drop lib suffixes for MSVC (#25997)

* Minor cleanup, drop debug postfix

* Force finding packages without patch

* Trim and rename dependencies patch

* Fix pc file, disable MSVC config postfix

* Disable random libwebp dependency

* Update versions
This commit is contained in:
Kai Pastor 2022-08-06 08:25:53 +02:00 committed by GitHub
parent 4614a12dd2
commit dba0645e88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 93 additions and 119 deletions

View File

@ -0,0 +1,80 @@
diff --git a/dlib/CMakeLists.txt b/dlib/CMakeLists.txt
index 9f3001d..962cfc4 100644
--- a/dlib/CMakeLists.txt
+++ b/dlib/CMakeLists.txt
@@ -287,6 +287,7 @@ if (NOT TARGET dlib)
set(dlib_needed_libraries)
set(dlib_needed_includes)
+ set(pkg_config_dlib_requires_private "")
if (DLIB_ISO_CPP_ONLY)
add_library(dlib ${source_files} )
@@ -814,6 +815,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)
@@ -829,6 +834,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)
@@ -964,6 +973,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")
@@ -977,7 +988,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@")

View File

@ -1,60 +0,0 @@
diff --git a/dlib/CMakeLists.txt b/dlib/CMakeLists.txt
index 9f3001d..962cfc4 100644
--- a/dlib/CMakeLists.txt
+++ b/dlib/CMakeLists.txt
@@ -814,32 +814,15 @@ if (NOT TARGET dlib)
if (DLIB_LINK_WITH_SQLITE3)
- find_library(sqlite sqlite3)
- # make sure sqlite3.h is in the include path
- find_path(sqlite_path sqlite3.h)
- if (sqlite AND sqlite_path)
- set(dlib_needed_includes ${dlib_needed_includes} ${sqlite_path})
- set(dlib_needed_libraries ${dlib_needed_libraries} ${sqlite} )
- else()
- set(DLIB_LINK_WITH_SQLITE3 OFF CACHE STRING ${DLIB_LINK_WITH_SQLITE3_STR} FORCE )
- endif()
- mark_as_advanced(sqlite sqlite_path)
+ find_package(unofficial-sqlite3 CONFIG)
+ set(dlib_needed_libraries ${dlib_needed_libraries} unofficial::sqlite3::sqlite3)
endif()
if (DLIB_USE_FFTW)
- find_library(fftw fftw3)
- # make sure fftw3.h is in the include path
- find_path(fftw_path fftw3.h)
- if (fftw AND fftw_path)
- set(dlib_needed_includes ${dlib_needed_includes} ${fftw_path})
- set(dlib_needed_libraries ${dlib_needed_libraries} ${fftw} )
- else()
- set(DLIB_USE_FFTW OFF CACHE STRING ${DLIB_USE_FFTW_STR} FORCE )
- toggle_preprocessor_switch(DLIB_USE_FFTW)
- endif()
- mark_as_advanced(fftw fftw_path)
+ find_package(FFTW3 CONFIG)
+ set(dlib_needed_libraries ${dlib_needed_libraries} FFTW3::fftw3)
endif()
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@")

View File

@ -1,44 +0,0 @@
diff --git a/dlib/cmake_utils/find_libjpeg.cmake b/dlib/cmake_utils/find_libjpeg.cmake
index 3b9e656..d741f31 100644
--- a/dlib/cmake_utils/find_libjpeg.cmake
+++ b/dlib/cmake_utils/find_libjpeg.cmake
@@ -14,7 +14,7 @@ if (DEFINED JPEG_FOUND)
return()
endif()
-find_package(JPEG QUIET)
+find_package(JPEG REQUIRED)
if(JPEG_FOUND)
set(JPEG_TEST_CMAKE_FLAGS
@@ -31,7 +31,7 @@ if(JPEG_FOUND)
message (STATUS "Found system copy of libjpeg: ${JPEG_LIBRARY}")
if(NOT test_for_libjpeg_worked)
set(JPEG_FOUND 0)
- message (STATUS "System copy of libjpeg is broken or too old. Will build our own libjpeg and use that instead.")
+ message (FATAL_ERROR "System copy of libjpeg is broken or too old. Will build our own libjpeg and use that instead.")
endif()
endif()
diff --git a/dlib/cmake_utils/find_libpng.cmake b/dlib/cmake_utils/find_libpng.cmake
index 1b35604..489a4c8 100644
--- a/dlib/cmake_utils/find_libpng.cmake
+++ b/dlib/cmake_utils/find_libpng.cmake
@@ -14,7 +14,7 @@ if (DEFINED PNG_FOUND)
return()
endif()
-find_package(PNG QUIET)
+find_package(PNG REQUIRED)
if(PNG_FOUND)
set(PNG_TEST_CMAKE_FLAGS
@@ -31,7 +31,7 @@ if(PNG_FOUND)
message (STATUS "Found system copy of libpng: ${PNG_LIBRARIES}")
if(NOT test_for_libpng_worked)
set(PNG_FOUND 0)
- message (STATUS "System copy of libpng is broken. Will build our own libpng and use that instead.")
+ message (FATAL_ERROR "System copy of libpng is broken. Will build our own libpng and use that instead.")
endif()
endif()

View File

@ -7,19 +7,11 @@ vcpkg_from_github(
SHA512 4bdcecdf0f986abc748245d21616bf2c304461e9a37572c66743f69141fc3f37eb846fdaedc6c910135d986534f7989cbcc52a884ae7a52464fbb2a07b16a327
HEAD_REF master
PATCHES
fix-sqlite3-fftw-linkage.patch
force_finding_packages.patch
fix-dependencies.patch
find_blas.patch
)
file(REMOVE_RECURSE "${SOURCE_PATH}/dlib/external/libjpeg")
file(REMOVE_RECURSE "${SOURCE_PATH}/dlib/external/libpng")
file(REMOVE_RECURSE "${SOURCE_PATH}/dlib/external/zlib")
# This fixes static builds; dlib doesn't pull in the needed transitive dependencies
file(READ "${SOURCE_PATH}/dlib/CMakeLists.txt" DLIB_CMAKE)
string(REPLACE "PNG_LIBRARY" "PNG_LIBRARIES" DLIB_CMAKE "${DLIB_CMAKE}")
file(WRITE "${SOURCE_PATH}/dlib/CMakeLists.txt" "${DLIB_CMAKE}")
file(REMOVE_RECURSE "${SOURCE_PATH}/dlib/external")
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
@ -33,12 +25,14 @@ vcpkg_cmake_configure(
OPTIONS
${FEATURE_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
-DCMAKE_DEBUG_POSTFIX=d
OPTIONS_DEBUG
-DDLIB_ENABLE_ASSERTS=ON
#-DDLIB_ENABLE_STACK_TRACE=ON
@ -50,9 +44,9 @@ vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/dlib)
vcpkg_fixup_pkgconfig()
# There is no way to suppress installation of the headers and resource files in debug build.
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")
@ -73,6 +67,4 @@ file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/dlib/external/libpng/arm")
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")
# Handle copyright
file(INSTALL "${SOURCE_PATH}/dlib/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share/doc")

View File

@ -1,6 +1,7 @@
{
"name": "dlib",
"version": "19.24",
"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",

View File

@ -1950,7 +1950,7 @@
},
"dlib": {
"baseline": "19.24",
"port-version": 0
"port-version": 1
},
"dmlc": {
"baseline": "2019-08-12",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "975dbde01f120a124488aae7930005b4b0409e58",
"version": "19.24",
"port-version": 1
},
{
"git-tree": "69c4335588e3785a09f580a40c128bf4d1bc5339",
"version": "19.24",