Skip to content

Commit

Permalink
Disable some optional dependencies of libtiff and freetype (#18)
Browse files Browse the repository at this point in the history
Summary:
**Summary**

1. Disabling lzma, jbig, webp, and zstd
   Some the dependencies of libtiff cause build errors, cf. issues
     * #9
     * #15

   Since these dependencies are not absolutely required for Ocean, let's disable them for now.
2. Disabling harfbuzz
   On Macs (Intel-based), when `libharfbuzz*.a` exists in a system-level directory, CMake currently selects that version and not the version that comes with Ocean.

   This causes iOS builds to fail because CMake doesn't seems to notice that's intended for a different platform.

   To work-around this problem, this diff disables the build and use of harfbuzz altogether.

   Also, if harfbuzz is not absolutely required by freetype (or Ocean), we should probably remove it completely to reduce build times and complexity.

**Testing**

Confirm that the build of the third-party libraries and Ocean no longer fails because of missing `JBIG::JBIG` or similar

https://github.com/facebookresearch/ocean/blob/main/building_for_macos.md
https://github.com/facebookresearch/ocean/blob/main/building_for_ios.md

Builds fine on Macs (for macOS and iOS). Testing on Windows, Linux, and Android is still required.

Pull Request resolved: #18

Reviewed By: janherling

Differential Revision: D59727228

Pulled By: enpe

fbshipit-source-id: 5d470c4e77f2c5a963614cbd8f834017f0dee077
  • Loading branch information
enpe authored and facebook-github-bot committed Jul 14, 2024
1 parent 16c00b3 commit 20983f1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build/cmake/third-party/dependencies_allplatforms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ giflib
openxr
tinyxml2
protozero
harfbuzz
#harfbuzz
mbedtls
libpng
libtiff
Expand Down
3 changes: 3 additions & 0 deletions build/cmake/third-party/freetype.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ list(APPEND CMAKE_MESSAGE_INDENT " ")

find_package(Git REQUIRED)

set(FT_DISABLE_BROTLI TRUE)
set(FT_DISABLE_BZIP2 TRUE)
set(FT_REQUIRE_HARFBUZZ FALSE)

set(ZLIB_ROOT ${CMAKE_INSTALL_PREFIX})
set(PNG_ROOT ${CMAKE_INSTALL_PREFIX})

Expand Down
14 changes: 6 additions & 8 deletions build/cmake/third-party/libtiff.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ set(tiff-tests OFF CACHE BOOL "")
set(tiff-contrib OFF CACHE BOOL "")
set(HAVE_LD_VERSION_SCRIPT OFF)

if (LINUX)
# Explicitly disable these codes because they cause build errors on Github.
set(libdeflate OFF)
set(lzma OFF)
set(jbig OFF)
set(webp OFF)
set(zstd OFF)
endif()
# Explicitly disable the following codes
set(libdeflate OFF)
set(lzma OFF)
set(jbig OFF)
set(webp OFF)
set(zstd OFF)

find_package(Git REQUIRED)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ if (IOS)
file(GLOB OCEAN_TARGET_STORYBOARDS "${CMAKE_SOURCE_DIR}/res/application/ocean/demo/tracking/featuretracker/ios/*.xib")
file(GLOB OCEAN_TARGET_IMAGE_RESOURCES
"${CMAKE_SOURCE_DIR}/res/application/ocean/demo/tracking/featuretracker/*.bmp"
"${CMAKE_SOURCE_DIR}/res/application/ocean/demo/tracking/featuretracker/*.jpg"
"${CMAKE_SOURCE_DIR}/res/application/ocean/demo/tracking/featuretracker/*.obj"
"${CMAKE_SOURCE_DIR}/res/application/ocean/demo/tracking/featuretracker/*.png"
"${CMAKE_SOURCE_DIR}/res/application/ocean/demo/tracking/featuretracker/*.txt"
Expand Down
6 changes: 3 additions & 3 deletions impl/ocean/cv/fonts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (MACOS OR ANDROID OR IOS OR LINUX OR WIN32)
set(OCEAN_TARGET_NAME "ocean_cv_fonts")

find_package(Freetype REQUIRED)
find_package(HarfBuzz REQUIRED)
# find_package(HarfBuzz REQUIRED)
find_package(PNG REQUIRED)

# Source files
Expand Down Expand Up @@ -38,11 +38,11 @@ if (MACOS OR ANDROID OR IOS OR LINUX OR WIN32)
ocean_io
ocean_math
Freetype::Freetype
${HarfBuzz_LIBRARY}
# ${HarfBuzz_LIBRARY}
PNG::PNG
)

target_include_directories(${OCEAN_TARGET_NAME} PRIVATE ${HarfBuzz_INCLUDE_DIRS})
# target_include_directories(${OCEAN_TARGET_NAME} PRIVATE ${HarfBuzz_INCLUDE_DIRS})

# Installation
install(TARGETS ${OCEAN_TARGET_NAME}
Expand Down

0 comments on commit 20983f1

Please sign in to comment.