Skip to content

Commit

Permalink
Sync with 467e6b8 (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdumas authored May 30, 2024
1 parent fa7ac42 commit c370b1d
Show file tree
Hide file tree
Showing 35 changed files with 396 additions and 146 deletions.
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ endif()
cmake_policy(SET CMP0054 NEW) # Only interpret if() arguments as variables or keywords when unquoted.
cmake_policy(SET CMP0076 NEW) # target_sources() command converts relative paths to absolute.
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW) # Honor visibility properties for all target types.
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) # INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) # Avoid overriding normal variables with option()
set(CMAKE_POLICY_DEFAULT_CMP0091 NEW) # MSVC runtime library flags are selected by an abstraction.
set(CMAKE_POLICY_DEFAULT_CMP0126 NEW) # Avoid overriding normal variables with set(CACHE)
Expand Down Expand Up @@ -272,6 +273,19 @@ if(LAGRANGE_MODULE_ANORIGAMI OR LAGRANGE_MODULE_MESHPROC OR LAGRANGE_MODULE_CONT
endif()
endif()

if(LAGRANGE_TOPLEVEL_PROJECT)
# Enable Blosc/Zlib for OpenVDB in toplevel builds
option(USE_BLOSC "" ON)
option(USE_ZLIB "" ON)

# ASM (used by Blosc) and MASM (used by legacy TBB) may be needed in the same build, so we enable
# them both at the top-level, otherwise this CMake error can be triggered:
# https://gitlab.kitware.com/cmake/cmake/-/issues/25042
if(MSVC)
enable_language(ASM ASM_MASM)
endif()
endif()

# On Linux & Windows we use MKL to provide BLAS/LAPACK. Since it comes precompiled with /MD on Windows,
# we need to use the MSVC runtime library flag globally for the whole project.
file(READ "cmake/lagrange/lagrangeMklModules.txt" LAGRANGE_MKL_MODULES)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.22.0
6.23.0
37 changes: 37 additions & 0 deletions cmake/recipes/external/blosc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# Copyright 2024 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#
if(TARGET Blosc::blosc)
return()
endif()

message(STATUS "Third-party (external): creating target 'Blosc::blosc'")

# TODO: Use external zlib (via miniz)
# option(PREFER_EXTERNAL_ZLIB "Find and use external Zlib library instead of included sources." ON)
# include(miniz)

block()
set(BUILD_TESTS OFF)

include(CPM)
CPMAddPackage(
NAME blosc
GITHUB_REPOSITORY Blosc/c-blosc
GIT_TAG v1.21.5
)
endblock()

set_target_properties(blosc_static PROPERTIES POSITION_INDEPENDENT_CODE ON)

if(NOT TARGET Blosc::blosc)
add_library(Blosc::blosc ALIAS blosc_static)
endif()
4 changes: 1 addition & 3 deletions cmake/recipes/external/libfive.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ endif()

message(STATUS "Third-party (external): creating target 'libfive::libfive'")

set(LIBFIVE_HASH 248c15c57abd2b1b9ea0e05d0a40f579d225f00f)

include(eigen)
include(boost)

include(CPM)
CPMAddPackage(
NAME libfive
GITHUB_REPOSITORY libfive/libfive
GIT_TAG ${LIBFIVE_HASH}
GIT_TAG 248c15c57abd2b1b9ea0e05d0a40f579d225f00f
DOWNLOAD_ONLY ON
)

Expand Down
2 changes: 1 addition & 1 deletion cmake/recipes/external/nanobind.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ include(CPM)
CPMAddPackage(
NAME nanobind
GITHUB_REPOSITORY wjakob/nanobind
GIT_TAG v1.8.0
GIT_TAG v2.0.0
DOWNLOAD_ONLY ON
)

Expand Down
114 changes: 62 additions & 52 deletions cmake/recipes/external/opensubdiv.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,61 +15,71 @@ endif()

message(STATUS "Third-party (external): creating target 'opensubdiv::opensubdiv'")

include(CPM)
CPMAddPackage(
NAME opensubdiv
GITHUB_REPOSITORY PixarAnimationStudios/OpenSubdiv
GIT_TAG tags/v3_4_4
DOWNLOAD_ONLY ON
)
block()
set(NO_EXAMPLES ON)
set(NO_TUTORIALS ON)
set(NO_REGRESSION ON)
set(NO_PTEX ON)
set(NO_DOC ON)
set(NO_OMP ON)
set(NO_TBB ON)
set(NO_CUDA ON)
set(NO_OPENCL ON)
set(NO_CLEW ON)
set(NO_OPENGL ON)
set(NO_METAL ON)
set(NO_DX ON)
set(NO_TESTS ON)
set(NO_GLTESTS ON)
set(NO_GLEW ON)
set(NO_GLFW ON)
set(NO_GLFW_X11 ON)
set(NO_MACOS_FRAMEWORK ON)

# TODO: Use upstream CMake + Enable TBB
add_library(opensubdiv)
add_library(opensubdiv::opensubdiv ALIAS opensubdiv)
# We trick OpenSubdiv's CMake into _not_ calling `find_package(TBB)` by setting `TBB_FOUND` to `ON`.
set(TBB_FOUND ON)
set(TBB_CXX_FLAGS "")
include(tbb)

set_target_properties(opensubdiv PROPERTIES FOLDER third_party)

include(GNUInstallDirs)
target_include_directories(opensubdiv SYSTEM PUBLIC
$<BUILD_INTERFACE:${opensubdiv_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

if(CMAKE_HOST_WIN32)
target_compile_definitions(opensubdiv PUBLIC _USE_MATH_DEFINES)
endif()

set_target_properties(opensubdiv PROPERTIES POSITION_INDEPENDENT_CODE ON)
include(CPM)
CPMAddPackage(
NAME opensubdiv
GITHUB_REPOSITORY PixarAnimationStudios/OpenSubdiv
GIT_TAG v3_6_0
)

file(GLOB SRC_FILES
"${opensubdiv_SOURCE_DIR}/opensubdiv/far/*.h"
"${opensubdiv_SOURCE_DIR}/opensubdiv/far/*.cpp"
"${opensubdiv_SOURCE_DIR}/opensubdiv/sdc/*.h"
"${opensubdiv_SOURCE_DIR}/opensubdiv/sdc/*.cpp"
"${opensubdiv_SOURCE_DIR}/opensubdiv/vtr/*.h"
"${opensubdiv_SOURCE_DIR}/opensubdiv/vtr/*.cpp"
)
source_group(
TREE "${opensubdiv_SOURCE_DIR}/opensubdiv/"
FILES ${SRC_FILES}
)
target_sources(opensubdiv PRIVATE ${SRC_FILES})
# Note: OpenSubdiv doesn't support being compiled as a shared library on Windows:
# https://github.com/PixarAnimationStudios/OpenSubdiv/issues/71
if(BUILD_SHARED_LIBS AND TARGET osd_dynamic_cpu)
add_library(opensubdiv::opensubdiv ALIAS osd_dynamic_cpu)
set(OPENSUBDIV_TARGET osd_dynamic_cpu)
else()
add_library(opensubdiv::opensubdiv ALIAS osd_static_cpu)
set(OPENSUBDIV_TARGET osd_static_cpu)
endif()

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
target_compile_options(opensubdiv PRIVATE
"-Wno-unused-function"
)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(opensubdiv PRIVATE
"-Wno-class-memaccess"
"-Wno-cast-function-type"
"-Wno-strict-aliasing"
# OpenSubdiv's code uses relative header include paths, and fails to properly set a transitive include directory
# that propagates to dependent targets, so we need to set it up manually.
include(GNUInstallDirs)
target_include_directories(${OPENSUBDIV_TARGET} SYSTEM PUBLIC
$<BUILD_INTERFACE:${opensubdiv_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
endif()

# Install rules
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME opensubdiv)
install(DIRECTORY ${opensubdiv_SOURCE_DIR}/opensubdiv DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS opensubdiv EXPORT Opensubdiv_Targets)
install(EXPORT Opensubdiv_Targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/opensubdiv NAMESPACE opensubdiv::)
# Set folders for MSVC
foreach(name IN ITEMS bfr_obj far_obj osd_cpu_obj osd_static_cpu sdc_obj vtr_obj)
if(TARGET ${name})
set_target_properties(${name} PROPERTIES FOLDER third_party/opensubdiv/opensubdiv)
endif()
endforeach()
foreach(name IN ITEMS regression_common_obj regression_far_utils_obj)
if(TARGET ${name})
set_target_properties(${name} PROPERTIES FOLDER third_party/opensubdiv/regression)
endif()
endforeach()
foreach(name IN ITEMS public_headers)
if(TARGET ${name})
set_target_properties(${name} PROPERTIES FOLDER third_party/opensubdiv/public_headers)
endif()
endforeach()
endblock()
18 changes: 16 additions & 2 deletions cmake/recipes/external/openvdb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ include(CMakeDependentOption)
cmake_dependent_option(OPENVDB_INSTALL_CMAKE_MODULES "" OFF "OPENVDB_BUILD_CORE" OFF)

# TODO: Enable Blosc/Zlib
option(USE_BLOSC "" OFF) # maybe later
option(USE_ZLIB "" OFF) # maybe later
option(USE_BLOSC "" OFF)
option(USE_ZLIB "" OFF)
option(USE_LOG4CPLUS "" OFF) # maybe later
option(USE_EXR "" OFF)
option(USE_CCACHE "" OFF)
Expand Down Expand Up @@ -114,6 +114,20 @@ function(openvdb_import_target)
ignore_package(TBB)
ignore_package(Boost)

if(USE_ZLIB)
ignore_package(ZLIB)
include(miniz)
if(NOT TARGET ZLIB::ZLIB)
get_target_property(_aliased miniz::miniz ALIASED_TARGET)
add_library(ZLIB::ZLIB ALIAS ${_aliased})
endif()
endif()

if(USE_BLOSC)
include(blosc)
ignore_package(Blosc)
endif()

# Ready to include openvdb CMake
include(CPM)
CPMAddPackage(
Expand Down
3 changes: 2 additions & 1 deletion cmake/recipes/external/spdlog.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ endif()
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "spdlog")

# Versions of fmt bundled with spdlog:
# - spdlog 1.14.1 -> fmt 10.2.1
# - spdlog 1.13.0 -> fmt 9.1.0
# - spdlog 1.12.0 -> fmt 9.1.0
# - spdlog 1.11.0 -> fmt 9.1.0
Expand All @@ -33,7 +34,7 @@ include(CPM)
CPMAddPackage(
NAME spdlog
GITHUB_REPOSITORY gabime/spdlog
GIT_TAG v1.13.0
GIT_TAG v1.14.1
)

set_target_properties(spdlog PROPERTIES POSITION_INDEPENDENT_CODE ON)
Expand Down
11 changes: 9 additions & 2 deletions cmake/recipes/external/tbb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,16 @@ endif()
install(TARGETS tbb_tbb EXPORT TBB)

# Set -fPIC flag and IDE folder name for tbb targets
foreach(name IN ITEMS tbb_def_files tbb_static tbb tbbmalloc tbbmalloc_static tbb_tbb)
foreach(name IN ITEMS tbb_def_files tbb_static tbb tbbmalloc tbbmalloc_static tbbmalloc_proxy tbb_tbb)
if(TARGET ${name})
set_target_properties(${name} PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(${name} PROPERTIES FOLDER third_party)
set_target_properties(${name} PROPERTIES FOLDER third_party/tbb)
endif()
endforeach()

# Silence some compiler warnings
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(tbb PRIVATE
"-Wno-class-memaccess"
)
endif()
2 changes: 1 addition & 1 deletion cmake/recipes/external/tracy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ include(CPM)
CPMAddPackage(
NAME tracy
GITHUB_REPOSITORY wolfpld/tracy
GIT_TAG v0.9.1
GIT_TAG v0.10
)
3 changes: 0 additions & 3 deletions modules/bvh/include/lagrange/bvh/create_BVH.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ std::unique_ptr<BVH<VertexArray, ElementArray>> create_BVH( //
default: //
throw std::runtime_error("Unsupported BVH engine type: " + bvhtype_to_string(engine_type));
}

// Don't complain dear compiler
return nullptr;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions modules/core/include/lagrange/utils/fmt_eigen.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ struct fmt::formatter<T, std::enable_if_t<std::is_base_of<Eigen::DenseBase<T>, T
for (Eigen::Index ic = 0; ic < a.cols(); ic++) {
out = fmt::format_to(out, "{} ", this->nested(a(ir, ic)));
}
out = fmt::format_to(out, "\n");
if (ir + 1 < a.rows()) {
out = fmt::format_to(out, "\n");
}
}
return out;
});
Expand Down Expand Up @@ -148,7 +150,7 @@ struct fmt::is_range<
#include <lagrange/utils/warnoff.h>
#include <spdlog/fmt/ostr.h>
#include <lagrange/utils/warnon.h>
// clang-format on
// clang-format on

template <typename Derived>
struct fmt::is_range<
Expand Down
8 changes: 2 additions & 6 deletions modules/core/python/scripts/meshconvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@


def parse_args():
parser = argparse.ArgumentParser(
description="Convert a mesh file to a different format."
)
parser = argparse.ArgumentParser(description="Convert a mesh file to a different format.")
parser.add_argument("input_mesh", help="input mesh file")
parser.add_argument("output_mesh", help="output mesh file")
parser.add_argument(
"--triangulate", "-t", action="store_true", help="triangulate the mesh"
)
parser.add_argument("--triangulate", "-t", action="store_true", help="triangulate the mesh")
parser.add_argument(
"--logging-level",
"-l",
Expand Down
15 changes: 3 additions & 12 deletions modules/core/python/scripts/meshstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@


def print_header(message):
print(
colorama.Fore.YELLOW
+ colorama.Style.BRIGHT
+ message
+ colorama.Style.RESET_ALL
)
print(colorama.Fore.YELLOW + colorama.Style.BRIGHT + message + colorama.Style.RESET_ALL)


def print_green(message):
Expand Down Expand Up @@ -52,9 +47,7 @@ def print_basic_info(mesh, info):
info["num_facets"] = num_facets
info["num_edges"] = num_edges
info["num_corners"] = num_corners
print(
f"#v: {num_vertices:<10}#f: {num_facets:<10}#e: {num_edges:<10}#c: {num_corners:<10}"
)
print(f"#v: {num_vertices:<10}#f: {num_facets:<10}#e: {num_edges:<10}#c: {num_corners:<10}")

# Mesh bbox
bbox_min = np.amin(mesh.vertices, axis=0)
Expand Down Expand Up @@ -126,9 +119,7 @@ def print_attributes(mesh):
num_channels = attr.num_channels

print(f"Attribute {colorama.Fore.GREEN}{name}{colorama.Style.RESET_ALL}")
print(
f" id:{id:<5}usage: {usage:<10}elem: {element_type:<10}channels: {num_channels}"
)
print(f" id:{id:<5}usage: {usage:<10}elem: {element_type:<10}channels: {num_channels}")


def load_info(mesh_file):
Expand Down
Loading

0 comments on commit c370b1d

Please sign in to comment.