@@ -58,6 +58,8 @@ option(FILAMENT_USE_ABSEIL_LOGGING "Use Abseil to log, may increase binary size"
5858
5959option (FILAMENT_ENABLE_EXPERIMENTAL_GCC_SUPPORT "Enable GCC support (unsupported)" OFF )
6060
61+ option (FILAMENT_SUPPORTS_WEBP_TEXTURES "Enable webp texture support for Filament (builds libwebp when ON)" OFF )
62+
6163# This is to disable GTAO for the short-term while we investigate a way to better manage size increases.
6264# On the regular filament build (where size is of less concern), we enable GTAO by default.
6365option (FILAMENT_DISABLE_GTAO "Disable GTAO" OFF )
@@ -753,12 +755,61 @@ function(combine_static_libs TARGET OUTPUT DEPS)
753755endfunction ()
754756
755757# ==================================================================================================
756- # Configuration for CMAKE_CROSSCOMPILING.
757- # ==================================================================================================
758+ # Configuration importing/exporting prebuilt "/tools" executables
759+ # ==================================================================================================
760+
761+ # In certain cases, we want the ability to separate the build type/flags (release, debug) of tools
762+ # (matc, resgen, etc...) from filament. Cross compilation is one such case (e.g. building material
763+ # with matc running on host while building filament for Android) [1]. Another example is when client
764+ # wants to enable ASAN for filament but not the tool [2].
765+ #
766+ # Here are the varibles that are used to determine behavior is such flows:
767+ # - CMAKE_CROSSCOMPILING : Set by cmake to indicate the build's target platform is different
768+ # from the host platform.
769+ # - IMPORT_EXECUTABLES_DIR : This is the directory containing the /ImportExecutables-type.cmake
770+ # which are then included in other CMakeLists.txt to enable finding targets that have been
771+ # prebuilt. This is set by the client in their `cmake` invocation.
772+ # - IMPORT_EXECUTABLES : Path to a file to for 1) exporting the prebuilt targets or 2)
773+ # importing a previously exported targets. (Used internally and should not be set by client).
774+ # - FILAMENT_EXPORT_PREBUILT_EXECUTABLES_DIR : A path set by the client to indicate that
775+ # they wish to export the tools as prebuilts, and the corresponding targets will be recorded
776+ # in a cmake file (i.e IMPORT_EXECUTABLES). IMPORT_EXECUTABLES will be set relative to the the
777+ # given path. This will set FILAMENT_EXPORT_PREBUILT_EXECUTABLES=ON.
778+ # - FILAMENT_IMPORT_PREBUILT_EXECUTABLES_DIR : A path set by the client to indicate that they wish
779+ # to import the tools as prebuilts from a .cmake file. The location (IMPORT_EXECUTABLES) of the
780+ # file is relative to the path given. This will set FILAMENT_IMPORT_PREBUILT_EXECUTABLES=ON.
781+ # - IMPORT_PREBUILT_EXECUTABLES and EXPORT_PREBUILT_EXECUTABLES are internal booleans set to
782+ # ON based on the prescence of FILAMENT_IMPORT_PREBUILT_EXECUTABLES_DIR and
783+ # FILAMENT_EXPORT_PREBUILT_EXECUTABLES_DIR.
784+ #
785+ # In conclusion, for cases
786+ # - [1] (crosscompiling), the client must set IMPORT_EXECUTABLES_DIR for both when they are building
787+ # the tools and when they are building the target-platform filament.
788+ # - [2] (all other instances), the client must set FILAMENT_EXPORT_PREBUILT_EXECUTABLES_DIR in
789+ # the prebuilt exporting step, and set FILAMENT_IMPORT_PREBUILT_EXECUTABLES_DIR in the importing
790+ # step.
791+
792+ # TODO: Fold the cross compilation case into the more general FILAMENT_IMPORT/EXPORT variables.
793+
794+ if (FILAMENT_EXPORT_PREBUILT_EXECUTABLES_DIR)
795+ set (FILAMENT_EXPORT_PREBUILT_EXECUTABLES ON )
796+ set (IMPORT_EXECUTABLES_DIR ${FILAMENT_EXPORT_PREBUILT_EXECUTABLES_DIR} )
797+ endif ()
798+
799+ if (FILAMENT_IMPORT_PREBUILT_EXECUTABLES_DIR)
800+ set (FILAMENT_IMPORT_PREBUILT_EXECUTABLES ON )
801+ set (IMPORT_EXECUTABLES_DIR ${FILAMENT_IMPORT_PREBUILT_EXECUTABLES_DIR} )
802+ endif ()
803+
758804if (WEBGL)
759805 set (IMPORT_EXECUTABLES ${FILAMENT} /${IMPORT_EXECUTABLES_DIR} /ImportExecutables-Release.cmake)
760806else ()
761- set (IMPORT_EXECUTABLES ${FILAMENT} /${IMPORT_EXECUTABLES_DIR} /ImportExecutables-${CMAKE_BUILD_TYPE } .cmake)
807+ if (FILAMENT_EXPORT_PREBUILT_EXECUTABLES OR FILAMENT_IMPORT_PREBUILT_EXECUTABLES)
808+ set (IMPORT_EXECUTABLES_BUILD_TYPE Prebuilt)
809+ else ()
810+ set (IMPORT_EXECUTABLES_BUILD_TYPE ${CMAKE_BUILD_TYPE } )
811+ endif ()
812+ set (IMPORT_EXECUTABLES ${FILAMENT} /${IMPORT_EXECUTABLES_DIR} /ImportExecutables-${IMPORT_EXECUTABLES_BUILD_TYPE} .cmake)
762813endif ()
763814
764815# ==================================================================================================
@@ -837,6 +888,7 @@ add_subdirectory(${EXTERNAL}/getopt)
837888add_subdirectory (${EXTERNAL} /perfetto/tnt )
838889add_subdirectory (${EXTERNAL} /zstd/tnt )
839890
891+
840892# Note that this has to be placed after mikktspace in order for combine_static_libs to work.
841893add_subdirectory (${LIBRARIES} /geometry )
842894
@@ -859,6 +911,11 @@ if (FILAMENT_ENABLE_FGVIEWER)
859911 add_subdirectory (${LIBRARIES} /fgviewer )
860912endif ()
861913
914+ if (FILAMENT_SUPPORTS_WEBP_TEXTURES)
915+ add_subdirectory (${EXTERNAL} /libwebp/tnt )
916+ add_definitions (-DFILAMENT_SUPPORTS_WEBP_TEXTURES )
917+ endif ()
918+
862919if (FILAMENT_SUPPORTS_VULKAN)
863920 add_subdirectory (${LIBRARIES} /bluevk )
864921 add_subdirectory (${EXTERNAL} /vkmemalloc/tnt )
@@ -917,6 +974,6 @@ if (IS_HOST_PLATFORM)
917974endif ()
918975
919976# Generate exported executables for cross-compiled builds (Android, WebGL, and iOS)
920- if (NOT CMAKE_CROSSCOMPILING )
977+ if (( NOT CMAKE_CROSSCOMPILING AND NOT FILAMENT_IMPORT_PREBUILT_EXECUTABLES) OR FILAMENT_EXPORT_PREBUILT_EXECUTABLES )
921978 export (TARGETS matc cmgen filamesh mipgen resgen uberz glslminifier FILE ${IMPORT_EXECUTABLES} )
922979endif ()
0 commit comments