Bug 358192

Summary: karbon-pdf2svg and krita-jpegimport/export use/link to first libjpeg found, should use jpeg defined by JPEG_LIBRARY and JPEG_INCLUDE_DIR
Product: [Applications] calligracommon Reporter: Hanspeter Niederstrasser <niederstrasser>
Component: generalAssignee: Calligra Bugs <calligra-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Fink Packages   
OS: macOS   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Hanspeter Niederstrasser 2016-01-18 23:09:41 UTC
During cmake configure, cmake finds a jpeg library and saves the library path to JPEG_LIBRARY and the include directory path to JPEG_INCLUDE_DIR.  However, when compiling the modules calligra_filter_pdf2svg.so, kritajpegexport.so, and kritajpegimport.so, it does not add the include path to the compiler command. And during linking , it uses the generic 'jpeg' instead.

It should be possible to add -DJPEG_INCLUDE_DIR -DJPEG_LIBRARY during the configure step and the build should use those in the appropriate locations.

Reproducible: Always




Possible patch.  It makes sure that the desired JPEG_INCLUDE_DIR is known the compiler, and that the correct JPEG_LIBRARY is used.

diff -ruN calligra-2.9.10-orig/filters/karbon/pdf/CMakeLists.txt calligra-2.9.10/filters/karbon/pdf/CMakeLists.txt
--- calligra-2.9.10-orig/filters/karbon/pdf/CMakeLists.txt	2015-12-08 13:09:15.000000000 -0600
+++ calligra-2.9.10/filters/karbon/pdf/CMakeLists.txt	2016-01-18 16:56:54.000000000 -0600
@@ -10,7 +10,8 @@
 
 target_link_libraries(calligra_filter_pdf2svg komain ${POPPLER_LIBRARY} ${POPPLER_CORE_LIBRARY})
 if(JPEG_FOUND)
-    target_link_libraries(calligra_filter_pdf2svg jpeg)
+    include_directories( ${JPEG_INCLUDE_DIR} )
+    target_link_libraries(calligra_filter_pdf2svg ${JPEG_LIBRARY})
 endif()
 if(OPENJPEG_FOUND)
     target_link_libraries(calligra_filter_pdf2svg ${OPENJPEG_LIBRARIES})
diff -ruN calligra-2.9.10-orig/krita/plugins/formats/jpeg/CMakeLists.txt calligra-2.9.10/krita/plugins/formats/jpeg/CMakeLists.txt
--- calligra-2.9.10-orig/krita/plugins/formats/jpeg/CMakeLists.txt	2015-12-08 13:09:17.000000000 -0600
+++ calligra-2.9.10/krita/plugins/formats/jpeg/CMakeLists.txt	2016-01-16 16:50:50.000000000 -0600
@@ -4,6 +4,10 @@
 
 include_directories(${ICCJPEG_SOURCE_DIR})
 
+if(JPEG_FOUND)
+    include_directories( ${JPEG_INCLUDE_DIR} )
+endif()
+
 if(LCMS2_FOUND)
     include_directories( ${LCMS2_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/krita/image/metadata ${EXIV2_INCLUDE_DIR})
 else()
@@ -25,9 +29,9 @@
 kde4_add_plugin(kritajpegimport ${kritajpegimport_PART_SRCS})
 
 if(LCMS2_FOUND)
-    target_link_libraries(kritajpegimport kritaui ${KDE4_KIO_LIBS} jpeg ${LCMS2_LIBRARIES} ${EXIV2_LIBRARIES} )
+    target_link_libraries(kritajpegimport kritaui ${KDE4_KIO_LIBS} ${JPEG_LIBRARY} ${LCMS2_LIBRARIES} ${EXIV2_LIBRARIES} )
 else()
-    target_link_libraries(kritajpegimport kritaui ${KDE4_KIO_LIBS} jpeg ${LCMS_LIBRARIES} ${EXIV2_LIBRARIES} )
+    target_link_libraries(kritajpegimport kritaui ${KDE4_KIO_LIBS} ${JPEG_LIBRARY} ${LCMS_LIBRARIES} ${EXIV2_LIBRARIES} )
 endif()
 
 install(TARGETS kritajpegimport  DESTINATION ${PLUGIN_INSTALL_DIR})
@@ -44,9 +48,9 @@
 kde4_add_plugin(kritajpegexport ${kritajpegexport_PART_SRCS})
 
 if(LCMS2_FOUND)
-    target_link_libraries(kritajpegexport kritaui  ${KDE4_KIO_LIBS} jpeg ${LCMS2_LIBRARIES} ${EXIV2_LIBRARIES} )
+    target_link_libraries(kritajpegexport kritaui  ${KDE4_KIO_LIBS} ${JPEG_LIBRARY} ${LCMS2_LIBRARIES} ${EXIV2_LIBRARIES} )
 else()
-    target_link_libraries(kritajpegexport kritaui  ${KDE4_KIO_LIBS} jpeg ${LCMS_LIBRARIES} ${EXIV2_LIBRARIES} )
+    target_link_libraries(kritajpegexport kritaui  ${KDE4_KIO_LIBS} ${JPEG_LIBRARY} ${LCMS_LIBRARIES} ${EXIV2_LIBRARIES} )
 endif()
 
 install(TARGETS kritajpegexport  DESTINATION ${PLUGIN_INSTALL_DIR})
diff -ruN calligra-2.9.10-orig/krita/plugins/formats/jpeg/tests/CMakeLists.txt calligra-2.9.10/krita/plugins/formats/jpeg/tests/CMakeLists.txt
--- calligra-2.9.10-orig/krita/plugins/formats/jpeg/tests/CMakeLists.txt	2015-12-08 13:09:17.000000000 -0600
+++ calligra-2.9.10/krita/plugins/formats/jpeg/tests/CMakeLists.txt	2016-01-16 15:30:12.000000000 -0600
@@ -1,6 +1,10 @@
 set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
 include_directories(     ${CMAKE_SOURCE_DIR}/krita/sdk/tests )
 
+if(JPEG_FOUND)
+    include_directories( ${JPEG_INCLUDE_DIR} )
+endif()
+
 macro_add_unittest_definitions()
 
 ########### next target ###############
Comment 1 Halla Rempt 2016-01-19 07:26:45 UTC
Git commit 3ddc07013e9f0896141ce55827b4ff6c10817905 by Boudewijn Rempt.
Committed on 19/01/2016 at 07:26.
Pushed by rempt into branch 'calligra/2.9'.

Link against the jpeg library CMake found, not the system one

The master branch in krita.git already had this fix.

M  +4    -4    krita/plugins/formats/jpeg/CMakeLists.txt

http://commits.kde.org/calligra/3ddc07013e9f0896141ce55827b4ff6c10817905
Comment 2 Justin Zobel 2021-03-09 01:22:32 UTC
Thank you for the bug report.

As this report hasn't seen any changes in 5 years or more, we ask if you can please confirm that the issue still persists.

If this bug is no longer persisting or relevant please change the status to resolved.
Comment 3 Hanspeter Niederstrasser 2021-03-11 11:51:40 UTC
Looks like http://commits.kde.org/calligra/3ddc07013e9f0896141ce55827b4ff6c10817905 took care of the opportunistic linking in kritajpegimport/export and pdf2svg plugin no longer uses jpeg.