Skip to content

Commit 771d858

Browse files
authored
Sync with 6d9ea6b for 6.43.0 (#86)
1 parent 9a9cae0 commit 771d858

251 files changed

Lines changed: 16265 additions & 1212 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/continuous.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,18 @@ jobs:
5858
docker-images: true
5959
swap-storage: true
6060

61-
- name: Show disk space
61+
- name: Set swap space
62+
if: runner.os == 'Linux' && matrix.compiler == 'gcc' && matrix.config == 'RelWithDebInfo'
63+
uses: pierotofy/set-swap-space@fc79b3f67fa8a838184ce84a674ca12238d2c761
64+
with:
65+
swap-size-gb: 16
66+
67+
- name: Show disk and memory space
6268
run: |
6369
echo "disk usage:"
6470
df -h
71+
echo "memory:"
72+
if command -v free &>/dev/null; then free -h; else sysctl hw.memsize; fi
6573
6674
- name: Select build dir (Linux)
6775
if: runner.os == 'Linux'
@@ -96,6 +104,9 @@ jobs:
96104
- name: Install Ninja
97105
uses: seanmiddleditch/gha-setup-ninja@master
98106

107+
- name: Install mold
108+
uses: rui314/setup-mold@v1
109+
99110
- name: Dependencies (Linux)
100111
if: runner.os == 'Linux'
101112
run: |
@@ -109,7 +120,7 @@ jobs:
109120
echo "CC=clang" >> $GITHUB_ENV
110121
echo "CXX=clang++" >> $GITHUB_ENV
111122
fi
112-
sudo apt-get install xorg-dev
123+
sudo apt-get install -y xorg-dev
113124
114125
- name: Dependencies (macOS)
115126
if: runner.os == 'macOS'

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ uv.lock
4343
*.out
4444
*.app
4545

46+
# Lagrange serialized mesh/scene
47+
*.lgs
48+
*.lgm
49+
4650
# Mesh files
4751
*.obj
4852
*.off
@@ -96,3 +100,8 @@ keyfile.txt
96100

97101
# ctags
98102
tags
103+
104+
# Claude
105+
.claude/agent-memory/
106+
/.tmp/
107+
.claude/settings.local.json

LagrangeOptions.cmake.sample

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,29 +48,30 @@
4848
# option(LAGRANGE_ALL "Build all lagrange modules" ON)
4949

5050
# Optional modules in alphabetical order.
51-
# option(LAGRANGE_MODULE_BVH "Build module lagrange::bvh" ON)
52-
# option(LAGRANGE_MODULE_FILTERING "Build module lagrange::filtering" ON)
53-
# option(LAGRANGE_MODULE_FS "Build module lagrange::fs" ON)
54-
# option(LAGRANGE_MODULE_GEODESIC "Build module lagrange::geodesic" ON)
55-
# option(LAGRANGE_MODULE_IMAGE "Build module lagrange::image" ON)
56-
# option(LAGRANGE_MODULE_IMAGE_IO "Build module lagrange::image_io" ON)
57-
# option(LAGRANGE_MODULE_IO "Build module lagrange::io" ON)
58-
# option(LAGRANGE_MODULE_PACKING "Build module lagrange::packing" ON)
59-
# option(LAGRANGE_MODULE_PARTITIONING "Build module lagrange::partitioning" ON)
60-
# option(LAGRANGE_MODULE_POISSON "Build module lagrange::poisson" ON)
61-
# option(LAGRANGE_MODULE_POLYDDG "Build module lagrange::polyddg" ON)
62-
# option(LAGRANGE_MODULE_POLYSCOPE "Build module lagrange::polyscope" ON)
63-
# option(LAGRANGE_MODULE_PRIMITIVE "Build module lagrange::primitive" ON)
64-
# option(LAGRANGE_MODULE_PYTHON "Build module lagrange::python" ON)
65-
# option(LAGRANGE_MODULE_RAYCASTING "Build module lagrange::raycasting" ON)
66-
# option(LAGRANGE_MODULE_REMESHING_IM "Build module lagrange::remeshing_im" ON)
67-
# option(LAGRANGE_MODULE_SCENE "Build module lagrange::scene" ON)
68-
# option(LAGRANGE_MODULE_SOLVER "Build module lagrange::solver" ON)
69-
# option(LAGRANGE_MODULE_SUBDIVISION "Build module lagrange::subdivision" ON)
70-
# option(LAGRANGE_MODULE_TEXPROC "Build module lagrange::texproc" ON)
71-
# option(LAGRANGE_MODULE_UI "Build module lagrange::ui" ON)
72-
# option(LAGRANGE_MODULE_VOLUME "Build module lagrange::volume" ON)
73-
# option(LAGRANGE_MODULE_WINDING "Build module lagrange::winding" ON)
51+
# option(LAGRANGE_MODULE_BVH "Build module lagrange::bvh" ON)
52+
# option(LAGRANGE_MODULE_FILTERING "Build module lagrange::filtering" ON)
53+
# option(LAGRANGE_MODULE_FS "Build module lagrange::fs" ON)
54+
# option(LAGRANGE_MODULE_GEODESIC "Build module lagrange::geodesic" ON)
55+
# option(LAGRANGE_MODULE_IMAGE "Build module lagrange::image" ON)
56+
# option(LAGRANGE_MODULE_IMAGE_IO "Build module lagrange::image_io" ON)
57+
# option(LAGRANGE_MODULE_IO "Build module lagrange::io" ON)
58+
# option(LAGRANGE_MODULE_PACKING "Build module lagrange::packing" ON)
59+
# option(LAGRANGE_MODULE_PARTITIONING "Build module lagrange::partitioning" ON)
60+
# option(LAGRANGE_MODULE_POISSON "Build module lagrange::poisson" ON)
61+
# option(LAGRANGE_MODULE_POLYDDG "Build module lagrange::polyddg" ON)
62+
# option(LAGRANGE_MODULE_POLYSCOPE "Build module lagrange::polyscope" ON)
63+
# option(LAGRANGE_MODULE_PRIMITIVE "Build module lagrange::primitive" ON)
64+
# option(LAGRANGE_MODULE_PYTHON "Build module lagrange::python" ON)
65+
# option(LAGRANGE_MODULE_RAYCASTING "Build module lagrange::raycasting" ON)
66+
# option(LAGRANGE_MODULE_REMESHING_IM "Build module lagrange::remeshing_im" ON)
67+
# option(LAGRANGE_MODULE_SCENE "Build module lagrange::scene" ON)
68+
# option(LAGRANGE_MODULE_SERIALIZATION2 "Build module lagrange::serialization2" ON)
69+
# option(LAGRANGE_MODULE_SOLVER "Build module lagrange::solver" ON)
70+
# option(LAGRANGE_MODULE_SUBDIVISION "Build module lagrange::subdivision" ON)
71+
# option(LAGRANGE_MODULE_TEXPROC "Build module lagrange::texproc" ON)
72+
# option(LAGRANGE_MODULE_UI "Build module lagrange::ui" ON)
73+
# option(LAGRANGE_MODULE_VOLUME "Build module lagrange::volume" ON)
74+
# option(LAGRANGE_MODULE_WINDING "Build module lagrange::winding" ON)
7475

7576
# General options
7677
# option(LAGRANGE_COMPILE_TESTS "Enable compilation tests" ON)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
anorigami;baking;cad_io;contouring;decal;deformers;filtering;meshproc;quadrangulation;solver;texproc
1+
anorigami;baking;cad_io;contouring;decal;deformers;filtering;meshproc;polyddg;quadrangulation;solver;texproc

cmake/lagrange/lagrange_add_python_binding.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
# governing permissions and limitations under the License.
1111
#
1212
function(lagrange_add_python_binding)
13+
cmake_parse_arguments(PARSE_ARGV 0 ARG "" "PYTHON_NAME" "")
14+
1315
# Retrieve module name
1416
get_filename_component(module_path "${CMAKE_CURRENT_SOURCE_DIR}/.." REALPATH)
1517
get_filename_component(module_name "${module_path}" NAME)
@@ -39,4 +41,9 @@ function(lagrange_add_python_binding)
3941

4042
# Keep track of active modules
4143
set_property(TARGET lagrange_python APPEND PROPERTY LAGRANGE_ACTIVE_MODULES ${module_name})
44+
45+
# Optional: override the Python submodule name (e.g. expose "serialization2" as "serialization")
46+
if(ARG_PYTHON_NAME)
47+
set_property(TARGET lagrange_python PROPERTY LAGRANGE_PYTHON_NAME_${module_name} ${ARG_PYTHON_NAME})
48+
endif()
4249
endfunction()

cmake/lagrange/lagrange_add_test.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,28 @@ function(lagrange_add_test)
5656
# Register tests
5757
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/reports")
5858

59+
# When cross-compiling with Emscripten, test discovery at build time can produce truncated JSON
60+
# output due to stdout flushing issues with PROXY_TO_PTHREAD. Use PRE_TEST to defer discovery to
61+
# ctest runtime instead. See:
62+
# - https://github.com/emscripten-core/emscripten/issues/15186
63+
# - https://github.com/emscripten-core/emscripten/issues/20059
64+
if(EMSCRIPTEN)
65+
set(_discovery_mode PRE_TEST)
66+
else()
67+
set(_discovery_mode POST_BUILD)
68+
endif()
69+
5970
if(LAGRANGE_TOPLEVEL_PROJECT AND NOT USE_SANITIZER MATCHES "([Tt]hread)")
6071
catch_discover_tests(${test_target}
6172
REPORTER junit
6273
OUTPUT_DIR "${CMAKE_BINARY_DIR}/reports"
6374
OUTPUT_SUFFIX ".xml"
75+
DISCOVERY_MODE ${_discovery_mode}
6476
PROPERTIES ENVIRONMENT ${LAGRANGE_TESTS_ENVIRONMENT}
6577
)
6678
else()
6779
catch_discover_tests(${test_target}
80+
DISCOVERY_MODE ${_discovery_mode}
6881
PROPERTIES ENVIRONMENT ${LAGRANGE_TESTS_ENVIRONMENT}
6982
)
7083
endif()

cmake/lagrange/lagrange_find_package.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function(lagrange_find_package name)
2424
span-lite
2525
spdlog
2626
TBB
27+
zstd
2728
)
2829

