Skip to content

Commit

Permalink
Sync with 074358a
Browse files Browse the repository at this point in the history
  • Loading branch information
qnzhou committed Sep 8, 2022
1 parent 37cbd9d commit 9fb82d7
Show file tree
Hide file tree
Showing 438 changed files with 12,980 additions and 1,133 deletions.
14 changes: 4 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2020 Adobe. All rights reserved.
# Copyright 2016 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
Expand Down Expand Up @@ -65,7 +65,7 @@ if(LAGRANGE_WITH_CCACHE AND CCACHE_PROGRAM)
endif()

################################################################################
project(Lagrange VERSION 6.3.0)
project(Lagrange VERSION 6.4.0)

# Detects whether internal libs are available
if(IS_DIRECTORY "${PROJECT_SOURCE_DIR}/cmake/recipes/internal")
Expand All @@ -92,16 +92,10 @@ option(LAGRANGE_UNIT_TESTS "Build all unit tests"
option(LAGRANGE_USE_PCH "Enable precompiled headers" OFF)
option(LAGRANGE_WITH_ONETBB "Build Lagrange with OneTBB 2021 rather than TBB 2020" ON)
option(LAGRANGE_WITH_TRACY "Build tracy client with Lagrange" OFF)
option(LAGRANGE_ENABLE_LEGACY_FUNCTIONS "Enable support for legacy functions." ON)

# Specific override for building on Jenkins
if(LAGRANGE_JENKINS)
if(CMAKE_HOST_SYSTEM_NAME MATCHES Linux)
# Unfortunately, on CentOS 7, the pre-compiled version of libarpack.so provided by
# anorigami is somehow incompatible with our built-from-source TBB. Indeed, their
# libarpack.so is looking for libtbb.so.2, but our CMake only produces a libtbb.so.
# Until we figure this out, we have to build arpack ourselves from source on CentOS.
option(ARPACK_BUILD_FROM_SOURCE "Build arpack from source using a Fortran compiler" ON)
endif()
# IPO is very slow and not needed for CI purposes
option(TBB_ENABLE_IPO "Enable Interprocedural Optimization (IPO) during the compilation" OFF)
endif()
Expand Down Expand Up @@ -217,7 +211,7 @@ if(LAGRANGE_UNIT_TESTS)
# Include Catch2 and provide function `catch_discover_tests` to register tests.
include(catch2)
FetchContent_GetProperties(catch2)
include("${catch2_SOURCE_DIR}/contrib/Catch.cmake")
include("${catch2_SOURCE_DIR}/extras/Catch.cmake")

# Global target for code coverage
if(LAGRANGE_TOPLEVEL_PROJECT)
Expand Down
11 changes: 8 additions & 3 deletions LagrangeOptions.cmake.sample
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@
# option(LAGRANGE_ALL "Build all lagrange modules" ON)

# Optional modules in alphabetical order.
# option(LAGRANGE_MODULE_FS "Build module lagrange::fs" ON)
# option(LAGRANGE_MODULE_IO "Build module lagrange::io" ON)
# option(LAGRANGE_MODULE_UI "Build module lagrange::ui" ON)
# option(LAGRANGE_MODULE_BVH "Build module lagrange::bvh" ON)
# option(LAGRANGE_MODULE_FS "Build module lagrange::fs" ON)
# option(LAGRANGE_MODULE_IO "Build module lagrange::io" ON)
# option(LAGRANGE_MODULE_PARTITIONING "Build module lagrange::partitioning" ON)
# option(LAGRANGE_MODULE_RAYCASTING "Build module lagrange::raycasting" ON)
# option(LAGRANGE_MODULE_SUBDIVISION "Build module lagrange::subdivision" ON)
# option(LAGRANGE_MODULE_UI "Build module lagrange::ui" ON)
# option(LAGRANGE_MODULE_VOLUME "Build module lagrange::volume" ON)

# General options
# option(LAGRANGE_DOCUMENTATION "Build Doxygen documentation" ON)
Expand Down
16 changes: 16 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ This codebase contains a modified portion of code from Earcut which can be obtai
* LICENSE:
* https://github.com/mapbox/earcut.hpp/blob/master/LICENSE

-------------------------------------------------------------------------------
This codebase contains a modified portion of code from Embree which can be obtained at:
* SOURCE:
* https://github.com/embree/embree/blob/ae029e2ff83bebbbe8742c88aba5b0521aba1a23/tutorials/closest_point/closest_point_device.cpp#L261-L341

* LICENSE:
* https://github.com/embree/embree/blob/master/LICENSE.txt

-------------------------------------------------------------------------------
This codebase contains a modified portion of code from Floating-point exception handling example which can be obtained at:
* SOURCE:
Expand Down Expand Up @@ -103,6 +111,14 @@ This codebase contains a modified portion of code from ImGui Progress Indicators
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-------------------------------------------------------------------------------
This codebase contains a modified portion of code from Libigl which can be obtained at:
* SOURCE:
* https://github.com/libigl/libigl

* LICENSE:
* https://github.com/libigl/libigl/blob/main/LICENSE.MPL2

-------------------------------------------------------------------------------
This codebase contains a modified portion of code from scope_guard which can be obtained at:
* SOURCE:
Expand Down
2 changes: 1 addition & 1 deletion cmake/lagrange/lagrange_add_executable.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2020 Adobe. All rights reserved.
# Copyright 2021 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
Expand Down
2 changes: 1 addition & 1 deletion cmake/lagrange/lagrange_add_module.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2021 Adobe. All rights reserved.
# Copyright 2020 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
Expand Down
21 changes: 20 additions & 1 deletion cmake/lagrange/lagrange_add_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ function(lagrange_add_test)
get_filename_component(module_path "${CMAKE_CURRENT_SOURCE_DIR}/.." REALPATH)
get_filename_component(module_name "${module_path}" NAME)

# Retrieve options
set(options CUSTOM_MAIN)
set(oneValueArgs "")
set(multiValueArgs "")
cmake_parse_arguments(OPTIONS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

# Create test executable
file(GLOB_RECURSE SRC_FILES "*.cpp" "*.h")
include(lagrange_add_executable)
Expand All @@ -28,10 +34,20 @@ function(lagrange_add_test)
lagrange::testing
)

# Use Catch2's provided main() by default
if(NOT OPTIONS_CUSTOM_MAIN)
target_link_libraries(${test_target} PUBLIC Catch2::Catch2WithMain)
endif()

# Enable code coverage
include(FetchContent)
target_code_coverage(${test_target} AUTO ALL EXCLUDE "${FETCHCONTENT_BASE_DIR}/*")

# TSan suppression file to be passed to catch_discover_tests
set(LAGRANGE_TESTS_ENVIRONMENT
"TSAN_OPTIONS=suppressions=${PROJECT_SOURCE_DIR}/scripts/tsan.suppressions"
)

# Output directory
set_target_properties(${test_target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests")

Expand All @@ -42,9 +58,12 @@ function(lagrange_add_test)
REPORTER junit
OUTPUT_DIR "${CMAKE_BINARY_DIR}/reports"
OUTPUT_SUFFIX ".xml"
PROPERTIES ENVIRONMENT ${LAGRANGE_TESTS_ENVIRONMENT}
)
else()
catch_discover_tests(${test_target})
catch_discover_tests(${test_target}
PROPERTIES ENVIRONMENT ${LAGRANGE_TESTS_ENVIRONMENT}
)
endif()

endfunction()
5 changes: 3 additions & 2 deletions 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 3b6d5e1b000a68c0c06cce10f73c60fcdb64dbcf
GIT_TAG bb6f8c0bd6347032d43d4d39e757d22439bc7645
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
Expand All @@ -49,6 +49,7 @@ function(lagrange_download_data)
list(GET entry 1 remote_path)
list(GET entry 2 checksum)
set(local_path "${LAGRANGE_DATA_FOLDER}/${local_relpath}")
set(keyfile_option "${LAGRANGE_ARTIFACTORY_KEYFILE}")

add_custom_command(
OUTPUT
Expand All @@ -61,7 +62,7 @@ function(lagrange_download_data)
"${local_relpath}"
"${remote_path}"
"${checksum}"
"${LAGRANGE_ARTIFACTORY_KEYFILE}"
${keyfile_option}
COMMENT
"Downloading file ${local_path}"
VERBATIM
Expand Down
2 changes: 1 addition & 1 deletion cmake/lagrange/lagrange_filter_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function(lagrange_filter_flags flags)
check_cxx_compiler_flag("${FLAG}" IS_SUPPORTED_${FLAG_VAR})
endif()
if(IS_SUPPORTED_${FLAG_VAR})
list(APPEND output_flags ${FLAG})
list(APPEND output_flags $<$<COMPILE_LANGUAGE:CXX>:${FLAG}>)
endif()
endforeach()
set(${flags} ${output_flags} PARENT_SCOPE)
Expand Down
9 changes: 8 additions & 1 deletion cmake/recipes/external/catch2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ include(FetchContent)
FetchContent_Declare(
catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.7
GIT_TAG v3.0.0-preview4
GIT_SHALLOW TRUE
)

option(CATCH_CONFIG_CPP17_STRING_VIEW "Enable support for std::string_view" ON)
FetchContent_MakeAvailable(catch2)

target_compile_features(Catch2 PUBLIC cxx_std_17)

set_target_properties(Catch2 PROPERTIES FOLDER third_party)
set_target_properties(Catch2WithMain PROPERTIES FOLDER third_party)
2 changes: 1 addition & 1 deletion cmake/recipes/external/eigen.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2020 Adobe. All rights reserved.
# Copyright 2019 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
Expand Down
97 changes: 97 additions & 0 deletions cmake/recipes/external/embree.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#
# Copyright 2022 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 embree::embree)
return()
endif()

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

include(FetchContent)
FetchContent_Declare(
embree
GIT_REPOSITORY https://github.com/embree/embree.git
GIT_TAG v3.13.4
GIT_SHALLOW TRUE
)

# Set Embree's default options
option(EMBREE_ISPC_SUPPORT "Build Embree with support for ISPC applications." OFF)
option(EMBREE_TUTORIALS "Enable to build Embree tutorials" OFF)
option(EMBREE_STATIC_LIB "Build Embree as a static library." ON)
set(EMBREE_TESTING_INTENSITY 0 CACHE STRING "Intensity of testing (0 = no testing, 1 = verify and tutorials, 2 = light testing, 3 = intensive testing.")
set(EMBREE_TASKING_SYSTEM "TBB" CACHE STRING "Selects tasking system")

# The following options are necessary to ensure packed-ray support
option(EMBREE_RAY_MASK "Enable the usage of mask for packed ray." ON)
option(EMBREE_RAY_PACKETS "Enable the usage packed ray." ON)

if(APPLE)
set(EMBREE_MAX_ISA "NEON" CACHE STRING "Selects highest ISA to support.")
elseif(EMSCRIPTEN)
set(EMBREE_MAX_ISA "SSE2" CACHE STRING "Selects highest ISA to support.")
else()
set(EMBREE_MAX_ISA "DEFAULT" CACHE STRING "Selects highest ISA to support.")
endif()

# We want to compile Embree with TBB support, so we need to overwrite Embree's
# `find_package()` and provide variables. The following discussion provide some
# context on how to achieve this:
# - https://gitlab.kitware.com/cmake/cmake/issues/17735
# - https://crascit.com/2018/09/14/do-not-redefine-cmake-commands/
function(embree_import_target)
macro(ignore_package NAME)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${NAME}/${NAME}Config.cmake "")
set(${NAME}_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NAME} CACHE PATH "" FORCE)
endmacro()

# Prefer Config mode before Module mode to prevent embree from loading its own FindTBB.cmake
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)

