Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use external libsquish if found #2451

Merged
merged 1 commit into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**.
* If you want support for HEIF/HEIC images:
* libheif >= 1.3 (tested through 1.6; older versions may also work, we
haven't tested)
* If you want support for DDS files:
* libsquish >= 1.13
* But... if not found on the system, an embedded version will be used.


Dependency control and disabling components
Expand Down
1 change: 1 addition & 0 deletions src/build-scripts/gh-win-installdeps.bash
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ vcpkg install freetype:x64-windows

vcpkg install libraw:x64-windows
vcpkg install openjpeg:x64-windows
vcpkg install libsquish:x64-windows
# vcpkg install ffmpeg:x64-windows # takes FOREVER!
# vcpkg install webp:x64-windows # No such vcpkg package?a

Expand Down
3 changes: 2 additions & 1 deletion src/build-scripts/install_homebrew_deps.bash
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ else
brew install --display-times libtiff ilmbase openexr opencolorio
brew install --display-times libpng giflib webp jpeg-turbo openjpeg
brew install --display-times freetype libraw dcmtk pybind11 numpy
brew install --display-times field3d ffmpeg libheif openvdb tbb
brew install --display-times field3d ffmpeg libheif libsquish
brew install --display-times openvdb tbb
brew install --display-times opencv qt ptex
fi

Expand Down
10 changes: 10 additions & 0 deletions src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,13 @@ macro (find_or_download_robin_map)
endif ()
checked_find_package (Robinmap REQUIRED)
endmacro()


###########################################################################
# libsquish

option (USE_EMBEDDED_LIBSQUISH
"Force use of embedded Libsquish, even if external is found" OFF)
if (NOT USE_EMBEDDED_LIBSQUISH)
checked_find_package (Libsquish)
endif ()
50 changes: 50 additions & 0 deletions src/cmake/modules/FindLibsquish.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Module to find Libsquish
#
# This module will first look into the directories defined by the variables:
# - Libsquish_ROOT, LIBSQUISH_INCLUDE_PATH, LIBSQUISH_LIBRARY_PATH
#
# This module defines the following variables:
#
# LIBSQUISH_FOUND True if Libsquish was found.
# LIBSQUISH_INCLUDES Where to find Libsquish headers
# LIBSQUISH_LIBRARIES List of libraries to link against when using Libsquish
# LIBSQUISH_VERSION Version of Libsquish (e.g., 3.6.2)

include (FindPackageHandleStandardArgs)

find_path (LIBSQUISH_INCLUDE_DIR squish.h
HINTS
${LIBSQUISH_INCLUDE_PATH}
ENV LIBSQUISH_INCLUDE_PATH
DOC "The directory where Libsquish headers reside")

find_library (LIBSQUISH_LIBRARY squish
HINTS
${LIBSQUISH_LIBRARY_PATH}
ENV LIBSQUISH_LIBRARY_PATH
DOC "The Libsquish libraries")

find_package_handle_standard_args (LIBSQUISH
REQUIRED_VARS
LIBSQUISH_INCLUDE_DIR
LIBSQUISH_LIBRARY
)

if (LIBSQUISH_FOUND)
set (LIBSQUISH_INCLUDES ${LIBSQUISH_INCLUDE_DIR})
set (LIBSQUISH_LIBRARIES ${LIBSQUISH_LIBRARY})

if (NOT TARGET Libsquish::Libsquish)
add_library(Libsquish::Libsquish UNKNOWN IMPORTED)
set_target_properties(Libsquish::Libsquish PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${LIBSQUISH_INCLUDES}")

set_property(TARGET Libsquish::Libsquish APPEND PROPERTY
IMPORTED_LOCATION "${LIBSQUISH_LIBRARIES}")
endif ()
endif ()

mark_as_advanced (
LIBSQUISH_INCLUDE_DIR
LIBSQUISH_LIBRARY
)
13 changes: 11 additions & 2 deletions src/dds.imageio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/OpenImageIO/oiio/blob/master/LICENSE.md

add_oiio_plugin (ddsinput.cpp squish/alpha.cpp squish/clusterfit.cpp
if (LIBSQUISH_FOUND)
# External libsquish was found -- use it
add_oiio_plugin (ddsinput.cpp
LINK_LIBRARIES Libsquish::Libsquish
)
else ()
# No external libsquish was found -- use the embedded version.
add_oiio_plugin (ddsinput.cpp squish/alpha.cpp squish/clusterfit.cpp
squish/colourblock.cpp squish/colourfit.cpp squish/colourset.cpp
squish/maths.cpp squish/rangefit.cpp squish/singlecolourfit.cpp
squish/squish.cpp)
squish/squish.cpp
INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/squish")
endif ()
2 changes: 1 addition & 1 deletion src/dds.imageio/ddsinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <OpenImageIO/imageio.h>
#include <OpenImageIO/typedesc.h>

#include "squish/squish.h"
#include "squish.h"

OIIO_PLUGIN_NAMESPACE_BEGIN

Expand Down