summaryrefslogtreecommitdiff
path: root/media-libs/libjxl/files/system-lcms.patch
blob: 537e02c35499f4b93ac5cbe7b1377294df56fc54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 280d4af..c9186df 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -127,6 +127,8 @@ set(JPEGXL_FORCE_SYSTEM_BROTLI false CACHE BOOL
     "Force using system installed brotli instead of third_party/brotli source.")
 set(JPEGXL_FORCE_SYSTEM_HWY false CACHE BOOL
     "Force using system installed highway (libhwy-dev) instead of third_party/highway source.")
+set(JPEGXL_FORCE_SYSTEM_LCMS false CACHE BOOL
+    "Force using system installed lcms instead of third_party/lcms source.")
 
 # Check minimum compiler versions. Older compilers are not supported and fail
 # with hard to understand errors.
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index b5e1899..887d31d 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -201,13 +201,23 @@ if (JPEGXL_ENABLE_SKCMS OR JPEGXL_ENABLE_PLUGINS)
   configure_file("${CMAKE_CURRENT_SOURCE_DIR}/skcms/LICENSE"
                  ${PROJECT_BINARY_DIR}/LICENSE.skcms COPYONLY)
 endif ()
-if (JPEGXL_ENABLE_VIEWERS OR NOT JPEGXL_ENABLE_SKCMS)
-  if( NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lcms/.git" )
-    message(SEND_ERROR "Please run git submodule update --init")
+if ((JPEGXL_ENABLE_VIEWERS OR NOT JPEGXL_ENABLE_SKCMS))
+  if(JPEGXL_FORCE_SYSTEM_LCMS)
+    pkg_check_modules(LCMS REQUIRED IMPORTED_TARGET lcms2)
+    add_library(lcms2 INTERFACE IMPORTED GLOBAL)
+    target_link_libraries(lcms2 INTERFACE PkgConfig::LCMS)
+  else()
+    if(JPEGXL_DEP_LICENSE_DIR)
+      configure_file("${JPEGXL_DEP_LICENSE_DIR}/libhwy-dev/copyright"
+                     ${PROJECT_BINARY_DIR}/LICENSE.highway COPYONLY)
+    endif()  # JPEGXL_DEP_LICENSE_DIR
+    if( NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lcms/.git" )
+      message(SEND_ERROR "Please run git submodule update --init")
+    endif()
+    include(lcms2.cmake)
+    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/lcms/COPYING"
+                   ${PROJECT_BINARY_DIR}/LICENSE.lcms COPYONLY)
   endif()
-  include(lcms2.cmake)
-  configure_file("${CMAKE_CURRENT_SOURCE_DIR}/lcms/COPYING"
-                 ${PROJECT_BINARY_DIR}/LICENSE.lcms COPYONLY)
 endif()
 
 # sjpeg