Skip to content

Commit

Permalink
SAIL: Added macro SAIL_HAVE_BUILTIN_${CODEC}
Browse files Browse the repository at this point in the history
  • Loading branch information
HappySeaFox committed Oct 10, 2023
1 parent fb14bc7 commit 9428115
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
34 changes: 18 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ join_paths(SAIL_INCLUDEDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_INC
#
sail_check_alignas()
sail_check_builtin_bswap()
sail_check_c11_thread_local()

# Check for required includes
#
Expand Down Expand Up @@ -195,15 +196,10 @@ if (WIN32)
string(REPLACE "/" "\\\\" SAIL_CODECS_PATH "${SAIL_CODECS_PATH}")
endif()

# Common configuration file
# Global include directory with generated configs
#
configure_file("${PROJECT_SOURCE_DIR}/src/config.h.in" "${PROJECT_BINARY_DIR}/include/config.h" @ONLY)
include_directories("${PROJECT_BINARY_DIR}/include")

# Execute tests that depend on config.h
#
sail_check_c11_thread_local()

# Configure subdirs
#
add_subdirectory(src/libsail-common)
Expand Down Expand Up @@ -239,10 +235,6 @@ if (NOT ENABLED_CODECS AND NOT SAIL_THIRD_PARTY_CODECS_PATH)
message(FATAL_ERROR "Error: No codecs are enabled and SAIL_THIRD_PARTY_CODECS_PATH is disabled.\nThis particular build of SAIL cannot load any image.")
endif()

# Installation
#
install(FILES "${PROJECT_BINARY_DIR}/include/config.h" DESTINATION include/sail/sail-common)

# Install our bundled libs if they exist and when VCPKG is not used
#
if (NOT SAIL_VCPKG)
Expand Down Expand Up @@ -272,14 +264,13 @@ if (NOT SAIL_VCPKG)
endif()
endif()

# Print configuration statistics
#
if (SAIL_COLORED_OUTPUT)
set(SAIL_COLORED_OUTPUT_CLARIFY " (on Windows >= 10 and Unix)")
endif()

if (ENABLED_CODECS)
string(TOUPPER "${ENABLED_CODECS}" ENABLED_CODECS)

foreach (codec IN LISTS ENABLED_CODECS)
set(SAIL_HAVE_CODEC_DEFINES "${SAIL_HAVE_CODEC_DEFINES}#define SAIL_HAVE_BUILTIN_${codec}\n")
endforeach()

string(REPLACE ";" " " ENABLED_CODECS "${ENABLED_CODECS}")
endif()

Expand All @@ -288,6 +279,17 @@ if (DISABLED_CODECS)
string(REPLACE ";" " " DISABLED_CODECS "${DISABLED_CODECS}")
endif()

# Common configuration file
#
configure_file("${PROJECT_SOURCE_DIR}/src/config.h.in" "${PROJECT_BINARY_DIR}/include/config.h" @ONLY)
install(FILES "${PROJECT_BINARY_DIR}/include/config.h" DESTINATION include/sail/sail-common)

# Print configuration statistics
#
if (SAIL_COLORED_OUTPUT)
set(SAIL_COLORED_OUTPUT_CLARIFY " (on Windows >= 10 and Unix)")
endif()

message("")
message("***************************************")
message("*")
Expand Down
3 changes: 3 additions & 0 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,7 @@
/* Enable __builtin_bswap64. */
#cmakedefine SAIL_HAVE_BUILTIN_BSWAP64

/* Enabled built-in codecs. */
@SAIL_HAVE_CODEC_DEFINES@

#endif
10 changes: 10 additions & 0 deletions tests/images/test-images.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

#include <stddef.h>

#include "config.h"

static const char * const SAIL_TEST_IMAGES[] = {
#ifdef SAIL_HAVE_BUILTIN_BMP
"@SAIL_TEST_IMAGES_PATH@/bmp/bpp1-indexed.bmp",
"@SAIL_TEST_IMAGES_PATH@/bmp/bpp1-indexed.not4.bmp",
"@SAIL_TEST_IMAGES_PATH@/bmp/bpp4-indexed.bmp",
Expand All @@ -18,15 +21,22 @@ static const char * const SAIL_TEST_IMAGES[] = {
"@SAIL_TEST_IMAGES_PATH@/bmp/bpp24-bgr.not4.bmp",
"@SAIL_TEST_IMAGES_PATH@/bmp/bpp32-bgra.bmp",
"@SAIL_TEST_IMAGES_PATH@/bmp/bpp32-bgra.not4.bmp",
#endif

#ifdef SAIL_HAVE_BUILTIN_PNG
"@SAIL_TEST_IMAGES_PATH@/png/bpp4-indexed.comment.iccp.png",
#endif

#ifdef SAIL_HAVE_BUILTIN_TGA
"@SAIL_TEST_IMAGES_PATH@/tga/bpp8-grayscale.extension.rle.tga",
"@SAIL_TEST_IMAGES_PATH@/tga/bpp8-indexed.extension.rle.tga",
"@SAIL_TEST_IMAGES_PATH@/tga/bpp24-bgr.extension.rle.tga",
#endif

#ifdef SAIL_HAVE_BUILTIN_XBM
"@SAIL_TEST_IMAGES_PATH@/xbm/bpp1-indexed.x10.xbm",
"@SAIL_TEST_IMAGES_PATH@/xbm/bpp1-indexed.x11.xbm",
#endif

NULL,
};
Expand Down

0 comments on commit 9428115

Please sign in to comment.