-
Notifications
You must be signed in to change notification settings - Fork 7.7k
[libjpeg-turbo] Patch vcpkg dependencies for 3.2.0 #52891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
17ebbab
41fb84e
91a63a5
5f44fec
9be746e
b666138
1d4b86e
816a4bf
f7ef5cf
9dd768c
be1bb27
808b8b5
12b63c7
bb02239
87954ac
50c6f20
32ddf85
57b099a
af1e9e9
4d62c34
8714cb6
9ac1bd8
924e41f
b8ebb3b
c396cd1
622c0b8
fdfabe3
63ac7fd
46229a2
a3fde3e
3df5533
863daa7
adefe48
5daa276
268667a
b275109
9944b28
12c6dea
8516d07
9fa31bc
ad0427e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
| index a1293dbb..92f981d7 100644 | ||
| --- a/CMakeLists.txt | ||
| +++ b/CMakeLists.txt | ||
| @@ -735,10 +735,22 @@ if(WITH_TURBOJPEG OR WITH_TOOLS OR WITH_TESTS) | ||
| boolean_number(WITH_SYSTEM_SPNG) | ||
| report_option(WITH_SYSTEM_SPNG "System-supplied libspng") | ||
| if(WITH_SYSTEM_SPNG) | ||
| - include(FindPkgConfig) | ||
| - pkg_check_modules(spng REQUIRED spng IMPORTED_TARGET) | ||
| + find_package(SPNG CONFIG QUIET) | ||
| + if(SPNG_FOUND) | ||
| + if(TARGET spng::spng) | ||
| + set(SPNG_TARGET_DEFAULT spng::spng) | ||
| + elseif(TARGET spng::spng_static) | ||
| + set(SPNG_TARGET_DEFAULT spng::spng_static) | ||
| + endif() | ||
| + else() | ||
| + include(FindPkgConfig) | ||
| + pkg_check_modules(spng REQUIRED spng IMPORTED_TARGET) | ||
| + set(SPNG_TARGET_DEFAULT PkgConfig::spng) | ||
| + endif() | ||
| + set(SPNG_TARGET ${SPNG_TARGET_DEFAULT} CACHE STRING | ||
| + "The imported target to use when linking libspng") | ||
| unset(SPNG_STATIC_SOURCES) | ||
| - set(SPNG_LIBRARY PkgConfig::spng) | ||
| + set(SPNG_LIBRARY ${SPNG_TARGET}) | ||
| else() | ||
| option(WITH_SYSTEM_ZLIB | ||
| "Build ${CMAKE_PROJECT_NAME} against the system-supplied zlib implementation rather than the implementation in the ${CMAKE_PROJECT_NAME} source tree" | ||
| diff --git a/release/Config.cmake.in b/release/Config.cmake.in | ||
| index 0c1ba8aa..dedc3617 100644 | ||
| --- a/release/Config.cmake.in | ||
| +++ b/release/Config.cmake.in | ||
| @@ -1,4 +1,24 @@ | ||
| @PACKAGE_INIT@ | ||
|
|
||
| +set(WITH_SYSTEM_SPNG @WITH_SYSTEM_SPNG@) | ||
| +set(WITH_SYSTEM_ZLIB @WITH_SYSTEM_ZLIB@) | ||
| + | ||
| +if(WITH_SYSTEM_SPNG OR WITH_SYSTEM_ZLIB) | ||
| + include(CMakeFindDependencyMacro) | ||
| + if(WITH_SYSTEM_SPNG) | ||
| + set(SPNG_LIBRARY @SPNG_LIBRARY@) | ||
| + if(SPNG_LIBRARY MATCHES "PkgConfig::") | ||
| + find_dependency(PkgConfig) | ||
| + if(PkgConfig_FOUND) | ||
| + pkg_check_modules(spng REQUIRED spng IMPORTED_TARGET) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| + endif() | ||
| + else() | ||
| + find_dependency(SPNG) | ||
| + endif() | ||
| + else() | ||
| + find_dependency(ZLIB) | ||
| + endif() | ||
| +endif() | ||
| + | ||
| include("${CMAKE_CURRENT_LIST_DIR}/@CMAKE_PROJECT_NAME@Targets.cmake") | ||
| check_required_components("@CMAKE_PROJECT_NAME@") | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,9 +1,9 @@ | ||||||||||||||||||||||||||||||||||||||
| libjpeg-turbo is compatible with built-in implementation-agnostic CMake targets: | ||||||||||||||||||||||||||||||||||||||
| find_package(JPEG REQUIRED) | ||||||||||||||||||||||||||||||||||||||
| target_link_libraries(main PRIVATE JPEG::JPEG) | ||||||||||||||||||||||||||||||||||||||
| libjpeg-turbo provides CMake targets for the TurboJPEG C API: | ||||||||||||||||||||||||||||||||||||||
| find_package(libjpeg-turbo CONFIG REQUIRED) | ||||||||||||||||||||||||||||||||||||||
| target_link_libraries(main PRIVATE $<IF:$<TARGET_EXISTS:libjpeg-turbo::turbojpeg>,libjpeg-turbo::turbojpeg,libjpeg-turbo::turbojpeg-static>) | ||||||||||||||||||||||||||||||||||||||
| libjpeg-turbo is compatible with built-in implementation-agnostic CMake targets: | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| find_package(JPEG REQUIRED) | ||||||||||||||||||||||||||||||||||||||
| target_link_libraries(main PRIVATE JPEG::JPEG) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| libjpeg-turbo provides CMake targets for the TurboJPEG C API: | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| find_package(libjpeg-turbo CONFIG REQUIRED) | ||||||||||||||||||||||||||||||||||||||
| target_link_libraries(main PRIVATE $<IF:$<TARGET_EXISTS:libjpeg-turbo::turbojpeg>,libjpeg-turbo::turbojpeg,libjpeg-turbo::turbojpeg-static>) | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When this file is touched, it should re-formatted to align with heuristical output.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,38 @@ | ||
| cmake_policy(PUSH) | ||
| cmake_policy(SET CMP0012 NEW) | ||
| cmake_policy(SET CMP0054 NEW) | ||
| find_path(JPEG_INCLUDE_DIR NAMES jpeglib.h PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include" NO_DEFAULT_PATH) | ||
| find_library(JPEG_LIBRARY_RELEASE NAMES jpeg PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib" NO_DEFAULT_PATH) | ||
| find_library(JPEG_LIBRARY_DEBUG NAMES jpeg PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib" NO_DEFAULT_PATH) | ||
| if(CMAKE_VERSION VERSION_LESS 3.12 AND CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| set(JPEG_LIBRARY "${JPEG_LIBRARY_DEBUG}" CACHE FILEPATH "") | ||
| endif() | ||
| _find_package(${ARGS}) | ||
| if(JPEG_FOUND AND NOT TARGET JPEG::JPEG) | ||
| # Backfill JPEG::JPEG to versions of cmake before 3.12 | ||
| add_library(JPEG::JPEG UNKNOWN IMPORTED) | ||
| if(DEFINED JPEG_INCLUDE_DIRS) | ||
| set_target_properties(JPEG::JPEG PROPERTIES | ||
| INTERFACE_INCLUDE_DIRECTORIES "${JPEG_INCLUDE_DIRS}") | ||
| endif() | ||
| if(EXISTS "${JPEG_LIBRARY}") | ||
| set_target_properties(JPEG::JPEG PROPERTIES | ||
| IMPORTED_LINK_INTERFACE_LANGUAGES "C" | ||
| IMPORTED_LOCATION "${JPEG_LIBRARY}") | ||
| endif() | ||
| if(EXISTS "${JPEG_LIBRARY_RELEASE}") | ||
| set_property(TARGET JPEG::JPEG APPEND PROPERTY | ||
| IMPORTED_CONFIGURATIONS RELEASE) | ||
| set_target_properties(JPEG::JPEG PROPERTIES | ||
| IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" | ||
| IMPORTED_LOCATION_RELEASE "${JPEG_LIBRARY_RELEASE}") | ||
| endif() | ||
| if(EXISTS "${JPEG_LIBRARY_DEBUG}") | ||
| set_property(TARGET JPEG::JPEG APPEND PROPERTY | ||
| IMPORTED_CONFIGURATIONS DEBUG) | ||
| set_target_properties(JPEG::JPEG PROPERTIES | ||
| IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" | ||
| IMPORTED_LOCATION_DEBUG "${JPEG_LIBRARY_DEBUG}") | ||
| endif() | ||
| endif() | ||
| cmake_policy(POP) | ||
| cmake_policy(PUSH) | ||
| cmake_policy(SET CMP0012 NEW) | ||
| cmake_policy(SET CMP0054 NEW) | ||
| find_path(JPEG_INCLUDE_DIR NAMES jpeglib.h PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include" NO_DEFAULT_PATH) | ||
| find_library(JPEG_LIBRARY_RELEASE NAMES jpeg PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib" NO_DEFAULT_PATH) | ||
| find_library(JPEG_LIBRARY_DEBUG NAMES jpeg PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib" NO_DEFAULT_PATH) | ||
| if(CMAKE_VERSION VERSION_LESS 3.12 AND CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| set(JPEG_LIBRARY "${JPEG_LIBRARY_DEBUG}" CACHE FILEPATH "") | ||
| endif() | ||
|
Comment on lines
+7
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the wrapper is touched: CMake 3.12 is no longer supported when using vcpkg. This (and its usage further down) is obsolete. |
||
| _find_package(${ARGS}) | ||
| if(JPEG_FOUND AND NOT TARGET JPEG::JPEG) | ||
| # Backfill JPEG::JPEG to versions of cmake before 3.12 | ||
| add_library(JPEG::JPEG UNKNOWN IMPORTED) | ||
| if(DEFINED JPEG_INCLUDE_DIRS) | ||
| set_target_properties(JPEG::JPEG PROPERTIES | ||
| INTERFACE_INCLUDE_DIRECTORIES "${JPEG_INCLUDE_DIRS}") | ||
| endif() | ||
| if(EXISTS "${JPEG_LIBRARY}") | ||
| set_target_properties(JPEG::JPEG PROPERTIES | ||
| IMPORTED_LINK_INTERFACE_LANGUAGES "C" | ||
| IMPORTED_LOCATION "${JPEG_LIBRARY}") | ||
| endif() | ||
| if(EXISTS "${JPEG_LIBRARY_RELEASE}") | ||
| set_property(TARGET JPEG::JPEG APPEND PROPERTY | ||
| IMPORTED_CONFIGURATIONS RELEASE) | ||
| set_target_properties(JPEG::JPEG PROPERTIES | ||
| IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" | ||
| IMPORTED_LOCATION_RELEASE "${JPEG_LIBRARY_RELEASE}") | ||
| endif() | ||
| if(EXISTS "${JPEG_LIBRARY_DEBUG}") | ||
| set_property(TARGET JPEG::JPEG APPEND PROPERTY | ||
| IMPORTED_CONFIGURATIONS DEBUG) | ||
| set_target_properties(JPEG::JPEG PROPERTIES | ||
| IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" | ||
| IMPORTED_LOCATION_DEBUG "${JPEG_LIBRARY_DEBUG}") | ||
| endif() | ||
| endif() | ||
| cmake_policy(POP) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this still goes against my "do not use imported targets from pkg-config" advise.
Again, the problem is that it works poorly for top-level projects in Windows because typically there is no pkg-config in the
PATH. (It is resolved when building vcpkg ports, but not for top-level projects.)