# Embree wants to be able to export() its target, and expects a target named `TBB` to exist.
# Somehow we stil need to define `TBB_INCLUDE_DIRS`, and linking against `TBB` isn't sufficient
# to compile embree targets properly.
include(tbb)
ignore_package(TBB)
get_target_property(TBB_INCLUDE_DIRS TBB::tbb INTERFACE_INCLUDE_DIRECTORIES)
add_library(TBB INTERFACE)
target_link_libraries(TBB INTERFACE TBB::tbb)
set(TBB_LIBRARIES TBB)

# Ready to include embree's atrocious CMake
FetchContent_MakeAvailable(embree)

# Disable warnings
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# Embree's subgrid.h is known for causing array subscript out of bound
# warning. Embree dev claim the code is correct and it is a GCC bug
# for misfiring warnings. See https://github.com/embree/embree/issues/271
#
# The issue should be fixed for gcc 9.2.1 and later.
target_compile_options(embree PRIVATE "-Wno-array-bounds")
endif()

# Now we need to do some juggling to propagate the include directory properties
# along with the `embree` target
add_library(embree::embree INTERFACE IMPORTED GLOBAL)
target_include_directories(embree::embree SYSTEM INTERFACE ${embree_SOURCE_DIR}/include)
target_link_libraries(embree::embree INTERFACE embree)
endfunction()

