Skip to content

Commit

Permalink
Sync with 43a2421 (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: Jérémie Dumas <jeremie.dumas@ens-lyon.org>
  • Loading branch information
HasKha and jdumas committed Dec 22, 2023
1 parent 587f6ab commit b0a868a
Show file tree
Hide file tree
Showing 121 changed files with 9,561 additions and 389 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wheel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
python-version: '3.8'

- name: Build wheels
uses: pypa/cibuildwheel@v2.12.1
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_ARCHS_LINUX: auto64
CIBW_ARCHS_WINDOWS: auto64
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ __pycache__
*.vtk

# Openvdb files
*.vdb
tensor_*.json
tensor_*.vdb
func_*.json

# Extra directories
/.vscode
Expand Down
53 changes: 32 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,27 @@ else()
endif()

# Python defaults
if(SKBUILD)
if(LINUX)
# MKL doesn't support building Python modules with individual shared libraries. On Linux dlopen()
# would fail with the following error:
#
# INTEL MKL ERROR: <...>/libmkl_def.so.1: undefined symbol: mkl_sparse_optimize_bsr_trsm_i8.
# Intel MKL FATAL ERROR: Cannot load libmkl_def.so.1.
#
# The reason is that the three libraries libmkl_core, libmkl_intel and libmkl_thread need to be
# dlopened with RTLD_GLOBAL first. One needs to link against libmkl_rt instead. See this issue for
# more details:
#
# https://gitlab.kitware.com/cmake/cmake/-/issues/20491
#
# Note: We should probably enable this on macOS as well, but our Jenkins nodes don't have a
# Fortran compiler (and our pre-built Arpack doesn't link against mkl_rt).
#
set(MKL_LINKING "sdl" CACHE STRING "Linking strategy to use with MKL (static, dynamic or sdl)")
option(ARPACK_BUILD_FROM_SOURCE "Build arpack from source using a Fortran compiler" ON)
endif()
if(SKBUILD AND LINUX)
# MKL doesn't support building Python modules with individual shared libraries. On Linux dlopen()
# would fail with the following error:
#
# INTEL MKL ERROR: <...>/libmkl_def.so.1: undefined symbol: mkl_sparse_optimize_bsr_trsm_i8.
# Intel MKL FATAL ERROR: Cannot load libmkl_def.so.1.
#
# The reason is that the three libraries libmkl_core, libmkl_intel and libmkl_thread need to be
# dlopened with RTLD_GLOBAL first. One needs to link against libmkl_rt instead. See this issue for
# more details:
#
# https://gitlab.kitware.com/cmake/cmake/-/issues/20491
#
# Note: We should probably enable this on macOS as well, but our Jenkins nodes don't have a
# Fortran compiler (and our pre-built Arpack doesn't link against mkl_rt).
#
set(MKL_LINKING "sdl" CACHE STRING "Linking strategy to use with MKL (static, dynamic or sdl)")
option(ARPACK_BUILD_FROM_SOURCE "Build arpack from source using a Fortran compiler" ON)

# Set RPATH to $ORIGIN on Linux
set(CMAKE_INSTALL_RPATH $ORIGIN)
endif()

# Meta target: ALL includes all optional modules and UI.
Expand Down Expand Up @@ -177,6 +178,7 @@ option(LAGRANGE_PERFORMANCE_TESTS "Build all performance tests"
option(LAGRANGE_UNIT_TESTS "Build all unit tests" ${LAGRANGE_TOPLEVEL_PROJECT})
option(LAGRANGE_USE_PCH "Enable precompiled headers" OFF)
option(LAGRANGE_USE_WASM_EXCEPTIONS "Use -fwasm-exception flag with Emscripten" OFF)
option(LAGRANGE_USE_WASM_THREADS "Enable threads (-pthread) with Emscripten" ON)
option(LAGRANGE_WITH_ONETBB "Build Lagrange with OneTBB 2021 rather than TBB 2020" ON)
option(LAGRANGE_WITH_TRACY "Build tracy client with Lagrange" OFF)

Expand Down Expand Up @@ -294,6 +296,7 @@ include(lagrange_include_modules)
include(lagrange_install)
include(lagrange_limit_parallelism)
include(lagrange_warnings)
include(lagrange_xcode_check)
include(sanitizers)

if(LAGRANGE_TOPLEVEL_PROJECT)
Expand All @@ -308,7 +311,15 @@ if(LAGRANGE_LIMIT_PARALLELISM)
lagrange_limit_parallelism()
endif()

find_package(Threads REQUIRED)
set(TBB_ENABLE_WASM_THREADS ${LAGRANGE_USE_WASM_THREADS})

# Force -pthread during compilation for Emscripten
if(EMSCRIPTEN AND LAGRANGE_USE_WASM_THREADS)
set(THREADS_HAVE_PTHREAD_ARG TRUE)
endif()

set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED GLOBAL)

# Include OneTBB early to provide TBB::tbb target
if(LAGRANGE_WITH_ONETBB)
Expand Down
2 changes: 2 additions & 0 deletions LagrangeOptions.cmake.sample
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
# Optional modules in alphabetical order.
# option(LAGRANGE_MODULE_BVH "Build module lagrange::bvh" ON)
# option(LAGRANGE_MODULE_FS "Build module lagrange::fs" ON)
# option(LAGRANGE_MODULE_IMAGE "Build module lagrange::image" ON)
# option(LAGRANGE_MODULE_IMAGE_IO "Build module lagrange::image_io" ON)
# option(LAGRANGE_MODULE_IO "Build module lagrange::io" ON)
# option(LAGRANGE_MODULE_PARTITIONING "Build module lagrange::partitioning" ON)
# option(LAGRANGE_MODULE_PYTHON "Build module lagrange::python" ON)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.17.0
6.18.0
1 change: 1 addition & 0 deletions cmake/lagrange/lagrange_add_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function(lagrange_add_test)
# TSan suppression file to be passed to catch_discover_tests
set(LAGRANGE_TESTS_ENVIRONMENT
"TSAN_OPTIONS=suppressions=${PROJECT_SOURCE_DIR}/.github/tsan.suppressions.ini"
"ASAN_SAVE_DUMPS=${module_name}.dmp"
)

# Output directory
Expand Down
2 changes: 1 addition & 1 deletion cmake/lagrange/lagrange_download_data.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function(lagrange_download_data)
PREFIX "${FETCHCONTENT_BASE_DIR}/lagrange-test-data"
SOURCE_DIR ${LAGRANGE_DATA_FOLDER}
GIT_REPOSITORY https://github.com/adobe/lagrange-test-data.git
GIT_TAG 3b2de026c4b96a85f1a40b2d412586dc071c8761
GIT_TAG c9a65d430c74bb8a30c3b556682cfaf88024ddf6
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
Expand Down
10 changes: 8 additions & 2 deletions cmake/lagrange/lagrange_global_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ if(EMSCRIPTEN)
set(EMSCRIPTEN_EXCEPTION_HANDLER_FLAG "-fexceptions")
endif()

add_compile_options(${EMSCRIPTEN_EXCEPTION_HANDLER_FLAG} -pthread)
add_link_options(${EMSCRIPTEN_EXCEPTION_HANDLER_FLAG} -pthread)
if(LAGRANGE_USE_WASM_THREADS)
set(EMSCRIPTEN_THREAD_FLAG "-pthread")
else()
set(EMSCRIPTEN_THREAD_FLAG "")
endif()

add_compile_options(${EMSCRIPTEN_EXCEPTION_HANDLER_FLAG} ${EMSCRIPTEN_THREAD_FLAG})
add_link_options(${EMSCRIPTEN_EXCEPTION_HANDLER_FLAG} ${EMSCRIPTEN_THREAD_FLAG})
endif()
59 changes: 59 additions & 0 deletions cmake/lagrange/lagrange_xcode_check.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
# Copyright 2023 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(NOT CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
return()
endif()

# Xcode 15's new linker will crash. We suggest either using the classical linker, or upgrading to Xcode 15.1.
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.1)
# First let's check if we are using the classical linker
set(is_using_classical_linker FALSE)
foreach(type IN ITEMS EXE SHARED MODULE)
set(suffix_types "none")
if(DEFINED CMAKE_CONFIGURATION_TYPES)
list(APPEND suffix_types ${CMAKE_CONFIGURATION_TYPES})
endif()
foreach(config IN LISTS suffix_types)
if(config STREQUAL "none")
set(config "")
else()
set(config "_${config}")
endif()
if(NOT DEFINED CMAKE_${type}_LINKER_FLAGS${config}_INIT)
continue()
endif()
if(CMAKE_${type}_LINKER_FLAGS${config}_INIT MATCHES "-Wl,-ld_classic")
set(is_using_classical_linker TRUE)
break()
endif()
endforeach()
endforeach()

