summaryrefslogtreecommitdiff
path: root/indra/cmake/Meshoptimizer.cmake
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2024-08-10 18:54:19 +0800
committerErik Kundiman <erik@megapahit.org>2024-08-10 18:58:27 +0800
commit649865d408846d1559e736abf1be5d74207e6313 (patch)
treee1523de8958f63f75897591bc43d16894fc557b9 /indra/cmake/Meshoptimizer.cmake
parent07004adb7e52b7ead801251b13e8589ad3971f6c (diff)
Automatic Meshoptimizer download, build & install
on macOS and Fedora.
Diffstat (limited to 'indra/cmake/Meshoptimizer.cmake')
-rw-r--r--indra/cmake/Meshoptimizer.cmake60
1 files changed, 54 insertions, 6 deletions
diff --git a/indra/cmake/Meshoptimizer.cmake b/indra/cmake/Meshoptimizer.cmake
index a1cf81be80..07ea3120a7 100644
--- a/indra/cmake/Meshoptimizer.cmake
+++ b/indra/cmake/Meshoptimizer.cmake
@@ -6,14 +6,61 @@ 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)
+ cmake_host_system_information(RESULT MAKE_JOBS QUERY NUMBER_OF_LOGICAL_CORES)
+ if (LINUX)
+ cmake_host_system_information(RESULT LINUX_DISTRO QUERY DISTRIB_ID)
+ endif (LINUX)
+ if (NOT (${LINUX_DISTRO} MATCHES fedora OR DARWIN))
+ find_package(meshoptimizer)
+ endif (NOT (${LINUX_DISTRO} MATCHES fedora OR DARWIN))
+endif (NOT USESYSTEMLIBS)
+
+if (${LINUX_DISTRO} MATCHES fedora 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)
+ execute_process(
+ COMMAND mkdir -p ${AUTOBUILD_INSTALL_DIR}/include/meshoptimizer
+ COMMAND curl
+ -L https://github.com/zeux/meshoptimizer/archive/refs/tags/v0.21.tar.gz
+ -o meshoptimizer-0.21.tar.gz
+ WORKING_DIRECTORY $ENV{HOME}/Downloads
+ )
+ execute_process(
+ COMMAND tar xf $ENV{HOME}/Downloads/meshoptimizer-0.21.tar.gz
+ WORKING_DIRECTORY /tmp
+ )
+ execute_process(
+ COMMAND cmake
+ -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
+ .
+ WORKING_DIRECTORY /tmp/meshoptimizer-0.21
+ )
+ if (DARWIN)
+ execute_process(
+ COMMAND cmake
+ -DCMAKE_OSX_ARCHITECTURES:STRING=arm64
+ -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.15
+ .
+ WORKING_DIRECTORY /tmp/meshoptimizer-0.21
+ )
+ endif (DARWIN)
+ execute_process(
+ COMMAND make -j${MAKE_JOBS}
+ WORKING_DIRECTORY /tmp/meshoptimizer-0.21
+ )
+ execute_process(
+ COMMAND cp /tmp/meshoptimizer-0.21/src/meshoptimizer.h ${AUTOBUILD_INSTALL_DIR}/include/meshoptimizer/
+ COMMAND cp /tmp/meshoptimizer-0.21/libmeshoptimizer.a ${AUTOBUILD_INSTALL_DIR}/lib/release/
+ WORKING_DIRECTORY ${AUTOBUILD_INSTALL_DIR}
+ RESULT_VARIABLE meshoptimizer_installed
+ )
+ 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 +71,4 @@ elseif (DARWIN)
endif (WINDOWS)
target_include_directories( ll::meshoptimizer SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/meshoptimizer)
+endif (${LINUX_DISTRO} MATCHES fedora OR DARWIN OR NOT USESYSTEMLIBS)