2930
# Defer to find_package() if desired. In the future we will switch to a dependency provider.

cmake/lagrange/lagrange_limit_parallelism.cmake

Lines changed: 35 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -10,81 +10,57 @@
1010
# governing permissions and limitations under the License.
1111
#
1212
function(lagrange_limit_parallelism)
13-
# Query system information
1413
cmake_host_system_information(RESULT NUMBER_OF_PHYSICAL_CORES QUERY NUMBER_OF_PHYSICAL_CORES)
15-
cmake_host_system_information(RESULT AVAILABLE_PHYSICAL_MEMORY QUERY AVAILABLE_PHYSICAL_MEMORY)
16-
cmake_host_system_information(RESULT AVAILABLE_VIRTUAL_MEMORY QUERY AVAILABLE_VIRTUAL_MEMORY)
17-
cmake_host_system_information(RESULT TOTAL_VIRTUAL_MEMORY QUERY TOTAL_VIRTUAL_MEMORY)
1814
cmake_host_system_information(RESULT TOTAL_PHYSICAL_MEMORY QUERY TOTAL_PHYSICAL_MEMORY)
1915

20-
# Peak memory computed "manually" for each platform (in MB)
21-
# Use a hard coded limit of 2 parallel linking jobs
22-
set(max_rss_linux_debug 3000)
23-
set(max_rss_linux_release 6000) # Force -j3 on a 16G memory machine.
24-
set(max_rss_darwin_debug 729)
25-
set(max_rss_darwin_release 395)
26-
set(max_rss_windows_debug 2100)
27-
set(max_rss_windows_release 1300)
28-
29-
# Use "release" limit only for matching single-config mode
30-
if(GENERATOR_IS_MULTI_CONFIG OR NOT DEFINED CMAKE_BUILD_TYPE)
31-
message(STATUS "Defaulting to debug")
32-
set(_postfix "debug")
16+
# Determine build type for memory estimation
17+
get_property(_is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
18+
if(_is_multi_config OR NOT DEFINED CMAKE_BUILD_TYPE)
19+
set(_build_type "debug")
3320
else()
34-
string(TOLOWER ${CMAKE_BUILD_TYPE} _type)
35-
if(_type STREQUAL release)
36-
set(_postfix "release")
37-
else()
38-
set(_postfix "debug")
39-
endif()
21+
string(TOLOWER "${CMAKE_BUILD_TYPE}" _build_type)
4022
endif()
4123

42-
string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} _system)
24+
# Estimated peak RSS per link job (in MB), by build type.
25+
# Measure with: /usr/bin/time -v cmake --build --preset <preset> -j1 --target lagrange_python
26+
set(_default_link_memory_release 16000) # 16GB
27+
set(_default_link_memory_relwithdebinfo 32000) # 32GB
28+
set(_default_link_memory_debug 32000) # 32GB
4329