# If not, display an error message
if(NOT is_using_classical_linker)
option(LAGRANGE_IGNORE_XCODE_15_LINKER_ERROR "Turn Xcode 15 linker check from an error into a warning" OFF)
if(LAGRANGE_IGNORE_XCODE_15_LINKER_ERROR)
set(mode WARNING)
set(postfix "")
else()
set(mode FATAL_ERROR)
set(postfix "You can also ignore this error by calling CMake with -DLAGRANGE_IGNORE_XCODE_15_LINKER_ERROR=ON\n")
endif()
message(${mode}
"Xcode 15.0 has a new linker that will cause a crash when linking weak symbols in C++. "
"We suggest either:\n1. Upgrading to Xcode >= 15.1, or\n2. Using the classical linker by deleting "
"your <build>/CMakeCache.txt and re-running CMake configure with \n"
" LDFLAGS=\"$LDFLAGS -Wl,-ld_classic\" cmake ..\n"
${postfix}
)
endif()
endif()
2 changes: 1 addition & 1 deletion cmake/recipes/external/assimp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ include(CPM)
CPMAddPackage(
NAME assimp
GITHUB_REPOSITORY assimp/assimp
GIT_TAG 0fdae2879d78864693ee730610dcf8ee10707875
GIT_TAG c1deb808faadd85a7a007447b62ae238a4be2337
)

