mirror of
https://github.com/microsoft/DirectXTex.git
synced 2026-02-12 23:56:13 +01:00
Add Auxiliary files for JPEG/PNG support on Linux (#407)
This commit is contained in:
@@ -48,6 +48,12 @@ option(BUILD_FUZZING "Build for fuzz testing" OFF)
|
||||
# Includes the functions for loading/saving OpenEXR files at runtime
|
||||
option(ENABLE_OPENEXR_SUPPORT "Build with OpenEXR support" OFF)
|
||||
|
||||
# See https://www.ijg.org/
|
||||
option(ENABLE_LIBJPEG_SUPPORT "Build with libjpeg support" OFF)
|
||||
|
||||
# See http://www.libpng.org/pub/png/libpng.html
|
||||
option(ENABLE_LIBPNG_SUPPORT "Build with libpng support" OFF)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
@@ -181,6 +187,22 @@ if(ENABLE_OPENEXR_SUPPORT)
|
||||
list(APPEND LIBRARY_SOURCES Auxiliary/DirectXTexEXR.cpp)
|
||||
endif()
|
||||
|
||||
if(ENABLE_LIBJPEG_SUPPORT)
|
||||
if(WIN32)
|
||||
message(STATUS "Use of the Windows Imaging Component (WIC) instead of libjpeg is recommended.")
|
||||
endif()
|
||||
list(APPEND LIBRARY_HEADERS Auxiliary/DirectXTexJPEG.h)
|
||||
list(APPEND LIBRARY_SOURCES Auxiliary/DirectXTexJPEG.cpp)
|
||||
endif()
|
||||
|
||||
if(ENABLE_LIBPNG_SUPPORT)
|
||||
if(WIN32)
|
||||
message(STATUS "Use of the Windows Imaging Component (WIC) instead of libpng is recommended.")
|
||||
endif()
|
||||
list(APPEND LIBRARY_HEADERS Auxiliary/DirectXTexPNG.h)
|
||||
list(APPEND LIBRARY_SOURCES Auxiliary/DirectXTexPNG.cpp)
|
||||
endif()
|
||||
|
||||
if(BUILD_DX11 AND WIN32)
|
||||
if(NOT COMPILED_SHADERS)
|
||||
if(USE_PREBUILT_SHADERS)
|
||||
@@ -255,6 +277,16 @@ elseif(BUILD_XBOX_EXTS_XBOXONE AND WIN32)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_LIBJPEG_SUPPORT)
|
||||
find_package(JPEG REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC JPEG::JPEG)
|
||||
endif()
|
||||
|
||||
if(ENABLE_LIBPNG_SUPPORT)
|
||||
find_package(PNG REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC PNG::PNG)
|
||||
endif()
|
||||
|
||||
if(NOT MINGW)
|
||||
target_precompile_headers(${PROJECT_NAME} PRIVATE DirectXTex/DirectXTexP.h)
|
||||
endif()
|
||||
@@ -364,6 +396,13 @@ endif()
|
||||
if(directx-headers_FOUND)
|
||||
list(APPEND DIRECTXTEX_DEP_L "DirectX-Headers")
|
||||
endif()
|
||||
if(ENABLE_LIBJPEG_SUPPORT AND JPEG_FOUND)
|
||||
list(APPEND DIRECTXTEX_DEP_L "libjpeg")
|
||||
endif()
|
||||
if(ENABLE_LIBPNG_SUPPORT AND PNG_FOUND)
|
||||
list(APPEND DIRECTXTEX_DEP_L "libpng")
|
||||
endif()
|
||||
|
||||
list(LENGTH DIRECTXTEX_DEP_L DEP_L)
|
||||
if(DEP_L)
|
||||
STRING(REPLACE ";" ", " DIRECTXTEX_DEP " ${DIRECTXTEX_DEP_L}")
|
||||
@@ -425,6 +464,20 @@ if(BUILD_TOOLS AND WIN32)
|
||||
target_compile_definitions(${t} PRIVATE USE_OPENEXR)
|
||||
endforeach()
|
||||
endif()
|
||||
if(ENABLE_LIBJPEG_SUPPORT)
|
||||
foreach(t IN LISTS TOOL_EXES)
|
||||
target_include_directories(${t} PRIVATE Auxiliary)
|
||||
target_link_libraries(${t} PRIVATE JPEG::JPEG)
|
||||
target_compile_definitions(${t} PRIVATE USE_LIBJPEG)
|
||||
endforeach()
|
||||
endif()
|
||||
if(ENABLE_LIBPNG_SUPPORT)
|
||||
foreach(t IN LISTS TOOL_EXES)
|
||||
target_include_directories(${t} PRIVATE Auxiliary)
|
||||
target_link_libraries(${t} PRIVATE PNG::PNG)
|
||||
target_compile_definitions(${t} PRIVATE USE_LIBPNG)
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#--- DDSView sample
|
||||
|
||||
Reference in New Issue
Block a user