44-
# Use a 3/2 factor safety margin compared to observed memory usage
45-
math(EXPR num_cpu_memory "${AVAILABLE_PHYSICAL_MEMORY} * 3 / 2 / ${max_rss_${_system}_${_postfix}}")
30+
# LTO links can require significantly more memory
31+
if(CMAKE_INTERPROCEDURAL_OPTIMIZATION)
32+
set(_default_link_memory_release 64000) # 64GB
33+
set(_default_link_memory_relwithdebinfo 64000) # 64GB
34+
endif()
4635

47-
# Compute limits for link/compile steps
48-
set(num_cpu_link 2)
49-
set(num_cpu_compile ${NUMBER_OF_PHYSICAL_CORES})
50-
if(num_cpu_link GREATER num_cpu_memory)
51-
set(num_cpu_link ${num_cpu_memory})
36+
if(DEFINED _default_link_memory_${_build_type})
37+
set(_link_memory ${_default_link_memory_${_build_type}})
38+
else()
39+
set(_link_memory ${_default_link_memory_debug})
5240
endif()
53-
if(num_cpu_compile GREATER num_cpu_memory)
54-
set(num_cpu_compile ${num_cpu_memory})
41+
42+
math(EXPR num_link_jobs "${TOTAL_PHYSICAL_MEMORY} / ${_link_memory}")
43+
if(num_link_jobs LESS 1)
44+
set(num_link_jobs 1)
5545
endif()
5646