set_target_properties(assimp PROPERTIES FOLDER third_party//assimp)
Expand Down
10 changes: 9 additions & 1 deletion cmake/recipes/external/boost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ option(BOOST_IOSTREAMS_ENABLE_ZSTD "Boost.Iostreams: Enable Zstd support" OFF)
add_library(boost_numeric_ublas INTERFACE)
add_library(Boost::numeric_ublas ALIAS boost_numeric_ublas)

if(SKBUILD)
set(OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS ON)
endif()

# Boost 1.82.0 is the min version we can use that supports upstream modern
# CMake targets (Boost::boost, Boost::headers, etc.)
include(CPM)
Expand All @@ -92,6 +97,10 @@ CPMAddPackage(
EXCLUDE_FROM_ALL ON
)

if(SKBUILD)
set(BUILD_SHARED_LIBS ${OLD_BUILD_SHARED_LIBS})
endif()

target_include_directories(boost_numeric_ublas INTERFACE
"${Boost_SOURCE_DIR}/libs/numeric/ublas/include"
)
Expand Down Expand Up @@ -125,7 +134,6 @@ target_compile_features(boost_numeric_ublas INTERFACE cxx_std_11)
# spoof the <auto_link.hpp> header with a blank one and remove the problematic error message.
if(TARGET Boost::random)
set(boost_dummy_autolink_dir "${Boost_BINARY_DIR}/dummy/boost/config/")
message("Creating dummy <auto_link.hpp> in ${boost_dummy_autolink_dir}")
file(WRITE "${boost_dummy_autolink_dir}/auto_link.hpp.in" "")
configure_file(${boost_dummy_autolink_dir}/auto_link.hpp.in ${boost_dummy_autolink_dir}/auto_link.hpp COPYONLY)
target_include_directories(boost_random PRIVATE "${Boost_BINARY_DIR}/dummy")
Expand Down
1 change: 1 addition & 0 deletions cmake/recipes/external/embree.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ function(embree_import_target)
set(unix_compilers "AppleClang;Clang;GNU")
if(CMAKE_CXX_COMPILER_ID IN_LIST unix_compilers) # IN_LIST wants the second arg to be a var
target_compile_options(embree PRIVATE "-Wno-unused-private-field")
target_compile_options(embree PRIVATE "-Wno-unused-but-set-variable")
endif()

# Now we need to do some juggling to propagate the include directory properties
Expand Down
1 change: 1 addition & 0 deletions cmake/recipes/external/miniz.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ target_include_directories(miniz PUBLIC
)

set_target_properties(miniz PROPERTIES FOLDER third_party)
set_target_properties(miniz PROPERTIES POSITION_INDEPENDENT_CODE ON)

target_include_directories(miniz PUBLIC
$<BUILD_INTERFACE:${miniz_BINARY_DIR}>
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.0.0
GIT_TAG v1.8.0
DOWNLOAD_ONLY ON
)

Expand Down
1 change: 1 addition & 0 deletions cmake/recipes/external/nlohmann_json.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ target_include_directories(nlohmann_json INTERFACE
"$<BUILD_INTERFACE:${nlohmann_json_SOURCE_DIR}>/include"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_compile_features(nlohmann_json INTERFACE cxx_std_11)

# Install rules
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME nlohmann_json)
Expand Down
9 changes: 8 additions & 1 deletion cmake/recipes/external/onetbb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ option(TBB_TEST "Enable testing" OFF)
option(TBB_EXAMPLES "Enable examples" OFF)
option(TBB_STRICT "Treat compiler warnings as errors" OFF)
option(TBB_PREFER_STATIC "Use the static version of TBB for the alias target" ON)
option(TBB_ENABLE_WASM_THREADS "Use wasm threads" ON)
unset(TBB_DIR CACHE)

function(onetbb_import_target)
Expand Down Expand Up @@ -62,12 +63,18 @@ function(onetbb_import_target)

set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME tbb)
include(CPM)

