Skip to content

Commit

Permalink
SAIL: Added possibility to specify not just individual codecs but cod…
Browse files Browse the repository at this point in the history
…ec groups by their priorities in CMake configuration routine
  • Loading branch information
HappySeaFox committed Oct 24, 2023
1 parent a562d5d commit f4f345b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@ option(SAIL_BUILD_EXAMPLES "Build examples." ON)
option(SAIL_BUILD_TESTS "Build tests." ON)
option(SAIL_DEV "Enable developer mode. Be more strict when compiling source code, for example." OFF)
set(SAIL_ENABLE_CODECS "" CACHE STRING "Forcefully enable the codecs specified in this ';'-separated list. \
If an enabled codec fails to find its dependencies, the configuration process fails.")
set(SAIL_DISABLE_CODECS "" CACHE STRING "Disable the codecs specified in this ';'-separated list.")
If an enabled codec fails to find its dependencies, the configuration process fails. \
One can also specify not just individual codecs but codec groups by their priority like that: highest-priority;xbm.")
set(SAIL_DISABLE_CODECS "" CACHE STRING "Disable the codecs specified in this ';'-separated list. \
One can also specify not just individual codecs but codec groups by their priority like that: highest-priority;xbm.")
option(SAIL_INSTALL_PDB "Install PDB files along with libraries." ON)
set(SAIL_ONLY_CODECS "" CACHE STRING "Forcefully enable only the codecs specified in this ';'-separated list and disable the rest. \
If an enabled codec fails to find its dependencies, the configuration process fails.")
If an enabled codec fails to find its dependencies, the configuration process fails. \
One can also specify not just individual codecs but codec groups by their priority like that: highest-priority;xbm.")
option(BUILD_SHARED_LIBS "Build shared libs. When disabled, sets SAIL_COMBINE_CODECS to ON automatically." ON)
cmake_dependent_option(SAIL_COMBINE_CODECS "Combine all codecs into a single library. When disabled, all codecs are implemented as \
dynamically loaded plugins." OFF "BUILD_SHARED_LIBS" ON)
Expand Down
43 changes: 39 additions & 4 deletions src/sail-codecs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,49 @@ add_subdirectory(common/bmp)

# List of codecs
#
set(CODECS avif bmp gif ico jpeg jpeg2000 jpegxl pcx png psd qoi svg tga tiff wal webp xbm)

set(HIGHEST_PRIORITY_CODECS gif jpeg png tiff)
set(HIGH_PRIORITY_CODECS bmp svg)
set(MEDIUM_PRIORITY_CODECS avif jpeg2000 jpegxl webp)
set(LOW_PRIORITY_CODECS ico pcx psd qoi tga)
set(LOWEST_PRIORITY_CODECS wal xbm)

set(CODECS ${HIGHEST_PRIORITY_CODECS}
${HIGH_PRIORITY_CODECS}
${MEDIUM_PRIORITY_CODECS}
${LOW_PRIORITY_CODECS}
${LOWEST_PRIORITY_CODECS})
list(SORT CODECS)

# Filter out codecs
# Expand codecs priorities to actual codecs.
#
set(FORCED_CODECS "")
macro(sail_expand_priorities)
set(TEMP_LIST)

foreach (codec IN LISTS ${ARGV0})
if (codec STREQUAL "highest-priority")
list(APPEND TEMP_LIST ${HIGHEST_PRIORITY_CODECS})
elseif (codec STREQUAL "high-priority")
list(APPEND TEMP_LIST ${HIGH_PRIORITY_CODECS})
elseif (codec STREQUAL "medium-priority")
list(APPEND TEMP_LIST ${MEDIUM_PRIORITY_CODECS})
elseif (codec STREQUAL "low-priority")
list(APPEND TEMP_LIST ${LOW_PRIORITY_CODECS})
elseif (codec STREQUAL "lowest-priority")
list(APPEND TEMP_LIST ${LOWEST_PRIORITY_CODECS})
else()
list(APPEND TEMP_LIST ${codec})
endif()
endforeach()

set(${ARGV0} ${TEMP_LIST})
endmacro()

sail_expand_priorities(SAIL_ONLY_CODECS)
sail_expand_priorities(SAIL_ENABLE_CODECS)
sail_expand_priorities(SAIL_DISABLE_CODECS)

# Filter out codecs
#
if (SAIL_ONLY_CODECS)
set(ENABLED_CODECS "")

Expand Down

0 comments on commit f4f345b

Please sign in to comment.