Fix libjpeg-turbo linking on systems that only have shared libjpeg installed

This commit is contained in:
Georg Hagen
2024-05-30 09:53:07 +02:00
parent 0ce6e31a0d
commit 6761845f99

View File

@@ -26,5 +26,14 @@ function(LinkLibJpegTurbo TARGET)
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/deps_ljt/INSTALL/lib/cmake)
endif()
find_package(libjpeg-turbo REQUIRED)
message("${libjpeg-turbo_LIBRARIES}")
if (TARGET libjpeg-turbo::turbojpeg-static)
target_link_libraries(${TARGET} PUBLIC libjpeg-turbo::turbojpeg-static)
message("Linking static libjpeg-turbo")
elseif (TARGET libjpeg-turbo::turbojpeg)
target_link_libraries(${TARGET} PUBLIC libjpeg-turbo::turbojpeg)
message("Linking shared libjpeg-turbo")
else ()
message(FATAL_ERROR "Neither static nor shared libjpeg-turbo exists")
endif ()
endfunction()