CPMAddPackage(
NAME tbb
GITHUB_REPOSITORY oneapi-src/oneTBB
GIT_TAG v2021.10.0
GIT_TAG v2021.11.0
)

# TODO: This might break with future versions of onetbb. Onetbb should eventually add a proper cmake option to turn wasm threads on/off.
if (EMSCRIPTEN AND NOT TBB_ENABLE_WASM_THREADS)
set_property(TARGET Threads::Threads PROPERTY INTERFACE_LINK_LIBRARIES "")
endif()

pop_variable(BUILD_SHARED_LIBS)
endfunction()

Expand Down
2 changes: 1 addition & 1 deletion cmake/recipes/external/openvdb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function(openvdb_import_target)
CPMAddPackage(
NAME openvdb
GITHUB_REPOSITORY AcademySoftwareFoundation/openvdb
GIT_TAG v10.1.0
GIT_TAG v11.0.0
)

unignore_package(TBB)
Expand Down
2 changes: 1 addition & 1 deletion cmake/recipes/external/python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ if(TARGET Python::Module)
endif()

set(Python_FIND_VIRTUALENV FIRST)
find_package(Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED)
find_package(Python 3.9 COMPONENTS Interpreter Development.Module REQUIRED)
26 changes: 23 additions & 3 deletions cmake/recipes/external/sanitizers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ function(append value)
endfunction()

if(USE_SANITIZER)
append("-fno-omit-frame-pointer" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)

if(UNIX)
append("-fno-omit-frame-pointer" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)

if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
append("-O1" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
Expand Down Expand Up @@ -79,7 +79,27 @@ if(USE_SANITIZER)
elseif(MSVC)
if(USE_SANITIZER MATCHES "([Aa]ddress)")
message(STATUS "Building with Address sanitizer")
append("-fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
# Do use AddressSanitizer you need to disable incompatible options. See details here:
# https://learn.microsoft.com/en-us/cpp/sanitizers/asan?view=msvc-170#ide-msbuild
#
# Please note that there are some issues with using it directly from the IDE, it may work better to
# run the code from the command-line (and through `ctest` which enables the ASAN_SAVE_DUMPS env variable):
# https://stackoverflow.com/questions/76781556/visual-studio-22-asan-failed-to-use-and-restart-external-symbolizer
# https://developercommunity.visualstudio.com/t/Fail-to-use-and-restart-external-symbol/10222443?q=+Failed+to+use+and+restart+external+symbolizer
append("/fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)

# Disable incremental linking
add_link_options(/INCREMENTAL:NO)

# Disable RTC flag
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
string(REGEX REPLACE "/RTC[^ ]*" "" ${flag_var} "${${flag_var}}")
endforeach(flag_var)

# Do not use program database for debug builds (since it requires incremental linking).
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>")
else()
message(
FATAL_ERROR
Expand Down
33 changes: 33 additions & 0 deletions cmake/recipes/external/stackwalker.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# Copyright 2023 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 StackWalker::StackWalker)
return()
endif()

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

option(StackWalker_DISABLE_TESTS "Disable tests" ON)

include(CPM)
CPMAddPackage(
NAME StackWalker
GITHUB_REPOSITORY JochenKalmbach/StackWalker
GIT_TAG 5b0df7a4db8896f6b6dc45d36e383c52577e3c6b
DOWNLOAD_ONLY YES
)

add_library(StackWalker STATIC ${StackWalker_SOURCE_DIR}/Main/StackWalker/StackWalker.cpp)
add_library(StackWalker::StackWalker ALIAS StackWalker)

target_include_directories(StackWalker PUBLIC ${StackWalker_SOURCE_DIR}/Main/StackWalker)

set_target_properties(StackWalker PROPERTIES FOLDER third_party)
Loading

0 comments on commit b0a868a

Please sign in to comment.