5747
if(CMAKE_SCRIPT_MODE_FILE)
58-
# The message() command, without any mode, will print to stderr. But jenkins only allows us
59-
# to capture stdout. To print a clean message without hyphens, we use cmake's echo command.
60-
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${num_cpu_compile}")
48+
# Script mode: echo the number of physical cores for use as the -j flag in Jenkins.
49+
# Link parallelism is handled separately via Ninja job pools at configure time.
50+
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${NUMBER_OF_PHYSICAL_CORES}")
6151
else()
62-
message(STATUS "Parallelism: Available physical memory: ${AVAILABLE_PHYSICAL_MEMORY} / ${TOTAL_PHYSICAL_MEMORY}")
63-
message(STATUS "Parallelism: Available virtual memory: ${AVAILABLE_VIRTUAL_MEMORY} / ${TOTAL_VIRTUAL_MEMORY}")
64-
message(STATUS "Parallelism: Number of physical cores: ${NUMBER_OF_PHYSICAL_CORES}")
65-
message(STATUS "Parallelism: Limiting link pool to ${num_cpu_link}")
66-
message(STATUS "Parallelism: Limiting compile pool to ${num_cpu_compile}")
67-
endif()
52+
message(STATUS "Parallelism: Total physical memory: ${TOTAL_PHYSICAL_MEMORY} MB")
53+
message(STATUS "Parallelism: Link job memory budget: ${_link_memory} MB (${_build_type})")
54+
message(STATUS "Parallelism: Limiting link pool to ${num_link_jobs}")
6855

69-
# Limit parallelism based on number of physical cores + available memory.
70-
set_property(GLOBAL PROPERTY JOB_POOLS
71-
pool-link=${num_cpu_link}
72-
pool-compile=${num_cpu_compile}
73-
pool-precompile-header=${num_cpu_compile}
74-
)
75-
set(CMAKE_JOB_POOL_LINK "pool-link" CACHE STRING "Job pool for linking" FORCE)
76-
set(CMAKE_JOB_POOL_COMPILE "pool-compile" CACHE STRING "Job pool for compiling" FORCE)
77-
set(CMAKE_JOB_POOL_PRECOMPILE_HEADER "pool-precompile-header" CACHE STRING "Job pool for generating pre-compiled headers" FORCE)
78-
79-
# Note: We cannot set directly CMAKE_BUILD_PARALLEL_LEVEL or CTEST_PARALLEL_LEVEL from this CMake file,
80-
# since those are environment variables [1]: they are not cached and do not affect subsequent CMake calls.
81-
# In practice, the parallelism for Ninja should be limited by our job pools, so the only thing we need is
82-
# to run ctest in parallel.
83-
# [1]: https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#cmake-language-environment-variables
56+
set_property(GLOBAL PROPERTY JOB_POOLS pool-link=${num_link_jobs})
57+
set(CMAKE_JOB_POOL_LINK "pool-link" CACHE STRING "Job pool for linking" FORCE)
58+
endif()
8459
endfunction()
8560

