summaryrefslogtreecommitdiff
path: root/indra/cmake/Meshoptimizer.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'indra/cmake/Meshoptimizer.cmake')
-rw-r--r--indra/cmake/Meshoptimizer.cmake65
1 files changed, 59 insertions, 6 deletions
diff --git a/indra/cmake/Meshoptimizer.cmake b/indra/cmake/Meshoptimizer.cmake
index a1cf81be80..0dc4069431 100644
--- a/indra/cmake/Meshoptimizer.cmake
+++ b/indra/cmake/Meshoptimizer.cmake
@@ -6,14 +6,66 @@ include(Prebuilt)
include_guard()
add_library( ll::meshoptimizer INTERFACE IMPORTED )
-if (NOT (USE_AUTOBUILD_3P OR USE_CONAN))
- target_include_directories( ll::meshoptimizer SYSTEM INTERFACE ${CMAKE_SYSROOT}/usr/local/include )
- target_link_libraries( ll::meshoptimizer INTERFACE meshoptimizer)
- return ()
-endif ()
-
+if (NOT USESYSTEMLIBS)
use_system_binary(meshoptimizer)
+else (NOT USESYSTEMLIBS)
+ if (NOT (${LINUX_DISTRO} MATCHES fedora OR (${LINUX_DISTRO} MATCHES opensuse-tumbleweed) OR DARWIN))
+ find_package(meshoptimizer)
+ target_link_libraries( ll::meshoptimizer INTERFACE meshoptimizer)
+ endif (NOT (${LINUX_DISTRO} MATCHES fedora OR (${LINUX_DISTRO} MATCHES opensuse-tumbleweed) OR DARWIN))
+endif (NOT USESYSTEMLIBS)
+
+if (${LINUX_DISTRO} MATCHES fedora OR (${LINUX_DISTRO} MATCHES opensuse-tumbleweed) OR DARWIN OR NOT USESYSTEMLIBS)
+ if (USESYSTEMLIBS)
+ if (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/meshoptimizer_installed OR NOT ${meshoptimizer_installed} EQUAL 0)
+ if (NOT EXISTS ${CMAKE_BINARY_DIR}/meshoptimizer-0.21.tar.gz)
+ file(DOWNLOAD
+ https://github.com/zeux/meshoptimizer/archive/refs/tags/v0.21.tar.gz
+ ${CMAKE_BINARY_DIR}/meshoptimizer-0.21.tar.gz
+ )
+ endif (NOT EXISTS ${CMAKE_BINARY_DIR}/meshoptimizer-0.21.tar.gz)
+ file(ARCHIVE_EXTRACT
+ INPUT ${CMAKE_BINARY_DIR}/meshoptimizer-0.21.tar.gz
+ DESTINATION ${CMAKE_BINARY_DIR}
+ )
+ if (DARWIN)
+ try_compile(MESHOPTIMIZER_RESULT
+ PROJECT meshoptimizer
+ SOURCE_DIR ${CMAKE_BINARY_DIR}/meshoptimizer-0.21
+ BINARY_DIR ${CMAKE_BINARY_DIR}/meshoptimizer-0.21
+ TARGET meshoptimizer
+ CMAKE_FLAGS
+ -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
+ -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES}
+ -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.15
+ OUTPUT_VARIABLE meshoptimizer_installed
+ )
+ else (DARWIN)
+ try_compile(MESHOPTIMIZER_RESULT
+ PROJECT meshoptimizer
+ SOURCE_DIR ${CMAKE_BINARY_DIR}/meshoptimizer-0.21
+ BINARY_DIR ${CMAKE_BINARY_DIR}/meshoptimizer-0.21
+ TARGET meshoptimizer
+ CMAKE_FLAGS
+ -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
+ OUTPUT_VARIABLE meshoptimizer_installed
+ )
+ endif (DARWIN)
+ if (${MESHOPTIMIZER_RESULT})
+ file(
+ COPY ${CMAKE_BINARY_DIR}/meshoptimizer-0.21/src/meshoptimizer.h
+ DESTINATION ${LIBS_PREBUILT_DIR}/include/meshoptimizer
+ )
+ file(
+ COPY ${CMAKE_BINARY_DIR}/meshoptimizer-0.21/libmeshoptimizer.a
+ DESTINATION ${LIBS_PREBUILT_DIR}/lib/release
+ )
+ file(WRITE ${PREBUILD_TRACKING_DIR}/meshoptimizer_installed "0")
+ endif (${MESHOPTIMIZER_RESULT})
+ endif (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/meshoptimizer_installed OR NOT ${meshoptimizer_installed} EQUAL 0)
+ else (USESYSTEMLIBS)
use_prebuilt_binary(meshoptimizer)
+ endif (USESYSTEMLIBS)
if (WINDOWS)
target_link_libraries( ll::meshoptimizer INTERFACE meshoptimizer.lib)
@@ -24,3 +76,4 @@ elseif (DARWIN)
endif (WINDOWS)
target_include_directories( ll::meshoptimizer SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/meshoptimizer)
+endif (${LINUX_DISTRO} MATCHES fedora OR (${LINUX_DISTRO} MATCHES opensuse-tumbleweed) OR DARWIN OR NOT USESYSTEMLIBS)