Skip to content

Commit

Permalink
Drop jxl_cms-static (libjxl#2916)
Browse files Browse the repository at this point in the history
  • Loading branch information
eustas authored Oct 31, 2023
1 parent d67fa35 commit 5b52fd6
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 73 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ jobs:
-DJPEGXL_ENABLE_TRANSCODE_JPEG=OFF
-DJPEGXL_ENABLE_PLUGINS=OFF
-DJPEGXL_ENABLE_VIEWERS=OFF
# Build with jxl_cms based on lcms2 library.
- name: release-lcms2
mode: release
cmake_args: >-
-DJPEGXL_ENABLE_SKCMS=OFF
apt_pkgs: liblcms2-2
# Build optimized for binary size, all features not needed for
# reconstructing pixels is disabled.
- name: release:minimal
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build_test_md.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- name: scalar
- name: asan
- name: release-nojpeg
- name: release-lcms2
- name: release:gcc8
runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 4 additions & 4 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ target_link_libraries(encode_oneshot PkgConfig::Jxl PkgConfig::JxlCms PkgConfig:
# depends on the platform, and building static binaries in general has problems.
# If you don't need static binaries you can remove this section.
add_library(StaticJxl INTERFACE IMPORTED GLOBAL)
list(REMOVE_ITEM Jxl_STATIC_LDFLAGS "-ljxl_cms")

set_target_properties(StaticJxl PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Jxl_STATIC_INCLUDE_DIR}"
INTERFACE_COMPILE_OPTIONS "${Jxl_STATIC_CFLAGS_OTHER}"
Expand All @@ -48,9 +50,7 @@ set_target_properties(StaticJxlThreads PROPERTIES
)

add_executable(decode_oneshot_static decode_oneshot.cc)
target_link_libraries(decode_oneshot_static
-static StaticJxl StaticJxlThreads)
target_link_libraries(decode_oneshot_static -static StaticJxl StaticJxlThreads)

add_executable(encode_oneshot_static encode_oneshot.cc)
target_link_libraries(encode_oneshot_static
-static StaticJxl StaticJxlThreads)
target_link_libraries(encode_oneshot_static -static StaticJxl StaticJxlThreads)
6 changes: 3 additions & 3 deletions examples/examples.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# license that can be found in the LICENSE file.

add_executable(decode_oneshot ${CMAKE_CURRENT_LIST_DIR}/decode_oneshot.cc)
target_link_libraries(decode_oneshot jxl_dec jxl_cms jxl_threads)
target_link_libraries(decode_oneshot jxl_dec jxl_threads)
add_executable(decode_progressive ${CMAKE_CURRENT_LIST_DIR}/decode_progressive.cc)
target_link_libraries(decode_progressive jxl_dec jxl_cms jxl_threads)
target_link_libraries(decode_progressive jxl_dec jxl_threads)
add_executable(encode_oneshot ${CMAKE_CURRENT_LIST_DIR}/encode_oneshot.cc)
target_link_libraries(encode_oneshot jxl jxl_cms jxl_threads)
target_link_libraries(encode_oneshot jxl jxl_threads)
7 changes: 7 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ else ()
endif() # WIN32
endif() #!MSVC

if (JPEGXL_ENABLE_SKCMS)
list(APPEND JPEGXL_INTERNAL_FLAGS -DJPEGXL_ENABLE_SKCMS=1)
if (JPEGXL_BUNDLE_SKCMS)
list(APPEND JPEGXL_INTERNAL_FLAGS -DJPEGXL_BUNDLE_SKCMS=1)
endif ()
endif ()

# strips the -static suffix from all the elements in LIST
function(strip_static OUTPUT_VAR LIB_LIST)
foreach(lib IN LISTS ${LIB_LIST})
Expand Down
10 changes: 8 additions & 2 deletions lib/jxl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,14 @@ set_target_properties(jxl_enc-obj PROPERTIES
# for tests.
add_library(jxl_dec-static STATIC
$<TARGET_OBJECTS:jxl_dec-obj>
${JXL_CMS_OBJECTS}
)
target_link_libraries(jxl_dec-static PUBLIC
${JPEGXL_COVERAGE_FLAGS}
${JPEGXL_DEC_INTERNAL_LIBS}
${JXL_CMS_LIBS}
jxl_base
)
target_link_libraries(jxl_dec-static
PUBLIC ${JPEGXL_COVERAGE_FLAGS} ${JPEGXL_DEC_INTERNAL_LIBS} jxl_base)

# The list of objects in the static and shared libraries.
set(JPEGXL_INTERNAL_OBJECTS
Expand All @@ -157,6 +162,7 @@ add_library(jxl-static STATIC
target_link_libraries(jxl-static PUBLIC
${JPEGXL_COVERAGE_FLAGS}
${JPEGXL_INTERNAL_LIBS}
${JXL_CMS_LIBS}
jxl_base
)
target_include_directories(jxl-static PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion lib/jxl/libjxl_cms.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Name: libjxl_cms
Description: CMS support library for libjxl
Version: @JPEGXL_LIBRARY_VERSION@
Requires.private: @JPEGXL_CMS_LIBRARY_REQUIRES@
Libs: -L${libdir} -ljxl_cms
Libs: @JXL_CMS_PK_LIBS@ -L${libdir} -ljxl_cms
Libs.private: -lm
Cflags: -I${includedir}
Cflags.private: -DJXL_STATIC_DEFINE
61 changes: 26 additions & 35 deletions lib/jxl_cms.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,51 +38,42 @@ target_include_directories(jxl_cms-obj PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>")

set(JXL_CMS_OBJECTS $<TARGET_OBJECTS:jxl_cms-obj>)
set(JXL_CMS_LIBS "")
set(JXL_CMS_PK_LIBS "")

if (JPEGXL_ENABLE_SKCMS)
target_include_directories(jxl_cms-obj PRIVATE
$<TARGET_PROPERTY:skcms-obj,INCLUDE_DIRECTORIES>
)
list(APPEND JXL_CMS_OBJECTS $<TARGET_OBJECTS:skcms-obj>)
target_compile_definitions(jxl_cms-obj PRIVATE JPEGXL_ENABLE_SKCMS=1)
if (JPEGXL_BUNDLE_SKCMS)
target_compile_definitions(jxl_cms-obj PRIVATE JPEGXL_BUNDLE_SKCMS=1)
else ()
target_link_libraries(jxl_cms-obj INTERFACE skcms)
endif ()
if (NOT JPEGXL_BUNDLE_SKCMS)
message(ERROR "Non-bundles skcms is not currently supported")
set(JXL_CMS_LIBS "skcms")
set(JXL_CMS_PK_LIBS "-lskcms")
endif ()
else ()
target_include_directories(jxl_cms-obj PRIVATE
$<TARGET_PROPERTY:lcms2,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:lcms2-obj,INCLUDE_DIRECTORIES>
)
target_link_libraries(jxl_cms-obj INTERFACE lcms2)
list(APPEND JXL_CMS_OBJECTS $<TARGET_OBJECTS:lcms2-obj>)
endif ()

add_library(jxl_cms-static STATIC ${JXL_CMS_OBJECTS})
if (NOT WIN32 OR MINGW)
set_target_properties(jxl_cms-static PROPERTIES OUTPUT_NAME "jxl_cms")
endif()

install(TARGETS jxl_cms-static DESTINATION ${CMAKE_INSTALL_LIBDIR})

if (BUILD_SHARED_LIBS AND NOT MINGW)
add_library(jxl_cms SHARED ${JXL_CMS_OBJECTS})
target_link_libraries(jxl_cms PRIVATE hwy)

set_target_properties(jxl_cms PROPERTIES
VERSION ${JPEGXL_LIBRARY_VERSION}
SOVERSION ${JPEGXL_LIBRARY_SOVERSION}
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")

install(TARGETS jxl_cms
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

else() # BUILD_SHARED_LIBS

add_library(jxl_cms ALIAS jxl_cms-static)

target_link_libraries(jxl_cms-obj PUBLIC ${JXL_CMS_LIBS})

if (BUILD_SHARED_LIBS)
add_library(jxl_cms SHARED ${JXL_CMS_OBJECTS})
target_link_libraries(jxl_cms INTERFACE ${JXL_CMS_LIBS})
target_link_libraries(jxl_cms PRIVATE hwy)

set_target_properties(jxl_cms PROPERTIES
VERSION ${JPEGXL_LIBRARY_VERSION}
SOVERSION ${JPEGXL_LIBRARY_SOVERSION}
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")

install(TARGETS jxl_cms
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif() # BUILD_SHARED_LIBS

set(JPEGXL_CMS_LIBRARY_REQUIRES "")
Expand Down
1 change: 0 additions & 1 deletion lib/jxl_extras.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ add_library(jxl_extras-static STATIC EXCLUDE_FROM_ALL ${JXL_EXTRAS_OBJECTS})
target_link_libraries(jxl_extras-static PUBLIC
${JXL_EXTRAS_CODEC_INTERNAL_LIBRARIES}
jxl-static
jxl_cms-static
jxl_threads-static
)
if(JPEGXL_ENABLE_JPEGLI)
Expand Down
26 changes: 13 additions & 13 deletions third_party/lcms2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

add_library(lcms2 STATIC EXCLUDE_FROM_ALL
add_library(lcms2-obj OBJECT EXCLUDE_FROM_ALL
lcms/src/cmsalpha.c
lcms/src/cmscam02.c
lcms/src/cmscgats.c
Expand Down Expand Up @@ -41,37 +41,37 @@ add_library(lcms2 STATIC EXCLUDE_FROM_ALL
lcms/src/cmsxform.c
lcms/src/lcms2_internal.h
)
target_include_directories(lcms2
target_include_directories(lcms2-obj
PUBLIC "${CMAKE_CURRENT_LIST_DIR}/lcms/include")
# This warning triggers with gcc-8.
if (CMAKE_C_COMPILER_ID MATCHES "GNU")
target_compile_options(lcms2
PRIVATE
# gcc-only flags.
-Wno-stringop-truncation
-Wno-strict-aliasing
)
target_compile_options(lcms2-obj
PRIVATE
# gcc-only flags.
-Wno-stringop-truncation
-Wno-strict-aliasing
)
endif()
# By default LCMS uses sizeof(void*) for memory alignment, but in arm 32-bits we
# can't access doubles not aligned to 8 bytes. This forces the alignment to 8
# bytes.
target_compile_definitions(lcms2
target_compile_definitions(lcms2-obj
PRIVATE "-DCMS_PTR_ALIGNMENT=8")
target_compile_definitions(lcms2
target_compile_definitions(lcms2-obj
PUBLIC "-DCMS_NO_REGISTER_KEYWORD=1")

# Ensure that a thread safe alternative of gmtime is used in LCMS
include(CheckSymbolExists)
check_symbol_exists(gmtime_r "time.h" HAVE_GMTIME_R)
if (HAVE_GMTIME_R)
target_compile_definitions(lcms2
target_compile_definitions(lcms2-obj
PUBLIC "-DHAVE_GMTIME_R=1")
else()
check_symbol_exists(gmtime_s "time.h" HAVE_GMTIME_S)
if (HAVE_GMTIME_S)
target_compile_definitions(lcms2
target_compile_definitions(lcms2-obj
PUBLIC "-DHAVE_GMTIME_S=1")
endif()
endif()

set_property(TARGET lcms2 PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET lcms2-obj PROPERTY POSITION_INDEPENDENT_CODE ON)
15 changes: 5 additions & 10 deletions third_party/skcms.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,10 @@
add_library(skcms-obj OBJECT EXCLUDE_FROM_ALL skcms/skcms.cc)
target_include_directories(skcms-obj PUBLIC "${CMAKE_CURRENT_LIST_DIR}/skcms/")

# This library is meant to be compiled/used by external libs (such as plugins)
# that need to use skcms. We use a wrapper for libjxl.
add_library(skcms-interface INTERFACE)
target_sources(skcms-interface INTERFACE ${CMAKE_CURRENT_LIST_DIR}/skcms/skcms.cc)
target_include_directories(skcms-interface INTERFACE ${CMAKE_CURRENT_LIST_DIR}/skcms)

include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-Wno-psabi" CXX_WPSABI_SUPPORTED)
if(CXX_WPSABI_SUPPORTED)
target_compile_options(skcms-obj PRIVATE -Wno-psabi)
target_compile_options(skcms-interface INTERFACE -Wno-psabi)
endif()

if(JPEGXL_BUNDLE_SKCMS)
Expand All @@ -45,7 +38,9 @@ set_target_properties(skcms-obj PROPERTIES
VISIBILITY_INLINES_HIDDEN 1
)

add_library(skcms STATIC EXCLUDE_FROM_ALL $<TARGET_OBJECTS:skcms-obj>)
target_include_directories(skcms
PUBLIC $<TARGET_PROPERTY:skcms-obj,INCLUDE_DIRECTORIES>)
if(NOT JPEGXL_BUNDLE_SKCMS)
add_library(skcms STATIC EXCLUDE_FROM_ALL $<TARGET_OBJECTS:skcms-obj>)
target_include_directories(skcms
PUBLIC $<TARGET_PROPERTY:skcms-obj,INCLUDE_DIRECTORIES>)
endif()

6 changes: 2 additions & 4 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ add_library(jxl_tool STATIC EXCLUDE_FROM_ALL
codec_config.cc
speed_stats.cc
tool_version.cc
${JXL_CMS_OBJECTS}
)
target_compile_options(jxl_tool PUBLIC "${JPEGXL_INTERNAL_FLAGS}")
target_include_directories(jxl_tool PUBLIC "${PROJECT_SOURCE_DIR}")
target_link_libraries(jxl_tool PUBLIC hwy)
jxl_link_libraries(jxl_tool jxl_base)
jxl_link_libraries(jxl_tool jxl_cms-obj)

# The JPEGXL_VERSION is set from the builders.
if(NOT DEFINED JPEGXL_VERSION OR JPEGXL_VERSION STREQUAL "")
Expand Down Expand Up @@ -354,7 +353,6 @@ foreach(FUZZER IN LISTS FUZZER_BINARIES)
if(FUZZER STREQUAL djxl_fuzzer)
target_link_libraries("${BINARY}"
jxl_dec-static
jxl_cms-static
jxl_threads-static
)
elseif(FUZZER STREQUAL jpegli_dec_fuzzer)
Expand Down Expand Up @@ -427,7 +425,7 @@ if (JNI_FOUND AND Java_FOUND)
# decoder_jni_onload.cc might be necessary for Android; not used yet.
add_library(jxl_jni SHARED jni/org/jpeg/jpegxl/wrapper/decoder_jni.cc)
target_include_directories(jxl_jni PRIVATE "${JNI_INCLUDE_DIRS}" "${PROJECT_SOURCE_DIR}")
target_link_libraries(jxl_jni PUBLIC jxl_dec-static jxl_cms-static jxl_threads-static)
target_link_libraries(jxl_jni PUBLIC jxl_dec-static jxl_threads-static)
if(NOT DEFINED JPEGXL_INSTALL_JNIDIR)
set(JPEGXL_INSTALL_JNIDIR ${CMAKE_INSTALL_LIBDIR})
endif()
Expand Down

0 comments on commit 5b52fd6

Please sign in to comment.