86-
# If this file is run in script mode, calling this function will simply echo the total number of
87-
# cores that we desire to build/test with.
61+
# If this file is run in script mode, it echoes the number of physical cores for use as
62+
# the -j flag for cmake --build and ctest. Link parallelism is not relevant here — it is
63+
# enforced by Ninja job pools set during the configure step.
8864
if(CMAKE_SCRIPT_MODE_FILE)
8965
if(DEFINED CMAKE_ARGV3)
9066
# We need to extract build type from preset

cmake/recipes/external/CPM.cmake

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
# accordance with the terms of the Adobe license agreement accompanying
77
# it.
88
#
9-
set(CPM_DOWNLOAD_VERSION 0.42.1)
9+
10+
# we use a fork slightly ahead of this until https://github.com/cpm-cmake/CPM.cmake/pull/688 is merged
11+
set(CPM_DOWNLOAD_VERSION 0.42.1-f50a6c0)
1012

1113
if(CPM_SOURCE_CACHE)
1214
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
@@ -22,8 +24,10 @@ get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
2224
function(download_cpm)
2325
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
2426
file(DOWNLOAD
25-
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
26-
${CPM_DOWNLOAD_LOCATION}
27+
# Revert to upstream URL once https://github.com/cpm-cmake/CPM.cmake/pull/688 is merged:
28+
# https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
29+
https://raw.githubusercontent.com/jdumas/CPM.cmake/f50a6c0ad986fdd407ae14a46f08b38716f36bc8/cmake/CPM.cmake
30+
${CPM_DOWNLOAD_LOCATION}
2731
)
2832
endfunction()
2933

cmake/recipes/external/Eigen3.cmake

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,19 @@ endif()
1616
option(EIGEN_WITH_MKL "Use Eigen with MKL" OFF)
1717
option(EIGEN_DONT_VECTORIZE "Disable Eigen vectorization" OFF)
1818

19-
if(EIGEN_ROOT)
20-
message(STATUS "Third-party (external): creating target 'Eigen3::Eigen' for external path: ${EIGEN_ROOT}")
21-
set(EIGEN_INCLUDE_DIRS ${EIGEN_ROOT})
22-
else()
23-
message(STATUS "Third-party (external): creating target 'Eigen3::Eigen'")
19+
message(STATUS "Third-party (external): creating target 'Eigen3::Eigen'")
2420

25-
include(CPM)
26-
CPMAddPackage(
27-
NAME eigen
28-
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
29-
GIT_TAG 3.4.1
30-
DOWNLOAD_ONLY ON
31-
)
32-
set(EIGEN_INCLUDE_DIRS ${eigen_SOURCE_DIR})
21+
set(EIGEN_VERSION "5.0.1" CACHE STRING "Version of Eigen to use")
3322

34-
install(DIRECTORY ${EIGEN_INCLUDE_DIRS}/Eigen
35-
DESTINATION include
36-
)
37-
endif()
23+
include(CPM)
24+
CPMAddPackage(
25+
NAME eigen
26+
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
27+
GIT_TAG ${EIGEN_VERSION}
28+
DOWNLOAD_ONLY ON
29+
)
30+
FetchContent_GetProperties(eigen)
31+
set(EIGEN_INCLUDE_DIRS ${eigen_SOURCE_DIR})
3832

3933
add_library(Eigen3_Eigen INTERFACE)
4034
add_library(Eigen3::Eigen ALIAS Eigen3_Eigen)
@@ -44,6 +38,8 @@ target_include_directories(Eigen3_Eigen SYSTEM INTERFACE
4438
$<BUILD_INTERFACE:${EIGEN_INCLUDE_DIRS}>
4539
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
4640
)
41+
42+
# Not necessary after Eigen 5, but required for older versions. Doesn't hurt to keep it.
4743
target_compile_definitions(Eigen3_Eigen INTERFACE EIGEN_MPL2_ONLY)
4844

4945
if(EIGEN_DONT_VECTORIZE)

0 commit comments

Comments
 (0)