1 # Copyright (c) the JPEG XL Project Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style
4 # license that can be found in the LICENSE file.
6 include(jxl_lists.cmake)
8 # Headers for exporting/importing public headers
9 include(GenerateExportHeader)
12 ${JPEGXL_INTERNAL_CMS_SOURCES}
14 target_compile_options(jxl_cms PRIVATE "${JPEGXL_INTERNAL_FLAGS}")
15 set_target_properties(jxl_cms PROPERTIES
16 POSITION_INDEPENDENT_CODE ON
17 CXX_VISIBILITY_PRESET hidden
18 VISIBILITY_INLINES_HIDDEN 1)
19 target_link_libraries(jxl_cms PUBLIC jxl_base)
20 target_include_directories(jxl_cms PRIVATE
21 ${JXL_HWY_INCLUDE_DIRS}
23 generate_export_header(jxl_cms
25 EXPORT_FILE_NAME include/jxl/jxl_cms_export.h)
26 target_include_directories(jxl_cms PUBLIC
27 "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>")
29 set(JPEGXL_CMS_LIBRARY_REQUIRES "")
31 if (JPEGXL_ENABLE_SKCMS)
32 target_link_skcms(jxl_cms)
34 target_link_libraries(jxl_cms PRIVATE lcms2)
35 if (JPEGXL_FORCE_SYSTEM_LCMS2)
36 set(JPEGXL_CMS_LIBRARY_REQUIRES "lcms2")
40 target_link_libraries(jxl_cms PRIVATE hwy)
42 set_target_properties(jxl_cms PROPERTIES
43 VERSION ${JPEGXL_LIBRARY_VERSION}
44 SOVERSION ${JPEGXL_LIBRARY_SOVERSION})
46 # Check whether the linker support excluding libs
47 set(LINKER_EXCLUDE_LIBS_FLAG "-Wl,--exclude-libs=ALL")
48 include(CheckCSourceCompiles)
49 list(APPEND CMAKE_EXE_LINKER_FLAGS ${LINKER_EXCLUDE_LIBS_FLAG})
50 check_c_source_compiles("int main(){return 0;}" LINKER_SUPPORT_EXCLUDE_LIBS)
51 list(REMOVE_ITEM CMAKE_EXE_LINKER_FLAGS ${LINKER_EXCLUDE_LIBS_FLAG})
53 if(LINKER_SUPPORT_EXCLUDE_LIBS)
54 set_property(TARGET jxl_cms APPEND_STRING PROPERTY
55 LINK_FLAGS " ${LINKER_EXCLUDE_LIBS_FLAG}")
58 install(TARGETS jxl_cms
59 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
60 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
61 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
63 if (BUILD_SHARED_LIBS)
64 set(JPEGXL_REQUIRES_TYPE "Requires.private")
65 set(JPEGXL_CMS_PRIVATE_LIBS "-lm ${PKGCONFIG_CXX_LIB}")
67 set(JPEGXL_REQUIRES_TYPE "Requires")
68 set(JPEGXL_CMS_PRIVATE_LIBS "-lm ${PKGCONFIG_CXX_LIB}")
71 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/jxl/libjxl_cms.pc.in"
72 "libjxl_cms.pc" @ONLY)
73 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libjxl_cms.pc"
74 DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")