# Call via a proper function in order to scope variables such as CMAKE_FIND_PACKAGE_PREFER_CONFIG and TBB_DIR
embree_import_target()

# Cleanup for IDEs
foreach(name IN ITEMS embree algorithms lexers math simd sys tasking uninstall)
if(TARGET ${name})
set_target_properties(${name} PROPERTIES FOLDER "third_party//embree")
endif()
endforeach()
81 changes: 81 additions & 0 deletions cmake/recipes/external/gklib.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#
# Copyright 2022 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 GKlib::GKlib)
return()
endif()

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

include(FetchContent)
FetchContent_Declare(
gklib
GIT_REPOSITORY https://github.com/KarypisLab/GKlib.git
GIT_TAG a7f8172703cf6e999dd0710eb279bba513da4fec
)

FetchContent_GetProperties(gklib)
if(NOT gklib_POPULATED)
FetchContent_Populate(gklib)
endif()

file(GLOB INC_FILES "${gklib_SOURCE_DIR}/*.h" )
file(GLOB SRC_FILES "${gklib_SOURCE_DIR}/*.c" )
if(NOT MSVC)
list(REMOVE_ITEM SRC_FILES "${gklib_SOURCE_DIR}/gkregex.c")
endif()

add_library(GKlib STATIC ${INC_FILES} ${SRC_FILES})
add_library(GKlib::GKlib ALIAS GKlib)

if(MSVC)
target_compile_definitions(GKlib PUBLIC USE_GKREGEX)
target_compile_definitions(GKlib PUBLIC "__thread=__declspec(thread)")
endif()

include(GNUInstallDirs)
target_include_directories(GKlib SYSTEM PUBLIC
"$<BUILD_INTERFACE:${gklib_SOURCE_DIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)

# Until [1] is merged, workaround this by making a copying the missing header so it can be found
# during compilation.
# [1]: https://github.com/KarypisLab/GKlib/pull/19
file(MAKE_DIRECTORY "${gklib_BINARY_DIR}/include/gklib")
configure_file("${gklib_SOURCE_DIR}/gk_ms_stdint.h" "${gklib_BINARY_DIR}/include/gklib/ms_stdint.h" COPYONLY)
target_include_directories(GKlib SYSTEM PUBLIC "$<BUILD_INTERFACE:${gklib_BINARY_DIR}/include/gklib>")

set_target_properties(GKlib PROPERTIES FOLDER third_party)

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
target_compile_options(GKlib PRIVATE
"-Wno-unused-variable"
"-Wno-sometimes-uninitialized"
"-Wno-absolute-value"
"-Wno-shadow"
)
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
target_compile_options(GKlib PRIVATE
"-w" # Disallow all warnings from gklib.
)
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
target_compile_options(GKlib PRIVATE
"/w" # Disable all warnings from gklib!
)
endif()

# Install rules
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME gklib)
install(DIRECTORY ${gklib_SOURCE_DIR}/include DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS GKlib EXPORT GKlib_Targets)
install(EXPORT GKlib_Targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/gklib NAMESPACE gklib::)
2 changes: 1 addition & 1 deletion cmake/recipes/external/gl3w.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2020 Adobe. All rights reserved.
# Copyright 2019 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
Expand Down
Loading

0 comments on commit 9fb82d7

Please sign in to comment.