Browse Source

CMake refactor (#1805)

* Start CMake refactoring.

* WIP on instlal().

* Handle install + hunter setup.

* Handle module options + igl_include helper.

* Build all tutorials again.

* Update CMake for unit tests.

* Update triangle lib.

* Update Hunter integration.

* Fix for header-only mode.

* Fix Windows compilation + add GMP/MPFR find_package + set VS folders.

* Fix CGAL build.

* Add copy dll for Windows + improve find gmp/mpfr.

* Update Github Actions.

* Update README.

* Fixes for CMake 3.18

* Fix include option.

* Rename libigl_imgui_front to avoid conflicts.

* Fix when disabling unit tests.

* Build imguizmo with C++11.

* Update CMake option comments.

* Rename nonfree -> restricted.

* Update triangle and tetgen versions.

* Fix compilation issue.

* Update continuous.yml

* remove cork

* finding matlab with default

* mosek module compiles; default detected; osx dylib hack

* Reduce build parallelism.

* Fix find GMP/MPFR on Windows + cleanup CGAL changes.

* Update readme.

Co-authored-by: Alec Jacobson <[email protected]>
Co-authored-by: Alec Jacobson <[email protected]>
Jérémie Dumas 3 years ago
parent
commit
b0fd49d598
100 changed files with 2062 additions and 3490 deletions
  1. 6 16
      .github/workflows/continuous.yml
  2. 39 98
      .gitignore
  3. 154 51
      CMakeLists.txt
  4. 78 0
      LibiglOptions.cmake.sample
  5. 4 2
      README.md
  6. 0 85
      cmake/CXXFeatures.cmake
  7. 0 17
      cmake/DownloadProject.CMakeLists.cmake.in
  8. 0 182
      cmake/DownloadProject.cmake
  9. 0 52
      cmake/FindCORK.cmake
  10. 0 1547
      cmake/FindMATLAB.cmake
  11. 0 198
      cmake/LibiglDownloadExternal.cmake
  12. 0 118
      cmake/LibiglFolders.cmake
  13. 0 26
      cmake/LibiglWindows.cmake
  14. 95 0
      cmake/find/FindGMP.cmake
  15. 0 0
      cmake/find/FindMOSEK.cmake
  16. 95 0
      cmake/find/FindMPFR.cmake
  17. 75 0
      cmake/igl/igl_add_library.cmake
  18. 51 0
      cmake/igl/igl_add_test.cmake
  19. 18 0
      cmake/igl/igl_add_tutorial.cmake
  20. 97 0
      cmake/igl/igl_copy_dll.cmake
  21. 45 0
      cmake/igl/igl_include.cmake
  22. 63 0
      cmake/igl/igl_install.cmake
  23. 8 0
      cmake/igl/igl_target_sources.cmake
  24. 7 0
      cmake/igl/igl_windows.cmake
  25. 3 0
      cmake/igl/libigl-config.cmake.in
  26. 34 0
      cmake/igl/modules/copyleft/cgal.cmake
  27. 27 0
      cmake/igl/modules/copyleft/comiso.cmake
  28. 19 0
      cmake/igl/modules/copyleft/core.cmake
  29. 27 0
      cmake/igl/modules/copyleft/tetgen.cmake
  30. 32 0
      cmake/igl/modules/core.cmake
  31. 25 0
      cmake/igl/modules/embree.cmake
  32. 23 0
      cmake/igl/modules/glfw.cmake
  33. 27 0
      cmake/igl/modules/imgui.cmake
  34. 24 0
      cmake/igl/modules/opengl.cmake
  35. 23 0
      cmake/igl/modules/png.cmake
  36. 25 0
      cmake/igl/modules/predicates.cmake
  37. 25 0
      cmake/igl/modules/restricted/matlab.cmake
  38. 27 0
      cmake/igl/modules/restricted/mosek.cmake
  39. 29 0
      cmake/igl/modules/restricted/triangle.cmake
  40. 21 0
      cmake/igl/modules/xml.cmake
  41. 0 8
      cmake/libigl-cgal.yml
  42. 0 31
      cmake/libigl-config.cmake.in
  43. 35 571
      cmake/libigl.cmake
  44. 24 27
      cmake/misc/HunterGate.cmake
  45. 0 0
      cmake/misc/OSXFixDylibReferences.cmake
  46. 64 0
      cmake/recipes/external/boost.cmake
  47. 14 0
      cmake/recipes/external/catch2.cmake
  48. 58 0
      cmake/recipes/external/cgal.cmake
  49. 31 0
      cmake/recipes/external/comiso.cmake
  50. 43 0
      cmake/recipes/external/eigen.cmake
  51. 54 0
      cmake/recipes/external/embree.cmake
  52. 17 0
      cmake/recipes/external/glad.cmake
  53. 42 0
      cmake/recipes/external/glfw.cmake
  54. 15 0
      cmake/recipes/external/gmp.cmake
  55. 34 0
      cmake/recipes/external/gmp_mpfr.cmake
  56. 67 0
      cmake/recipes/external/imgui.cmake
  57. 40 0
      cmake/recipes/external/imguizmo.cmake
  58. 25 0
      cmake/recipes/external/libigl_imgui_fonts.cmake
  59. 18 0
      cmake/recipes/external/libigl_tests_data.cmake
  60. 18 0
      cmake/recipes/external/libigl_tutorial_data.cmake
  61. 15 0
      cmake/recipes/external/mpfr.cmake
  62. 17 0
      cmake/recipes/external/predicates.cmake
  63. 32 0
      cmake/recipes/external/stb.cmake
  64. 19 0
      cmake/recipes/external/tetgen.cmake
  65. 24 0
      cmake/recipes/external/tinyxml2.cmake
  66. 19 0
      cmake/recipes/external/triangle.cmake
  67. 5 0
      cmake/recipes/hunter/boost.cmake
  68. 1 0
      cmake/recipes/hunter/catch2.cmake
  69. 5 0
      cmake/recipes/hunter/cgal.cmake
  70. 5 0
      cmake/recipes/hunter/comiso.cmake
  71. 2 0
      cmake/recipes/hunter/eigen.cmake
  72. 5 0
      cmake/recipes/hunter/embree.cmake
  73. 5 0
      cmake/recipes/hunter/glad.cmake
  74. 5 0
      cmake/recipes/hunter/glfw.cmake
  75. 5 0
      cmake/recipes/hunter/gmp.cmake
  76. 5 0
      cmake/recipes/hunter/imgui.cmake
  77. 5 0
      cmake/recipes/hunter/imguizmo.cmake
  78. 5 0
      cmake/recipes/hunter/libigl_imgui_fonts.cmake
  79. 1 0
      cmake/recipes/hunter/libigl_tests_data.cmake
  80. 1 0
      cmake/recipes/hunter/libigl_tutorial_data.cmake
  81. 5 0
      cmake/recipes/hunter/mpfr.cmake
  82. 5 0
      cmake/recipes/hunter/predicates.cmake
  83. 5 0
      cmake/recipes/hunter/stb.cmake
  84. 5 0
      cmake/recipes/hunter/tetgen.cmake
  85. 5 0
      cmake/recipes/hunter/tinyxml2.cmake
  86. 5 0
      cmake/recipes/hunter/triangle.cmake
  87. 11 11
      include/igl/copyleft/cgal/assign.cpp
  88. 0 41
      include/igl/copyleft/cork/from_cork_mesh.cpp
  89. 0 39
      include/igl/copyleft/cork/from_cork_mesh.h
  90. 0 99
      include/igl/copyleft/cork/mesh_boolean.cpp
  91. 0 55
      include/igl/copyleft/cork/mesh_boolean.h
  92. 0 43
      include/igl/copyleft/cork/to_cork_mesh.cpp
  93. 0 39
      include/igl/copyleft/cork/to_cork_mesh.h
  94. 2 2
      include/igl/opengl/glfw/imgui/ImGuiMenu.cpp
  95. 2 2
      include/igl/png/readPNG.cpp
  96. 2 2
      include/igl/png/render_to_png.cpp
  97. 2 2
      include/igl/png/render_to_png_async.cpp
  98. 5 5
      include/igl/png/texture_from_png.cpp
  99. 2 2
      include/igl/png/writePNG.cpp
  100. 0 119
      tests/CMakeLists.txt

+ 6 - 16
.github/workflows/continuous.yml

@@ -47,9 +47,6 @@ jobs:
             sudo apt-get update
             sudo apt-get install \
               libblas-dev \
-              libboost-filesystem-dev \
-              libboost-system-dev \
-              libboost-thread-dev \
               libglu1-mesa-dev \
               liblapack-dev \
               libmpfr-dev \
@@ -60,7 +57,7 @@ jobs:
         if: runner.os == 'macOS'
         run: |
           brew update
-          brew install boost gmp mpfr ccache
+          brew install gmp mpfr ccache
 
       - name: Cache Build
         id: cache-build
@@ -82,8 +79,8 @@ jobs:
             -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
             -DCMAKE_BUILD_TYPE=${{ matrix.config }} \
             -DLIBIGL_USE_STATIC_LIBRARY=${{ matrix.static }} \
-            -DLIBIGL_WITH_CGAL=ON \
-            -DLIBIGL_WITH_COMISO=ON
+            -DLIBIGL_COPYLEFT_WITH_CGAL=ON \
+            -DLIBIGL_COPYLEFT_WITH_CORK=ON
 
       - name: Build
         run: cd build; make -j2; ccache --show-stats
@@ -113,13 +110,6 @@ jobs:
           fetch-depth: 10
       - uses: seanmiddleditch/gha-setup-ninja@master
 
-      - name: Setup Conda
-        uses: conda-incubator/setup-miniconda@v2
-        with:
-          activate-environment: libigl-cgal
-          environment-file: cmake/libigl-cgal.yml
-          auto-activate-base: false
-
       - name: Set env
         run: |
           echo "appdata=$env:LOCALAPPDATA" >> ${env:GITHUB_ENV}
@@ -148,9 +138,9 @@ jobs:
             -DCMAKE_CXX_COMPILER_LAUNCHER=sccache ^
             -DCMAKE_BUILD_TYPE=${{ matrix.config }} ^
             -DLIBIGL_USE_STATIC_LIBRARY=${{ matrix.static }} ^
-            -DLIBIGL_WITH_CGAL=ON ^
-            -DLIBIGL_WITH_COMISO=OFF ^
-            -DCMAKE_JOB_POOLS=pool-linking=1;pool-compilation=2 ^
+            -DLIBIGL_COPYLEFT_WITH_CGAL=ON ^
+            -DLIBIGL_COPYLEFT_WITH_CORK=ON ^
+            -DCMAKE_JOB_POOLS=pool-linking=1;pool-compilation=1 ^
             -DCMAKE_JOB_POOL_COMPILE:STRING=pool-compilation ^
             -DCMAKE_JOB_POOL_LINK:STRING=pool-linking ^
             -B build ^

+ 39 - 98
.gitignore

@@ -1,100 +1,41 @@
-# use glob syntax.
-*.a
-*.dylib
-*.egg-info/
-*.exe
-*.ilk
-*.log
+# Prerequisites
+*.d
+
+# Compiled Object files
+*.slo
+*.lo
 *.o
-*.opensdf
-*.orig
-*.pdb
-*.psess
-*.pyc
-*.sdf
+*.obj
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Compiled Dynamic libraries
 *.so
-*.so.[0123456789]
-*.so.[0123456789].[0123456789]
-*.suo
-*.swo
-*.swp
-*.tlog
-*.user
-*.vsp
-*CMakeFiles*
-*buildXcode*
-*tags
-*~
-.DS_Store
-.idea/
-.vs/
-.vscode/
-/external
-Debug/
-README.html
-Release/
-Untitled.ipynb
-build
-doc.html
-documentation/*.aux
-documentation/*.log
-documentation/*.out
-example
-example1
-example_header_only
-example_static
-examples/*/*.mexmaci64
-examples/*/*.rbr
-examples/bbw/bbw_demo
-examples/bbw/bbw_demo_selfcontained.zip
-examples/bbw/bbw_demo_selfcontained/*
-examples/bbw/examples/*-volume.dmat
-examples/bbw/examples/*-volume.mesh
-examples/principal_curvature/curvature
-examples/quicklook-mesh/Mesh.qlgenerator/*
-examples/upright/upright
-external/MeshFix/meshfix
-external/embree/build/*
-external/glew/build
-external/glfw/build
-external/libpng/build
-external/medit/rebar.rbr
-external/tetgen/tetgen
-external/tinyxml2/build
-external/tinyxml2/test
-external/tinyxml2/tinyxml2.pc
-external/yimg/showpng
-iglhelpers.pyc
-lib
-libigl.zip
-optional/build
-python/.idea
-python/.ipynb_checkpoints
-python/__pycache__
-python/build
-python/build2
-python/build3
-python/build4
-python/builddebug
-python/buildstatic
-python/py_igl/todo
-python/py_igl/todo
-python/scripts/generated
-scripts/change_name.sh
-site/
-syntax: glob
-tests/bin
-tests/build
-tests/data
-tutorial/*/*.mexmaci64
-tutorial/*/Makefile
-tutorial/*/build/*
-tutorial/.idea
-tutorial/XXX_test/CMakeLists.txt
-tutorial/XXX_test/main.cpp
-tutorial/build
-tutorial/cmake-build-debug
-tutorial/data
-tutorial/readme.html
-untitled
-scripts
+*.dylib
+*.dll
+
+# Fortran module files
+*.mod
+*.smod
+
+# Compiled Static libraries
+*.lai
+*.la
+*.a
+*.lib
+
+# Executables
+*.exe
+*.out
+*.app
+
+# Build folders
+/build*
+/tests/data
+/tutorial/data
+/install
+
+# Libigl specific
+LibiglOptions.cmake

+ 154 - 51
CMakeLists.txt

@@ -1,74 +1,177 @@
-cmake_minimum_required(VERSION 3.1)
+# Detects whether this is a top-level project
+get_directory_property(LIBIGL_PARENT_DIR PARENT_DIRECTORY)
+if(NOT LIBIGL_PARENT_DIR)
+    set(LIBIGL_TOPLEVEL_PROJECT ON)
+else()
+    set(LIBIGL_TOPLEVEL_PROJECT OFF)
+endif()
+
+# Check required CMake version
+set(REQUIRED_CMAKE_VERSION "3.16.0")
+if(LIBIGL_TOPLEVEL_PROJECT)
+    cmake_minimum_required(VERSION ${REQUIRED_CMAKE_VERSION})
+else()
+    # Don't use cmake_minimum_required here to avoid implicitly overriding parent policies
+    if(${CMAKE_VERSION} VERSION_LESS ${REQUIRED_CMAKE_VERSION})
+        message(FATAL_ERROR "CMake required version to build Libigl is ${REQUIRED_CMAKE_VERSION}")
+    endif()
+endif()
 
-# Toggles the use of the hunter package manager
+# Include user-provided default options if available. We do that before the main
+# `project()` so that we can define the C/C++ compilers from the option file.
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/LibiglOptions.cmake)
+    message(STATUS "Using local options file: ${CMAKE_CURRENT_SOURCE_DIR}/LibiglOptions.cmake")
+    include(${CMAKE_CURRENT_SOURCE_DIR}/LibiglOptions.cmake)
+endif()
+
+# If this option is enabled, this will setup the Hunter package manager.
 option(HUNTER_ENABLED "Enable Hunter package manager support" OFF)
+if(HUNTER_ENABLED)
+    include("cmake/misc/HunterGate.cmake")
+    HunterGate(
+        URL "https://github.com/cpp-pm/hunter/archive/v0.23.300.tar.gz"
+        SHA1 "1151d539465d9cdbc880ee30f794864aec11c448"
+    )
+endif()
 
-include("cmake/HunterGate.cmake")
-HunterGate(
-	URL "https://github.com/ruslo/hunter/archive/v0.23.171.tar.gz"
-	SHA1 "5d68bcca78eee347239ca5f4d34f4b6c12683154"
-)
+################################################################################
+project(libigl VERSION 2.4.0)
 
-project(libigl)
+# CMake module path
+list(PREPEND CMAKE_MODULE_PATH
+    ${CMAKE_CURRENT_LIST_DIR}/cmake/
+    ${CMAKE_CURRENT_LIST_DIR}/cmake/igl
+    ${CMAKE_CURRENT_LIST_DIR}/cmake/find
+    ${CMAKE_CURRENT_LIST_DIR}/cmake/recipes/external
+)
 
-# Detects whether this is a top-level project
-get_directory_property(LIBIGL_PARENT_DIR PARENT_DIRECTORY)
-if(NOT LIBIGL_PARENT_DIR)
-	set(LIBIGL_TOPLEVEL_PROJECT ON)
+if(HUNTER_ENABLED)
+    list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake/recipes/hunter)
 else()
-	set(LIBIGL_TOPLEVEL_PROJECT OFF)
+    list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake/recipes/external)
+endif()
+
+# Check for gmp + mpfr and enable cork / cgal modules accordingly
+set(LIBIGL_DEFAULT_CGAL ${LIBIGL_TOPLEVEL_PROJECT})
+set(MATLAB_ADDITIONAL_VERSIONS
+    "R2022b=10.3"
+    "R2022a=10.2"
+    "R2021b=10.1"
+    "R2021a=10.0"
+)
+set(LIBIGL_DEFAULT_MATLAB ${LIBIGL_TOPLEVEL_PROJECT})
+set(LIBIGL_DEFAULT_MOSEK ${LIBIGL_TOPLEVEL_PROJECT})
+if(LIBIGL_TOPLEVEL_PROJECT)
+    if(NOT WIN32)
+        find_package(GMP QUIET)
+        find_package(MPFR QUIET)
+        if(NOT (TARGET gmp::gmp AND TARGET mpfr::mpfr))
+            set(LIBIGL_DEFAULT_CGAL OFF)
+            message(WARNING "Missing dependencies GMP and MPFR. The libigl modules for cork and cgal "
+                            "will be disabled by default.")
+        endif()
+    endif()
+    find_package(Matlab QUIET)
+    if(NOT Matlab_FOUND)
+        set(LIBIGL_DEFAULT_MATLAB OFF)
+        message(WARNING "Matlab not found, disabling igl_restricted::matlab module.")
+    endif()
+    find_package(MOSEK QUIET)
+    if(NOT MOSEK_FOUND)
+        set(LIBIGL_DEFAULT_MOSEK OFF)
+        message(WARNING "Mosek not found, disabling igl_restricted::mosek module.")
+    endif()
 endif()
 
 # Build tests and tutorials
-option(LIBIGL_BUILD_TESTS      "Build libigl unit test"        ${LIBIGL_TOPLEVEL_PROJECT})
-option(LIBIGL_BUILD_TUTORIALS  "Build libigl tutorial"         ${LIBIGL_TOPLEVEL_PROJECT})
-option(LIBIGL_EXPORT_TARGETS   "Export libigl CMake targets"   ${LIBIGL_TOPLEVEL_PROJECT})
+option(LIBIGL_BUILD_TESTS      "Build libigl unit test"                ${LIBIGL_TOPLEVEL_PROJECT})
+option(LIBIGL_BUILD_TUTORIALS  "Build libigl tutorial"                 ${LIBIGL_TOPLEVEL_PROJECT})
+option(LIBIGL_INSTALL          "Enable installation of libigl targets" ${LIBIGL_TOPLEVEL_PROJECT})
 
 # USE_STATIC_LIBRARY speeds up the generation of multiple binaries,
 # at the cost of a longer initial compilation time
 # (by default, static build is off since libigl is a header-only library)
-option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library" ON)
-
-# All dependencies that are downloaded as cmake projects and tested on the auto-builds are ON
-# (by default, all build options are off)
-option(LIBIGL_WITH_COMISO            "Use CoMiso"                   ON)
-option(LIBIGL_WITH_EMBREE            "Use Embree"                   ON)
-option(LIBIGL_WITH_OPENGL            "Use OpenGL"                   ON)
-option(LIBIGL_WITH_OPENGL_GLFW       "Use GLFW"                     ON)
-option(LIBIGL_WITH_OPENGL_GLFW_IMGUI "Use ImGui"                    ON)
-option(LIBIGL_WITH_PNG               "Use PNG"                      ON)
-option(LIBIGL_WITH_TETGEN            "Use Tetgen"                   ON)
-option(LIBIGL_WITH_TRIANGLE          "Use Triangle"                 ON)
-option(LIBIGL_WITH_PREDICATES        "Use exact predicates"         ON)
-option(LIBIGL_WITH_XML               "Use XML"                      ON)
-option(LIBIGL_WITH_PYTHON            "Use Python"                   OFF)
-### End
-
-if(${LIBIGL_WITH_PYTHON})
-	message(FATAL_ERROR "Python binding are in the process of being redone. Please use the master branch or refer to https://github.com/geometryprocessing/libigl-python-bindings for the developement version or https://anaconda.org/conda-forge/igl for the stable version.")
-endif()
+option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library" ${LIBIGL_TOPLEVEL_PROJECT})
+
+# Permissive modules. These modules are available under MPL2 license, and their dependencies are available
+# under a permissive or public domain license.
+option(LIBIGL_WITH_EMBREE           "Build target igl::embree"           ${LIBIGL_TOPLEVEL_PROJECT})
+option(LIBIGL_WITH_GLFW             "Build target igl::glfw"             ${LIBIGL_TOPLEVEL_PROJECT})
+option(LIBIGL_WITH_IMGUI            "Build target igl::imgui"            ${LIBIGL_TOPLEVEL_PROJECT})
+option(LIBIGL_WITH_OPENGL           "Build target igl::opengl"           ${LIBIGL_TOPLEVEL_PROJECT})
+option(LIBIGL_WITH_PNG              "Build target igl::png"              ${LIBIGL_TOPLEVEL_PROJECT})
+option(LIBIGL_WITH_PREDICATES       "Build target igl::predicates"       ${LIBIGL_TOPLEVEL_PROJECT})
+option(LIBIGL_WITH_XML              "Build target igl::xml"              ${LIBIGL_TOPLEVEL_PROJECT})
+
+# Copyleft modules. These modules are available under GPL license, and their dependencies are
+# available under a copyleft license.
+option(LIBIGL_COPYLEFT_WITH_CORE    "Build target igl_copyleft::core"    ${LIBIGL_TOPLEVEL_PROJECT})
+option(LIBIGL_COPYLEFT_WITH_CGAL    "Build target igl_copyleft::cgal"    ${LIBIGL_DEFAULT_CGAL})
+option(LIBIGL_COPYLEFT_WITH_COMISO  "Build target igl_copyleft::comiso"  ${LIBIGL_TOPLEVEL_PROJECT})
+option(LIBIGL_COPYLEFT_WITH_TETGEN  "Build target igl_copyleft::tetgen"  ${LIBIGL_TOPLEVEL_PROJECT})
+
+# Restricted modules. These modules are available under MPL2 license, but their dependencies are
+# only available under a non-commercial or proprietary license.
+option(LIBIGL_RESTRICTED_WITH_MATLAB   "Build target igl_restricted::matlab"   ${LIBIGL_DEFAULT_MATLAB})
+option(LIBIGL_RESTRICTED_WITH_MOSEK    "Build target igl_restricted::mosek"    ${LIBIGL_DEFAULT_MOSEK})
+option(LIBIGL_RESTRICTED_WITH_TRIANGLE "Build target igl_restricted::triangle" ${LIBIGL_TOPLEVEL_PROJECT})
+
+
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
 
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
-set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
 
-### conditionally compile certain modules depending on libraries found on the system
-list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
+# Include CMake helper functions
+include(igl_add_library)
+include(igl_add_test)
+include(igl_add_tutorial)
+include(igl_copy_dll)
+include(igl_include)
+include(igl_install)
+include(igl_target_sources)
 
-### Adding libIGL: choose the path to your local copy libIGL
+# Enable unit testing at the root level
+if(LIBIGL_BUILD_TESTS)
+    include(CTest)
+endif()
+
+# Defines CMake targets for selected libigl modules
 include(libigl)
 
 if(LIBIGL_BUILD_TUTORIALS)
-	add_subdirectory(tutorial)
+    add_subdirectory(tutorial)
 endif()
 
-if(LIBIGL_BUILD_TESTS)
-	include(CTest)
-	enable_testing()
-	add_subdirectory(tests)
-endif()
+################################################################################
+# Install CMake config files
+################################################################################
 
-if(LIBIGL_TOPLEVEL_PROJECT)
-	# Set folders for Visual Studio/Xcode
-	igl_set_folders()
+if(LIBIGL_INSTALL)
+    include(GNUInstallDirs)
+    set(project_config_in "${PROJECT_SOURCE_DIR}/cmake/igl/libigl-config.cmake.in")
+    set(project_config_out "${CMAKE_CURRENT_BINARY_DIR}/libigl-config.cmake")
+    set(config_targets_base "LibiglConfigTargets")
+    set(version_config_file "${CMAKE_CURRENT_BINARY_DIR}/LibiglConfigVersion.cmake")
+    set(export_dest_dir "${CMAKE_INSTALL_LIBDIR}/cmake/igl")
+
+    foreach(suffix IN ITEMS "") #"_restricted" "_copyleft")
+        install(EXPORT LibiglTargets${suffix}
+            DESTINATION ${export_dest_dir}
+            NAMESPACE igl${suffix}::
+            FILE ${config_targets_base}${suffix}.cmake
+            COMPONENT LibiglDevelopment
+        )
+    endforeach()
+
+    include(CMakePackageConfigHelpers)
+    configure_package_config_file(
+            "${project_config_in}"
+            "${project_config_out}"
+        INSTALL_DESTINATION
+            ${CMAKE_INSTALL_DATAROOTDIR}/libigl/cmake
+    )
+
+    write_basic_package_version_file("${version_config_file}" COMPATIBILITY SameMajorVersion)
+    install(FILES "${project_config_out}" "${version_config_file}" DESTINATION "${export_dest_dir}")
 endif()

+ 78 - 0
LibiglOptions.cmake.sample

@@ -0,0 +1,78 @@
+# If you are cloning and compiling the libigl repository as a standalone, you
+# can use this file as a convenience to set default CMake options. Simply copy
+# this file and remove the '.sample' suffix. Then, uncomment the relevant
+# options as desired. Note that this file is included before `project(Libigl)`
+# is defined, so we can use it to define the C and C++ compilers, but some
+# variables such as PROJECT_SOURCE_DIR will not be defined yet. You can use
+# CMAKE_SOURCE_DIR instead.
+#
+# If you are using libigl as a subproject (e.g. see the libigl-example-project
+# template), then you do NOT need to use this file. Simply set your preferred
+# CMake options in the parent project, # before including libigl.
+
+################################################################################
+# CMake Options
+################################################################################
+
+# Specify a custom install prefix path
+# set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install CACHE STRING "Install directory used by install().")
+
+# Generates a `compile_commands.json` that can be used for autocompletion
+# set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable/Disable output of compile commands during generation.")
+
+# Use ccache to speed up compilation of repeated builds
+# find_program(CCACHE_PROGRAM ccache)
+# if(CCACHE_PROGRAM)
+#     message(STATUS "Enabling Ccache support")
+#     set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE STRING "")
+#     set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE STRING "")
+# endif()
+
+# Use a specific C/C++ compiler, e.g. llvm-clang on macOS (so we can use clangd)
+# set(CMAKE_C_COMPILER   "/usr/bin/clang" CACHE STRING "C compiler")
+# set(CMAKE_CXX_COMPILER "/usr/bin/clang++" CACHE STRING "C++ compiler")
+
+# Set deployment platform for macOS
+# set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "macOS deployment target")
+
+# Always add colored output (e.g. when using Ninja)
+# add_compile_options(-fdiagnostics-color=always) # GCC
+# add_compile_options(-fcolor-diagnostics) # Clang
+
+# add_compile_options(-ftime-trace) # Clang
+
+################################################################################
+# Libigl Options
+################################################################################
+
+# Build options
+# option(LIBIGL_BUILD_TESTS        "Build libigl unit test"                OFF)
+# option(LIBIGL_BUILD_TUTORIALS    "Build libigl tutorial"                 OFF)
+# option(LIBIGL_INSTALL            "Enable installation of libigl targets" OFF)
+# option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library"          OFF)
+
+# Module options
+# option(LIBIGL_WITH_EMBREE              "Build target igl::embree"              ON)
+# option(LIBIGL_WITH_GLFW                "Build target igl::glfw"                ON)
+# option(LIBIGL_WITH_IMGUI               "Build target igl::imgui"               ON)
+# option(LIBIGL_WITH_OPENGL              "Build target igl::opengl"              ON)
+# option(LIBIGL_WITH_PNG                 "Build target igl::png"                 ON)
+# option(LIBIGL_WITH_PREDICATES          "Build target igl::predicates"          ON)
+# option(LIBIGL_WITH_XML                 "Build target igl::xml"                 ON)
+# option(LIBIGL_COPYLEFT_WITH_CGAL       "Build target igl_copyleft::cgal"       ON)
+# option(LIBIGL_COPYLEFT_WITH_COMISO     "Build target igl_copyleft::comiso"     ON)
+# option(LIBIGL_COPYLEFT_WITH_CORE       "Build target igl_copyleft::core"       ON)
+# option(LIBIGL_COPYLEFT_WITH_CORK       "Build target igl_copyleft::cork"       ON)
+# option(LIBIGL_COPYLEFT_WITH_TETGEN     "Build target igl_copyleft::tetgen"     ON)
+# option(LIBIGL_RESTRICTED_WITH_MATLAB   "Build target igl_restricted::matlab"   ON)
+# option(LIBIGL_RESTRICTED_WITH_MOSEK    "Build target igl_restricted::mosek"    ON)
+# option(LIBIGL_RESTRICTED_WITH_TRIANGLE "Build target igl_restricted::triangle" ON)
+
+################################################################################
+# FetchContent Options
+################################################################################
+
+# option(FETCHCONTENT_FULLY_DISCONNECTED   "Disables all attempts to download or update content and assumes source dirs already exist" ON)
+# option(FETCHCONTENT_UPDATES_DISCONNECTED "Enables UPDATE_DISCONNECTED behavior for all content population" ON)
+# option(FETCHCONTENT_QUIET                "Enables QUIET option for all content population" ON)
+# set(FETCHCONTENT_BASE_DIR "${CMAKE_SOURCE_DIR}/external" CACHE PATH "Directory under which to collect all populated content")

+ 4 - 2
README.md

@@ -1,6 +1,6 @@
 # libigl - A simple C++ geometry processing library
+
 [![](https://github.com/libigl/libigl/workflows/Build/badge.svg?event=push)](https://github.com/libigl/libigl/actions?query=workflow%3ABuild+branch%3Amain+event%3Apush)
-[![](https://github.com/libigl/libigl/workflows/Nightly/badge.svg)](https://github.com/libigl/libigl/actions?query=workflow%3ANightly+branch%3Amain+event%3Aschedule)
 [![](https://anaconda.org/conda-forge/igl/badges/installer/conda.svg)](https://anaconda.org/conda-forge/igl)
 
 ![](https://libigl.github.io/libigl-teaser.png)
@@ -8,4 +8,6 @@
 Documentation, tutorial, and instructions at <https://libigl.github.io>.
 
 
-💡 **Note**: [v2.3.0](https://github.com/libigl/libigl/releases/tag/v2.3.0) is our last stable release before some planned major reorganization (see #1696 for details). The upcoming reorganization is aimed at facilitating maintenance and packaging of various libigl components. The next release will be a new major version of libigl (3.0.0). Be mindful if you are updating to the latest commit on the `main` branch of libigl.
+| 🚨 Important |
+|:---|
+| The latest version of libigl (v2.4.0) introduces some **breaking changes** to its CMake build system. Please read our [changelog](https://libigl.github.io/changelog/) page for instructions on how to update your project accordingly. |

+ 0 - 85
cmake/CXXFeatures.cmake

@@ -1,85 +0,0 @@
-################################################################################
-
-if(NOT (${CMAKE_VERSION} VERSION_LESS "3.8.0"))
-  # For CMake 3.8 and above, we can use meta features directly provided by CMake itself
-  set(CXX11_FEATURES cxx_std_11)
-  set(CXX14_FEATURES cxx_std_14)
-  set(CXX17_FEATURES cxx_std_17)
-  return()
-endif()
-
-################################################################################
-
-set(CXX11_FEATURES
-  cxx_auto_type
-  cxx_constexpr
-)
-
-set(CXX14_FEATURES
-  cxx_generic_lambdas
-)
-
-set(CXX17_FEATURES
-
-)
-
-################################################################################
-
-# https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
-# cxx_aggregate_default_initializers    Aggregate default initializers, as defined in N3605.
-# cxx_alias_templates                   Template aliases, as defined in N2258.
-# cxx_alignas                           Alignment control alignas, as defined in N2341.
-# cxx_alignof                           Alignment control alignof, as defined in N2341.
-# cxx_attributes                        Generic attributes, as defined in N2761.
-# cxx_attribute_deprecated              deprecated]] attribute, as defined in N3760.
-# cxx_auto_type                         Automatic type deduction, as defined in N1984.
-# cxx_binary_literals                   Binary literals, as defined in N3472.
-# cxx_constexpr                         Constant expressions, as defined in N2235.
-# cxx_contextual_conversions            Contextual conversions, as defined in N3323.
-# cxx_decltype_incomplete_return_types  Decltype on incomplete return types, as defined in N3276.
-# cxx_decltype                          Decltype, as defined in N2343.
-# cxx_decltype_auto                     decltype(auto) semantics, as defined in N3638.
-# cxx_default_function_template_args    Default template arguments for function templates, as defined in DR226
-# cxx_defaulted_functions               Defaulted functions, as defined in N2346.
-# cxx_defaulted_move_initializers       Defaulted move initializers, as defined in N3053.
-# cxx_delegating_constructors           Delegating constructors, as defined in N1986.
-# cxx_deleted_functions                 Deleted functions, as defined in N2346.
-# cxx_digit_separators                  Digit separators, as defined in N3781.
-# cxx_enum_forward_declarations         Enum forward declarations, as defined in N2764.
-# cxx_explicit_conversions              Explicit conversion operators, as defined in N2437.
-# cxx_extended_friend_declarations      Extended friend declarations, as defined in N1791.
-# cxx_extern_templates                  Extern templates, as defined in N1987.
-# cxx_final                             Override control final keyword, as defined in N2928, N3206 and N3272.
-# cxx_func_identifier                   Predefined __func__ identifier, as defined in N2340.
-# cxx_generalized_initializers          Initializer lists, as defined in N2672.
-# cxx_generic_lambdas                   Generic lambdas, as defined in N3649.
-# cxx_inheriting_constructors           Inheriting constructors, as defined in N2540.
-# cxx_inline_namespaces                 Inline namespaces, as defined in N2535.
-# cxx_lambdas                           Lambda functions, as defined in N2927.
-# cxx_lambda_init_captures              Initialized lambda captures, as defined in N3648.
-# cxx_local_type_template_args          Local and unnamed types as template arguments, as defined in N2657.
-# cxx_long_long_type                    long long type, as defined in N1811.
-# cxx_noexcept                          Exception specifications, as defined in N3050.
-# cxx_nonstatic_member_init             Non-static data member initialization, as defined in N2756.
-# cxx_nullptr                           Null pointer, as defined in N2431.
-# cxx_override                          Override control override keyword, as defined in N2928, N3206 and N3272.
-# cxx_range_for                         Range-based for, as defined in N2930.
-# cxx_raw_string_literals               Raw string literals, as defined in N2442.
-# cxx_reference_qualified_functions     Reference qualified functions, as defined in N2439.
-# cxx_relaxed_constexpr                 Relaxed constexpr, as defined in N3652.
-# cxx_return_type_deduction             Return type deduction on normal functions, as defined in N3386.
-# cxx_right_angle_brackets              Right angle bracket parsing, as defined in N1757.
-# cxx_rvalue_references                 R-value references, as defined in N2118.
-# cxx_sizeof_member                     Size of non-static data members, as defined in N2253.
-# cxx_static_assert                     Static assert, as defined in N1720.
-# cxx_strong_enums                      Strongly typed enums, as defined in N2347.
-# cxx_thread_local                      Thread-local variables, as defined in N2659.
-# cxx_trailing_return_types             Automatic function return type, as defined in N2541.
-# cxx_unicode_literals                  Unicode string literals, as defined in N2442.
-# cxx_uniform_initialization            Uniform initialization, as defined in N2640.
-# cxx_unrestricted_unions               Unrestricted unions, as defined in N2544.
-# cxx_user_literals                     User-defined literals, as defined in N2765.
-# cxx_variable_templates                Variable templates, as defined in N3651.
-# cxx_variadic_macros                   Variadic macros, as defined in N1653.
-# cxx_variadic_templates                Variadic templates, as defined in N2242.
-# cxx_template_template_parameters      Template template parameters, as defined in ISO/IEC 14882:1998.

+ 0 - 17
cmake/DownloadProject.CMakeLists.cmake.in

@@ -1,17 +0,0 @@
-# Distributed under the OSI-approved MIT License.  See accompanying
-# file LICENSE or https://github.com/Crascit/DownloadProject for details.
-
-cmake_minimum_required(VERSION 3.1)
-
-project(${DL_ARGS_PROJ}-download NONE)
-
-include(ExternalProject)
-ExternalProject_Add(${DL_ARGS_PROJ}-download
-                    ${DL_ARGS_UNPARSED_ARGUMENTS}
-                    SOURCE_DIR          "${DL_ARGS_SOURCE_DIR}"
-                    BINARY_DIR          "${DL_ARGS_BINARY_DIR}"
-                    CONFIGURE_COMMAND   ""
-                    BUILD_COMMAND       ""
-                    INSTALL_COMMAND     ""
-                    TEST_COMMAND        ""
-)

+ 0 - 182
cmake/DownloadProject.cmake

@@ -1,182 +0,0 @@
-# Distributed under the OSI-approved MIT License.  See accompanying
-# file LICENSE or https://github.com/Crascit/DownloadProject for details.
-#
-# MODULE:   DownloadProject
-#
-# PROVIDES:
-#   download_project( PROJ projectName
-#                    [PREFIX prefixDir]
-#                    [DOWNLOAD_DIR downloadDir]
-#                    [SOURCE_DIR srcDir]
-#                    [BINARY_DIR binDir]
-#                    [QUIET]
-#                    ...
-#   )
-#
-#       Provides the ability to download and unpack a tarball, zip file, git repository,
-#       etc. at configure time (i.e. when the cmake command is run). How the downloaded
-#       and unpacked contents are used is up to the caller, but the motivating case is
-#       to download source code which can then be included directly in the build with
-#       add_subdirectory() after the call to download_project(). Source and build
-#       directories are set up with this in mind.
-#
-#       The PROJ argument is required. The projectName value will be used to construct
-#       the following variables upon exit (obviously replace projectName with its actual
-#       value):
-#
-#           projectName_SOURCE_DIR
-#           projectName_BINARY_DIR
-#
-#       The SOURCE_DIR and BINARY_DIR arguments are optional and would not typically
-#       need to be provided. They can be specified if you want the downloaded source
-#       and build directories to be located in a specific place. The contents of
-#       projectName_SOURCE_DIR and projectName_BINARY_DIR will be populated with the
-#       locations used whether you provide SOURCE_DIR/BINARY_DIR or not.
-#
-#       The DOWNLOAD_DIR argument does not normally need to be set. It controls the
-#       location of the temporary CMake build used to perform the download.
-#
-#       The PREFIX argument can be provided to change the base location of the default
-#       values of DOWNLOAD_DIR, SOURCE_DIR and BINARY_DIR. If all of those three arguments
-#       are provided, then PREFIX will have no effect. The default value for PREFIX is
-#       CMAKE_BINARY_DIR.
-#
-#       The QUIET option can be given if you do not want to show the output associated
-#       with downloading the specified project.
-#
-#       In addition to the above, any other options are passed through unmodified to
-#       ExternalProject_Add() to perform the actual download, patch and update steps.
-#       The following ExternalProject_Add() options are explicitly prohibited (they
-#       are reserved for use by the download_project() command):
-#
-#           CONFIGURE_COMMAND
-#           BUILD_COMMAND
-#           INSTALL_COMMAND
-#           TEST_COMMAND
-#
-#       Only those ExternalProject_Add() arguments which relate to downloading, patching
-#       and updating of the project sources are intended to be used. Also note that at
-#       least one set of download-related arguments are required.
-#
-#       If using CMake 3.2 or later, the UPDATE_DISCONNECTED option can be used to
-#       prevent a check at the remote end for changes every time CMake is run
-#       after the first successful download. See the documentation of the ExternalProject
-#       module for more information. It is likely you will want to use this option if it
-#       is available to you. Note, however, that the ExternalProject implementation contains
-#       bugs which result in incorrect handling of the UPDATE_DISCONNECTED option when
-#       using the URL download method or when specifying a SOURCE_DIR with no download
-#       method. Fixes for these have been created, the last of which is scheduled for
-#       inclusion in CMake 3.8.0. Details can be found here:
-#
-#           https://gitlab.kitware.com/cmake/cmake/commit/bdca68388bd57f8302d3c1d83d691034b7ffa70c
-#           https://gitlab.kitware.com/cmake/cmake/issues/16428
-#
-#       If you experience build errors related to the update step, consider avoiding
-#       the use of UPDATE_DISCONNECTED.
-#
-# EXAMPLE USAGE:
-#
-#   include(DownloadProject)
-#   download_project(PROJ                googletest
-#                    GIT_REPOSITORY      https://github.com/google/googletest.git
-#                    GIT_TAG             master
-#                    UPDATE_DISCONNECTED 1
-#                    QUIET
-#   )
-#
-#   add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
-#
-#========================================================================================
-
-
-set(_DownloadProjectDir "${CMAKE_CURRENT_LIST_DIR}")
-
-include(CMakeParseArguments)
-
-function(download_project)
-
-    set(options QUIET)
-    set(oneValueArgs
-        PROJ
-        PREFIX
-        DOWNLOAD_DIR
-        SOURCE_DIR
-        BINARY_DIR
-        # Prevent the following from being passed through
-        CONFIGURE_COMMAND
-        BUILD_COMMAND
-        INSTALL_COMMAND
-        TEST_COMMAND
-    )
-    set(multiValueArgs "")
-
-    cmake_parse_arguments(DL_ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-
-    # Hide output if requested
-    if (DL_ARGS_QUIET)
-        set(OUTPUT_QUIET "OUTPUT_QUIET")
-    else()
-        unset(OUTPUT_QUIET)
-        message(STATUS "Downloading/updating ${DL_ARGS_PROJ}")
-    endif()
-
-    # Set up where we will put our temporary CMakeLists.txt file and also
-    # the base point below which the default source and binary dirs will be.
-    # The prefix must always be an absolute path.
-    if (NOT DL_ARGS_PREFIX)
-        set(DL_ARGS_PREFIX "${CMAKE_BINARY_DIR}")
-    else()
-        get_filename_component(DL_ARGS_PREFIX "${DL_ARGS_PREFIX}" ABSOLUTE
-                               BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
-    endif()
-    if (NOT DL_ARGS_DOWNLOAD_DIR)
-        set(DL_ARGS_DOWNLOAD_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-download")
-    endif()
-
-    # Ensure the caller can know where to find the source and build directories
-    if (NOT DL_ARGS_SOURCE_DIR)
-        set(DL_ARGS_SOURCE_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-src")
-    endif()
-    if (NOT DL_ARGS_BINARY_DIR)
-        set(DL_ARGS_BINARY_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-build")
-    endif()
-    set(${DL_ARGS_PROJ}_SOURCE_DIR "${DL_ARGS_SOURCE_DIR}" PARENT_SCOPE)
-    set(${DL_ARGS_PROJ}_BINARY_DIR "${DL_ARGS_BINARY_DIR}" PARENT_SCOPE)
-
-    # The way that CLion manages multiple configurations, it causes a copy of
-    # the CMakeCache.txt to be copied across due to it not expecting there to
-    # be a project within a project.  This causes the hard-coded paths in the
-    # cache to be copied and builds to fail.  To mitigate this, we simply
-    # remove the cache if it exists before we configure the new project.  It
-    # is safe to do so because it will be re-generated.  Since this is only
-    # executed at the configure step, it should not cause additional builds or
-    # downloads.
-    file(REMOVE "${DL_ARGS_DOWNLOAD_DIR}/CMakeCache.txt")
-
-    # Create and build a separate CMake project to carry out the download.
-    # If we've already previously done these steps, they will not cause
-    # anything to be updated, so extra rebuilds of the project won't occur.
-    # Make sure to pass through CMAKE_MAKE_PROGRAM in case the main project
-    # has this set to something not findable on the PATH.
-    configure_file("${_DownloadProjectDir}/DownloadProject.CMakeLists.cmake.in"
-                   "${DL_ARGS_DOWNLOAD_DIR}/CMakeLists.txt")
-    execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
-                        -D "CMAKE_MAKE_PROGRAM:FILE=${CMAKE_MAKE_PROGRAM}"
-                        .
-                    RESULT_VARIABLE result
-                    ${OUTPUT_QUIET}
-                    WORKING_DIRECTORY "${DL_ARGS_DOWNLOAD_DIR}"
-    )
-    if(result)
-        message(FATAL_ERROR "CMake step for ${DL_ARGS_PROJ} failed: ${result}")
-    endif()
-    execute_process(COMMAND ${CMAKE_COMMAND} --build .
-                    RESULT_VARIABLE result
-                    ${OUTPUT_QUIET}
-                    WORKING_DIRECTORY "${DL_ARGS_DOWNLOAD_DIR}"
-    )
-    if(result)
-        message(FATAL_ERROR "Build step for ${DL_ARGS_PROJ} failed: ${result}")
-    endif()
-
-endfunction()

+ 0 - 52
cmake/FindCORK.cmake

@@ -1,52 +0,0 @@
-#
-# Try to find CORK library and include path.
-# Once done this will define
-#
-# CORK_FOUND
-# CORK_INCLUDE_DIR
-# CORK_LIBRARIES
-#
-
-if(NOT CORK_FOUND)
-
-FIND_PATH(CORK_INCLUDE_DIR cork.h
-  PATHS
-    ${PROJECT_SOURCE_DIR}/../../external/cork/include
-    ${PROJECT_SOURCE_DIR}/../external/cork/include
-    ${PROJECT_SOURCE_DIR}/external/cork/include
-    /usr/local/include
-    /usr/X11/include
-    /usr/include
-    /opt/local/include
-    NO_DEFAULT_PATH
-    )
-
-FIND_LIBRARY( CORK_LIBRARIES NAMES cork
-  PATHS
-    ${PROJECT_SOURCE_DIR}/../../external/cork/lib/
-    ${PROJECT_SOURCE_DIR}/../external/cork/lib/
-    ${PROJECT_SOURCE_DIR}/external/cork/lib/
-    /usr/local
-    /usr/X11
-    /usr
-    PATH_SUFFIXES
-    a
-    lib64
-    lib
-    NO_DEFAULT_PATH
-)
-
-SET(CORK_FOUND "NO")
-IF (CORK_INCLUDE_DIR AND CORK_LIBRARIES)
-	SET(CORK_FOUND "YES")
-ENDIF (CORK_INCLUDE_DIR AND CORK_LIBRARIES)
-
-if(CORK_FOUND)
-  message(STATUS "Found CORK: ${CORK_INCLUDE_DIR}")
-else(CORK_FOUND)
-  if (NOT CORK_FIND_QUIETLY)
-    message(FATAL_ERROR "could NOT find CORK")
-  endif (NOT CORK_FIND_QUIETLY)
-endif(CORK_FOUND)
-
-endif(NOT CORK_FOUND)

+ 0 - 1547
cmake/FindMATLAB.cmake

@@ -1,1547 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-#.rst:
-# FindMatlab
-# ----------
-#
-# Finds Matlab installations and provides Matlab tools and libraries to cmake.
-#
-# This package first intention is to find the libraries associated with Matlab
-# in order to be able to build Matlab extensions (mex files). It can also be
-# used:
-#
-# * run specific commands in Matlab
-# * declare Matlab unit test
-# * retrieve various information from Matlab (mex extensions, versions and
-#   release queries, ...)
-#
-# The module supports the following components:
-#
-# * ``MX_LIBRARY``, ``ENG_LIBRARY`` and ``MAT_LIBRARY``: respectively the MX,
-#   ENG and MAT libraries of Matlab
-# * ``MAIN_PROGRAM`` the Matlab binary program.
-# * ``MEX_COMPILER`` the MEX compiler.
-# * ``SIMULINK`` the Simulink environment.
-#
-# .. note::
-#
-#   The version given to the :command:`find_package` directive is the Matlab
-#   **version**, which should not be confused with the Matlab *release* name
-#   (eg. `R2014`).
-#   The :command:`matlab_get_version_from_release_name` and
-#   :command:`matlab_get_release_name_from_version` allow a mapping
-#   from the release name to the version.
-#
-# The variable :variable:`Matlab_ROOT_DIR` may be specified in order to give
-# the path of the desired Matlab version. Otherwise, the behaviour is platform
-# specific:
-#
-# * Windows: The installed versions of Matlab are retrieved from the
-#   Windows registry
-# * OS X: The installed versions of Matlab are given by the MATLAB
-#   paths in ``/Application``. If no such application is found, it falls back
-#   to the one that might be accessible from the PATH.
-# * Unix: The desired Matlab should be accessible from the PATH.
-#
-# Additional information is provided when :variable:`MATLAB_FIND_DEBUG` is set.
-# When a Matlab binary is found automatically and the ``MATLAB_VERSION``
-# is not given, the version is queried from Matlab directly.
-# On Windows, it can make a window running Matlab appear.
-#
-# The mapping of the release names and the version of Matlab is performed by
-# defining pairs (name, version).  The variable
-# :variable:`MATLAB_ADDITIONAL_VERSIONS` may be provided before the call to
-# the :command:`find_package` in order to handle additional versions.
-#
-# A Matlab scripts can be added to the set of tests using the
-# :command:`matlab_add_unit_test`. By default, the Matlab unit test framework
-# will be used (>= 2013a) to run this script, but regular ``.m`` files
-# returning an exit code can be used as well (0 indicating a success).
-#
-# Module Input Variables
-# ^^^^^^^^^^^^^^^^^^^^^^
-#
-# Users or projects may set the following variables to configure the module
-# behaviour:
-#
-# :variable:`Matlab_ROOT_DIR`
-#   the root of the Matlab installation.
-# :variable:`MATLAB_FIND_DEBUG`
-#   outputs debug information
-# :variable:`MATLAB_ADDITIONAL_VERSIONS`
-#   additional versions of Matlab for the automatic retrieval of the installed
-#   versions.
-#
-# Variables defined by the module
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# Result variables
-# """"""""""""""""
-#
-# ``Matlab_FOUND``
-#   ``TRUE`` if the Matlab installation is found, ``FALSE``
-#   otherwise. All variable below are defined if Matlab is found.
-# ``Matlab_ROOT_DIR``
-#   the final root of the Matlab installation determined by the FindMatlab
-#   module.
-# ``Matlab_MAIN_PROGRAM``
-#   the Matlab binary program. Available only if the component ``MAIN_PROGRAM``
-#   is given in the :command:`find_package` directive.
-# ``Matlab_INCLUDE_DIRS``
-#  the path of the Matlab libraries headers
-# ``Matlab_MEX_LIBRARY``
-#   library for mex, always available.
-# ``Matlab_MX_LIBRARY``
-#   mx library of Matlab (arrays). Available only if the component
-#   ``MX_LIBRARY`` has been requested.
-# ``Matlab_ENG_LIBRARY``
-#   Matlab engine library. Available only if the component ``ENG_LIBRARY``
-#   is requested.
-# ``Matlab_MAT_LIBRARY``
-#   Matlab matrix library. Available only if the component ``MAT_LIBRARY``
-#   is requested.
-# ``Matlab_LIBRARIES``
-#   the whole set of libraries of Matlab
-# ``Matlab_MEX_COMPILER``
-#   the mex compiler of Matlab. Currently not used.
-#   Available only if the component ``MEX_COMPILER`` is asked
-#
-# Cached variables
-# """"""""""""""""
-#
-# ``Matlab_MEX_EXTENSION``
-#   the extension of the mex files for the current platform (given by Matlab).
-# ``Matlab_ROOT_DIR``
-#   the location of the root of the Matlab installation found. If this value
-#   is changed by the user, the result variables are recomputed.
-#
-# Provided macros
-# ^^^^^^^^^^^^^^^
-#
-# :command:`matlab_get_version_from_release_name`
-#   returns the version from the release name
-# :command:`matlab_get_release_name_from_version`
-#   returns the release name from the Matlab version
-#
-# Provided functions
-# ^^^^^^^^^^^^^^^^^^
-#
-# :command:`matlab_add_mex`
-#   adds a target compiling a MEX file.
-# :command:`matlab_add_unit_test`
-#   adds a Matlab unit test file as a test to the project.
-# :command:`matlab_extract_all_installed_versions_from_registry`
-#   parses the registry for all Matlab versions. Available on Windows only.
-#   The part of the registry parsed is dependent on the host processor
-# :command:`matlab_get_all_valid_matlab_roots_from_registry`
-#   returns all the possible Matlab paths, according to a previously
-#   given list. Only the existing/accessible paths are kept. This is mainly
-#   useful for the searching all possible Matlab installation.
-# :command:`matlab_get_mex_suffix`
-#   returns the suffix to be used for the mex files
-#   (platform/architecture dependent)
-# :command:`matlab_get_version_from_matlab_run`
-#   returns the version of Matlab, given the full directory of the Matlab
-#   program.
-#
-#
-# Known issues
-# ^^^^^^^^^^^^
-#
-# **Symbol clash in a MEX target**
-#   By default, every symbols inside a MEX
-#   file defined with the command :command:`matlab_add_mex` have hidden
-#   visibility, except for the entry point. This is the default behaviour of
-#   the MEX compiler, which lowers the risk of symbol collision between the
-#   libraries shipped with Matlab, and the libraries to which the MEX file is
-#   linking to. This is also the default on Windows platforms.
-#
-#   However, this is not sufficient in certain case, where for instance your
-#   MEX file is linking against libraries that are already loaded by Matlab,
-#   even if those libraries have different SONAMES.
-#   A possible solution is to hide the symbols of the libraries to which the
-#   MEX target is linking to. This can be achieved in GNU GCC compilers with
-#   the linker option ``-Wl,--exclude-libs,ALL``.
-#
-# **Tests using GPU resources**
-#   in case your MEX file is using the GPU and
-#   in order to be able to run unit tests on this MEX file, the GPU resources
-#   should be properly released by Matlab. A possible solution is to make
-#   Matlab aware of the use of the GPU resources in the session, which can be
-#   performed by a command such as ``D = gpuDevice()`` at the beginning of
-#   the test script (or via a fixture).
-#
-#
-# Reference
-# ^^^^^^^^^
-#
-# .. variable:: Matlab_ROOT_DIR
-#
-#    The root folder of the Matlab installation. If set before the call to
-#    :command:`find_package`, the module will look for the components in that
-#    path. If not set, then an automatic search of Matlab
-#    will be performed. If set, it should point to a valid version of Matlab.
-#
-# .. variable:: MATLAB_FIND_DEBUG
-#
-#    If set, the lookup of Matlab and the intermediate configuration steps are
-#    outputted to the console.
-#
-# .. variable:: MATLAB_ADDITIONAL_VERSIONS
-#
-#   If set, specifies additional versions of Matlab that may be looked for.
-#   The variable should be a list of strings, organised by pairs of release
-#   name and versions, such as follows::
-#
-#     set(MATLAB_ADDITIONAL_VERSIONS
-#         "release_name1=corresponding_version1"
-#         "release_name2=corresponding_version2"
-#         ...
-#         )
-#
-#   Example::
-#
-#     set(MATLAB_ADDITIONAL_VERSIONS
-#         "R2013b=8.2"
-#         "R2013a=8.1"
-#         "R2012b=8.0")
-#
-#   The order of entries in this list matters when several versions of
-#   Matlab are installed. The priority is set according to the ordering in
-#   this list.
-
-set(_FindMatlab_SELF_DIR "${CMAKE_CURRENT_LIST_DIR}")
-
-include(FindPackageHandleStandardArgs)
-include(CheckCXXCompilerFlag)
-include(CheckCCompilerFlag)
-
-
-# The currently supported versions. Other version can be added by the user by
-# providing MATLAB_ADDITIONAL_VERSIONS
-if(NOT MATLAB_ADDITIONAL_VERSIONS)
-  set(MATLAB_ADDITIONAL_VERSIONS)
-endif()
-
-# Is this mapping necessary? It's always causing trouble to need to bump these
-# for each new version.
-set(MATLAB_VERSIONS_MAPPING
-  "R2020b=9.9"
-  "R2020a=9.8"
-  "R2019b=9.7"
-  "R2019a=9.6"
-  "R2018b=9.5"
-  "R2018a=9.4"
-  "R2017b=9.3"
-  "R2017a=9.2"
-  "R2016b=9.1"
-  "R2016a=9.0"
-  "R2015b=8.6"
-  "R2015a=8.5"
-  "R2014b=8.4"
-  "R2014a=8.3"
-  "R2013b=8.2"
-  "R2013a=8.1"
-  "R2012b=8.0"
-  "R2012a=7.14"
-  "R2011b=7.13"
-  "R2011a=7.12"
-  "R2010b=7.11"
-
-  ${MATLAB_ADDITIONAL_VERSIONS}
-  )
-
-
-# temporary folder for all Matlab runs
-set(_matlab_temporary_folder ${CMAKE_BINARY_DIR}/Matlab)
-
-if(NOT EXISTS "${_matlab_temporary_folder}")
-  file(MAKE_DIRECTORY "${_matlab_temporary_folder}")
-endif()
-
-#.rst:
-# .. command:: matlab_get_version_from_release_name
-#
-#   Returns the version of Matlab (17.58) from a release name (R2017k)
-macro (matlab_get_version_from_release_name release_name version_name)
-
-  string(REGEX MATCHALL "${release_name}=([0-9]+\\.?[0-9]*)" _matched ${MATLAB_VERSIONS_MAPPING})
-
-  set(${version_name} "")
-  if(NOT _matched STREQUAL "")
-    set(${version_name} ${CMAKE_MATCH_1})
-  else()
-    message(WARNING "The release name ${release_name} is not registered")
-  endif()
-  unset(_matched)
-
-endmacro()
-
-
-
-
-
-#.rst:
-# .. command:: matlab_get_release_name_from_version
-#
-#   Returns the release name (R2017k) from the version of Matlab (17.58)
-macro (matlab_get_release_name_from_version version release_name)
-
-  set(${release_name} "")
-  foreach(_var IN LISTS MATLAB_VERSIONS_MAPPING)
-    string(REGEX MATCHALL "(.+)=${version}" _matched ${_var})
-    if(NOT _matched STREQUAL "")
-      set(${release_name} ${CMAKE_MATCH_1})
-      break()
-    endif()
-  endforeach(_var)
-
-  unset(_var)
-  unset(_matched)
-  if(${release_name} STREQUAL "")
-    message(WARNING "The version ${version} is not registered")
-  endif()
-
-endmacro()
-
-
-
-
-
-# extracts all the supported release names (R2017k...) of Matlab
-# internal use
-macro(matlab_get_supported_releases list_releases)
-  set(${list_releases})
-  foreach(_var IN LISTS MATLAB_VERSIONS_MAPPING)
-    string(REGEX MATCHALL "(.+)=([0-9]+\\.?[0-9]*)" _matched ${_var})
-    if(NOT _matched STREQUAL "")
-      list(APPEND ${list_releases} ${CMAKE_MATCH_1})
-    endif()
-    unset(_matched)
-    unset(CMAKE_MATCH_1)
-  endforeach(_var)
-  unset(_var)
-endmacro()
-
-
-
-# extracts all the supported versions of Matlab
-# internal use
-macro(matlab_get_supported_versions list_versions)
-  set(${list_versions})
-  foreach(_var IN LISTS MATLAB_VERSIONS_MAPPING)
-    string(REGEX MATCHALL "(.+)=([0-9]+\\.?[0-9]*)" _matched ${_var})
-    if(NOT _matched STREQUAL "")
-      list(APPEND ${list_versions} ${CMAKE_MATCH_2})
-    endif()
-    unset(_matched)
-    unset(CMAKE_MATCH_1)
-  endforeach(_var)
-  unset(_var)
-endmacro()
-
-
-#.rst:
-# .. command:: matlab_extract_all_installed_versions_from_registry
-#
-#   This function parses the registry and founds the Matlab versions that are
-#   installed. The found versions are returned in `matlab_versions`.
-#   Set `win64` to `TRUE` if the 64 bit version of Matlab should be looked for
-#   The returned list contains all versions under
-#   ``HKLM\\SOFTWARE\\Mathworks\\MATLAB`` or an empty list in case an error
-#   occurred (or nothing found).
-#
-#   .. note::
-#
-#     Only the versions are provided. No check is made over the existence of the
-#     installation referenced in the registry,
-#
-function(matlab_extract_all_installed_versions_from_registry win64 matlab_versions)
-
-  if(NOT CMAKE_HOST_WIN32)
-    message(FATAL_ERROR "This macro can only be called by a windows host (call to reg.exe")
-  endif()
-
-
-  if(${win64} AND ${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "64")
-    set(APPEND_REG "/reg:64")
-  else()
-    set(APPEND_REG "/reg:32")
-  endif()
-
-  # /reg:64 should be added on 64 bits capable OSs in order to enable the
-  # redirection of 64 bits applications
-  execute_process(
-    COMMAND reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Mathworks\\MATLAB /f * /k ${APPEND_REG}
-    RESULT_VARIABLE resultMatlab
-    OUTPUT_VARIABLE varMatlab
-    ERROR_VARIABLE errMatlab
-    INPUT_FILE NUL
-    )
-
-
-  set(matlabs_from_registry)
-  if(${resultMatlab} EQUAL 0)
-
-    string(
-      REGEX MATCHALL "MATLAB\\\\([0-9]+(\\.[0-9]+)?)"
-      matlab_versions_regex ${varMatlab})
-
-    foreach(match IN LISTS matlab_versions_regex)
-      string(
-        REGEX MATCH "MATLAB\\\\(([0-9]+)(\\.([0-9]+))?)"
-        current_match ${match})
-
-      set(_matlab_current_version ${CMAKE_MATCH_1})
-      set(current_matlab_version_major ${CMAKE_MATCH_2})
-      set(current_matlab_version_minor ${CMAKE_MATCH_4})
-      if(NOT current_matlab_version_minor)
-        set(current_matlab_version_minor "0")
-      endif()
-
-      list(APPEND matlabs_from_registry ${_matlab_current_version})
-      unset(_matlab_current_version)
-    endforeach(match)
-
-  endif()
-
-  if(matlabs_from_registry)
-    list(REMOVE_DUPLICATES matlabs_from_registry)
-    list(SORT matlabs_from_registry)
-    list(REVERSE matlabs_from_registry)
-  endif()
-
-  set(${matlab_versions} ${matlabs_from_registry} PARENT_SCOPE)
-
-endfunction()
-
-
-
-# (internal)
-macro(extract_matlab_versions_from_registry_brute_force matlab_versions)
-  # get the supported versions
-  set(matlab_supported_versions)
-  matlab_get_supported_versions(matlab_supported_versions)
-
-
-  # this is a manual population of the versions we want to look for
-  # this can be done as is, but preferably with the call to
-  # matlab_get_supported_versions and variable
-
-  # populating the versions we want to look for
-  # set(matlab_supported_versions)
-
-  # # Matlab 7
-  # set(matlab_major 7)
-  # foreach(current_matlab_minor RANGE 4 20)
-    # list(APPEND matlab_supported_versions "${matlab_major}.${current_matlab_minor}")
-  # endforeach(current_matlab_minor)
-
-  # # Matlab 8
-  # set(matlab_major 8)
-  # foreach(current_matlab_minor RANGE 0 5)
-    # list(APPEND matlab_supported_versions "${matlab_major}.${current_matlab_minor}")
-  # endforeach(current_matlab_minor)
-
-  # # taking into account the possible additional versions provided by the user
-  # if(DEFINED MATLAB_ADDITIONAL_VERSIONS)
-    # list(APPEND matlab_supported_versions MATLAB_ADDITIONAL_VERSIONS)
-  # endif()
-
-
-  # we order from more recent to older
-  if(matlab_supported_versions)
-    list(REMOVE_DUPLICATES matlab_supported_versions)
-    list(SORT matlab_supported_versions)
-    list(REVERSE matlab_supported_versions)
-  endif()
-
-
-  set(${matlab_versions} ${matlab_supported_versions})
-
-
-endmacro()
-
-
-
-
-#.rst:
-# .. command:: matlab_get_all_valid_matlab_roots_from_registry
-#
-#   Populates the Matlab root with valid versions of Matlab.
-#   The returned matlab_roots is organized in pairs
-#   ``(version_number,matlab_root_path)``.
-#
-#   ::
-#
-#     matlab_get_all_valid_matlab_roots_from_registry(
-#         matlab_versions
-#         matlab_roots)
-#
-#   ``matlab_versions``
-#     the versions of each of the Matlab installations
-#   ``matlab_roots``
-#     the location of each of the Matlab installations
-function(matlab_get_all_valid_matlab_roots_from_registry matlab_versions matlab_roots)
-
-  # The matlab_versions comes either from
-  # extract_matlab_versions_from_registry_brute_force or
-  # matlab_extract_all_installed_versions_from_registry.
-
-
-  set(_matlab_roots_list )
-  foreach(_matlab_current_version ${matlab_versions})
-    get_filename_component(
-      current_MATLAB_ROOT
-      "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\${_matlab_current_version};MATLABROOT]"
-      ABSOLUTE)
-
-    if(EXISTS ${current_MATLAB_ROOT})
-      list(APPEND _matlab_roots_list ${_matlab_current_version} ${current_MATLAB_ROOT})
-    endif()
-
-  endforeach(_matlab_current_version)
-  unset(_matlab_current_version)
-  set(${matlab_roots} ${_matlab_roots_list} PARENT_SCOPE)
-  unset(_matlab_roots_list)
-endfunction()
-
-#.rst:
-# .. command:: matlab_get_mex_suffix
-#
-#   Returns the extension of the mex files (the suffixes).
-#   This function should not be called before the appropriate Matlab root has
-#   been found.
-#
-#   ::
-#
-#     matlab_get_mex_suffix(
-#         matlab_root
-#         mex_suffix)
-#
-#   ``matlab_root``
-#     the root of the Matlab installation
-#   ``mex_suffix``
-#     the variable name in which the suffix will be returned.
-function(matlab_get_mex_suffix matlab_root mex_suffix)
-
-  # todo setup the extension properly. Currently I do not know if this is
-  # sufficient for all win32 distributions.
-  # there is also CMAKE_EXECUTABLE_SUFFIX that could be tweaked
-  set(mexext_suffix "")
-  if(WIN32)
-    list(APPEND mexext_suffix ".bat")
-  endif()
-
-  # we first try without suffix, since cmake does not understand a list with
-  # one empty string element
-  find_program(
-    Matlab_MEXEXTENSIONS_PROG
-    NAMES mexext
-    PATHS ${matlab_root}/bin
-    DOC "Matlab MEX extension provider"
-    NO_DEFAULT_PATH
-  )
-
-  foreach(current_mexext_suffix IN LISTS mexext_suffix)
-    if(NOT DEFINED Matlab_MEXEXTENSIONS_PROG OR NOT Matlab_MEXEXTENSIONS_PROG)
-      # this call should populate the cache automatically
-      find_program(
-        Matlab_MEXEXTENSIONS_PROG
-        "mexext${current_mexext_suffix}"
-        PATHS ${matlab_root}/bin
-        DOC "Matlab MEX extension provider"
-        NO_DEFAULT_PATH
-      )
-    endif()
-  endforeach(current_mexext_suffix)
-
-
-  # the program has been found?
-  if((NOT Matlab_MEXEXTENSIONS_PROG) OR (NOT EXISTS ${Matlab_MEXEXTENSIONS_PROG}))
-    if(MATLAB_FIND_DEBUG)
-      message(WARNING "[MATLAB] Cannot found mexext program. Matlab root is ${matlab_root}")
-    endif()
-    unset(Matlab_MEXEXTENSIONS_PROG CACHE)
-    return()
-  endif()
-
-  set(_matlab_mex_extension)
-
-  set(devnull)
-  if(UNIX)
-    set(devnull INPUT_FILE /dev/null)
-  elseif(WIN32)
-    set(devnull INPUT_FILE NUL)
-  endif()
-
-  execute_process(
-    COMMAND ${Matlab_MEXEXTENSIONS_PROG}
-    OUTPUT_VARIABLE _matlab_mex_extension
-    ERROR_VARIABLE _matlab_mex_extension_error
-    ${devnull})
-  string(STRIP ${_matlab_mex_extension} _matlab_mex_extension)
-
-  unset(Matlab_MEXEXTENSIONS_PROG CACHE)
-  set(${mex_suffix} ${_matlab_mex_extension} PARENT_SCOPE)
-endfunction()
-
-
-
-
-#.rst:
-# .. command:: matlab_get_version_from_matlab_run
-#
-#   This function runs Matlab program specified on arguments and extracts its
-#   version.
-#
-#   ::
-#
-#     matlab_get_version_from_matlab_run(
-#         matlab_binary_path
-#         matlab_list_versions)
-#
-#   ``matlab_binary_path``
-#     the location of the `matlab` binary executable
-#   ``matlab_list_versions``
-#     the version extracted from Matlab
-function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_versions)
-
-  set(${matlab_list_versions} "" PARENT_SCOPE)
-
-
-  if(MATLAB_FIND_DEBUG)
-    message(STATUS "[MATLAB] Determining the version of Matlab from ${matlab_binary_program}")
-  endif()
-
-  if(EXISTS "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp")
-    if(MATLAB_FIND_DEBUG)
-      message(STATUS "[MATLAB] Removing previous ${_matlab_temporary_folder}/matlabVersionLog.cmaketmp file")
-    endif()
-    file(REMOVE "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp")
-  endif()
-
-
-  # the log file is needed since on windows the command executes in a new
-  # window and it is not possible to get back the answer of Matlab
-  # the -wait command is needed on windows, otherwise the call returns
-  # immediately after the program launches itself.
-  if(WIN32)
-    set(_matlab_additional_commands "-wait")
-  endif()
-
-  set(devnull)
-  if(UNIX)
-    set(devnull INPUT_FILE /dev/null)
-  elseif(WIN32)
-    set(devnull INPUT_FILE NUL)
-  endif()
-
-  # timeout set to 120 seconds, in case it does not start
-  # note as said before OUTPUT_VARIABLE cannot be used in a platform
-  # independent manner however, not setting it would flush the output of Matlab
-  # in the current console (unix variant)
-  execute_process(
-    COMMAND "${matlab_binary_program}" -nosplash -nojvm ${_matlab_additional_commands} -logfile "matlabVersionLog.cmaketmp" -nodesktop -nodisplay -r "version, exit"
-    OUTPUT_VARIABLE _matlab_version_from_cmd_dummy
-    RESULT_VARIABLE _matlab_result_version_call
-    ERROR_VARIABLE _matlab_result_version_call_error
-    TIMEOUT 120
-    WORKING_DIRECTORY "${_matlab_temporary_folder}"
-    ${devnull}
-    )
-
-  if("${_matlab_result_version_call}" MATCHES "timeout")
-    if(MATLAB_FIND_DEBUG)
-      message(WARNING "[MATLAB] Unable to determine the version of Matlab."
-        " Matlab call timed out after 120 seconds.")
-    endif()
-    return()
-  endif()
-
-  if(${_matlab_result_version_call})
-    if(MATLAB_FIND_DEBUG)
-      message(WARNING "[MATLAB] Unable to determine the version of Matlab. Matlab call returned with error ${_matlab_result_version_call}.")
-    endif()
-    return()
-  elseif(NOT EXISTS "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp")
-    if(MATLAB_FIND_DEBUG)
-      message(WARNING "[MATLAB] Unable to determine the version of Matlab. The log file does not exist.")
-    endif()
-    return()
-  endif()
-
-  # if successful, read back the log
-  file(READ "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp" _matlab_version_from_cmd)
-  file(REMOVE "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp")
-
-  set(index -1)
-  string(FIND ${_matlab_version_from_cmd} "ans" index)
-  if(index EQUAL -1)
-
-    if(MATLAB_FIND_DEBUG)
-      message(WARNING "[MATLAB] Cannot find the version of Matlab returned by the run.")
-    endif()
-
-  else()
-    set(matlab_list_of_all_versions_tmp)
-
-    string(SUBSTRING ${_matlab_version_from_cmd} ${index} -1 substring_ans)
-    string(
-      REGEX MATCHALL "ans[\r\n\t ]*=[\r\n\t ]*'?([0-9]+(\\.[0-9]+)?)"
-      matlab_versions_regex
-      ${substring_ans})
-    foreach(match IN LISTS matlab_versions_regex)
-      string(
-        REGEX MATCH "ans[\r\n\t ]*=[\r\n\t ]*'?(([0-9]+)(\\.([0-9]+))?)"
-        current_match ${match})
-
-      list(APPEND matlab_list_of_all_versions_tmp ${CMAKE_MATCH_1})
-    endforeach()
-    if(matlab_list_of_all_versions_tmp)
-      list(REMOVE_DUPLICATES matlab_list_of_all_versions_tmp)
-    endif()
-    set(${matlab_list_versions} ${matlab_list_of_all_versions_tmp} PARENT_SCOPE)
-
-  endif()
-
-endfunction()
-
-#.rst:
-# .. command:: matlab_add_unit_test
-#
-#   Adds a Matlab unit test to the test set of cmake/ctest.
-#   This command requires the component ``MAIN_PROGRAM``.
-#   The unit test uses the Matlab unittest framework (default, available
-#   starting Matlab 2013b+) except if the option ``NO_UNITTEST_FRAMEWORK``
-#   is given.
-#
-#   The function expects one Matlab test script file to be given.
-#   In the case ``NO_UNITTEST_FRAMEWORK`` is given, the unittest script file
-#   should contain the script to be run, plus an exit command with the exit
-#   value. This exit value will be passed to the ctest framework (0 success,
-#   non 0 failure). Additional arguments accepted by :command:`add_test` can be
-#   passed through ``TEST_ARGS`` (eg. ``CONFIGURATION <config> ...``).
-#
-#   ::
-#
-#     matlab_add_unit_test(
-#         NAME <name>
-#         UNITTEST_FILE matlab_file_containing_unittest.m
-#         [CUSTOM_TEST_COMMAND matlab_command_to_run_as_test]
-#         [UNITTEST_PRECOMMAND matlab_command_to_run]
-#         [TIMEOUT timeout]
-#         [ADDITIONAL_PATH path1 [path2 ...]]
-#         [MATLAB_ADDITIONAL_STARTUP_OPTIONS option1 [option2 ...]]
-#         [TEST_ARGS arg1 [arg2 ...]]
-#         [NO_UNITTEST_FRAMEWORK]
-#         )
-#
-#   The function arguments are:
-#
-#   ``NAME``
-#     name of the unittest in ctest.
-#   ``UNITTEST_FILE``
-#     the matlab unittest file. Its path will be automatically
-#     added to the Matlab path.
-#   ``CUSTOM_TEST_COMMAND``
-#     Matlab script command to run as the test.
-#     If this is not set, then the following is run:
-#     ``runtests('matlab_file_name'), exit(max([ans(1,:).Failed]))``
-#     where ``matlab_file_name`` is the ``UNITTEST_FILE`` without the extension.
-#   ``UNITTEST_PRECOMMAND``
-#     Matlab script command to be ran before the file
-#     containing the test (eg. GPU device initialisation based on CMake
-#     variables).
-#   ``TIMEOUT``
-#     the test timeout in seconds. Defaults to 180 seconds as the
-#     Matlab unit test may hang.
-#   ``ADDITIONAL_PATH``
-#     a list of paths to add to the Matlab path prior to
-#     running the unit test.
-#   ``MATLAB_ADDITIONAL_STARTUP_OPTIONS``
-#     a list of additional option in order
-#     to run Matlab from the command line.
-#     ``-nosplash -nodesktop -nodisplay`` are always added.
-#   ``TEST_ARGS``
-#     Additional options provided to the add_test command. These
-#     options are added to the default options (eg. "CONFIGURATIONS Release")
-#   ``NO_UNITTEST_FRAMEWORK``
-#     when set, indicates that the test should not
-#     use the unittest framework of Matlab (available for versions >= R2013a).
-#   ``WORKING_DIRECTORY``
-#     This will be the working directory for the test. If specified it will
-#     also be the output directory used for the log file of the test run.
-#     If not specifed the temporary directory ``${CMAKE_BINARY_DIR}/Matlab`` will
-#     be used as the working directory and the log location.
-#
-function(matlab_add_unit_test)
-
-  if(NOT Matlab_MAIN_PROGRAM)
-    message(FATAL_ERROR "[MATLAB] This functionality needs the MAIN_PROGRAM component (not default)")
-  endif()
-
-  set(options NO_UNITTEST_FRAMEWORK)
-  set(oneValueArgs NAME UNITTEST_FILE TIMEOUT WORKING_DIRECTORY
-    UNITTEST_PRECOMMAND CUSTOM_TEST_COMMAND)
-  set(multiValueArgs ADDITIONAL_PATH MATLAB_ADDITIONAL_STARTUP_OPTIONS TEST_ARGS)
-
-  set(prefix _matlab_unittest_prefix)
-  cmake_parse_arguments(PARSE_ARGV 0 ${prefix} "${options}" "${oneValueArgs}" "${multiValueArgs}" )
-
-  if(NOT ${prefix}_NAME)
-    message(FATAL_ERROR "[MATLAB] The Matlab test name cannot be empty")
-  endif()
-
-  add_test(NAME ${${prefix}_NAME}
-           COMMAND ${CMAKE_COMMAND}
-            "-Dtest_name=${${prefix}_NAME}"
-            "-Dadditional_paths=${${prefix}_ADDITIONAL_PATH}"
-            "-Dtest_timeout=${${prefix}_TIMEOUT}"
-            "-Doutput_directory=${_matlab_temporary_folder}"
-            "-Dworking_directory=${${prefix}_WORKING_DIRECTORY}"
-            "-DMatlab_PROGRAM=${Matlab_MAIN_PROGRAM}"
-            "-Dno_unittest_framework=${${prefix}_NO_UNITTEST_FRAMEWORK}"
-            "-DMatlab_ADDITIONAL_STARTUP_OPTIONS=${${prefix}_MATLAB_ADDITIONAL_STARTUP_OPTIONS}"
-            "-Dunittest_file_to_run=${${prefix}_UNITTEST_FILE}"
-            "-Dcustom_Matlab_test_command=${${prefix}_CUSTOM_TEST_COMMAND}"
-            "-Dcmd_to_run_before_test=${${prefix}_UNITTEST_PRECOMMAND}"
-            -P ${_FindMatlab_SELF_DIR}/MatlabTestsRedirect.cmake
-           ${${prefix}_TEST_ARGS}
-           ${${prefix}_UNPARSED_ARGUMENTS}
-           )
-endfunction()
-
-
-#.rst:
-# .. command:: matlab_add_mex
-#
-#   Adds a Matlab MEX target.
-#   This commands compiles the given sources with the current tool-chain in
-#   order to produce a MEX file. The final name of the produced output may be
-#   specified, as well as additional link libraries, and a documentation entry
-#   for the MEX file. Remaining arguments of the call are passed to the
-#   :command:`add_library` or :command:`add_executable` command.
-#
-#   ::
-#
-#      matlab_add_mex(
-#          NAME <name>
-#          [EXECUTABLE | MODULE | SHARED]
-#          SRC src1 [src2 ...]
-#          [OUTPUT_NAME output_name]
-#          [DOCUMENTATION file.txt]
-#          [LINK_TO target1 target2 ...]
-#          [...]
-#      )
-#
-#   ``NAME``
-#     name of the target.
-#   ``SRC``
-#     list of source files.
-#   ``LINK_TO``
-#     a list of additional link dependencies.  The target links to ``libmex``
-#     by default. If ``Matlab_MX_LIBRARY`` is defined, it also
-#     links to ``libmx``.
-#   ``OUTPUT_NAME``
-#     if given, overrides the default name. The default name is
-#     the name of the target without any prefix and
-#     with ``Matlab_MEX_EXTENSION`` suffix.
-#   ``DOCUMENTATION``
-#     if given, the file ``file.txt`` will be considered as
-#     being the documentation file for the MEX file. This file is copied into
-#     the same folder without any processing, with the same name as the final
-#     mex file, and with extension `.m`. In that case, typing ``help <name>``
-#     in Matlab prints the documentation contained in this file.
-#   ``MODULE`` or ``SHARED`` may be given to specify the type of library to be
-#     created. ``EXECUTABLE`` may be given to create an executable instead of
-#     a library. If no type is given explicitly, the type is ``SHARED``.
-#
-#   The documentation file is not processed and should be in the following
-#   format:
-#
-#   ::
-#
-#     % This is the documentation
-#     function ret = mex_target_output_name(input1)
-#
-function(matlab_add_mex)
-
-  if(NOT WIN32)
-    # we do not need all this on Windows
-    # pthread options
-    if(CMAKE_CXX_COMPILER_LOADED)
-      check_cxx_compiler_flag(-pthread HAS_MINUS_PTHREAD)
-    elseif(CMAKE_C_COMPILER_LOADED)
-      check_c_compiler_flag(-pthread HAS_MINUS_PTHREAD)
-    endif()
-    # we should use try_compile instead, the link flags are discarded from
-    # this compiler_flag function.
-    #check_cxx_compiler_flag(-Wl,--exclude-libs,ALL HAS_SYMBOL_HIDING_CAPABILITY)
-
-  endif()
-
-  set(options EXECUTABLE MODULE SHARED)
-  set(oneValueArgs NAME DOCUMENTATION OUTPUT_NAME)
-  set(multiValueArgs LINK_TO SRC)
-
-  set(prefix _matlab_addmex_prefix)
-  cmake_parse_arguments(${prefix} "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
-
-  if(NOT ${prefix}_NAME)
-    message(FATAL_ERROR "[MATLAB] The MEX target name cannot be empty")
-  endif()
-
-  if(NOT ${prefix}_OUTPUT_NAME)
-    set(${prefix}_OUTPUT_NAME ${${prefix}_NAME})
-  endif()
-
-  if(${prefix}_EXECUTABLE)
-    add_executable(${${prefix}_NAME}
-      ${${prefix}_SRC}
-      ${${prefix}_DOCUMENTATION}
-      ${${prefix}_UNPARSED_ARGUMENTS})
-  else()
-    if(${prefix}_MODULE)
-      set(type MODULE)
-    else()
-      set(type SHARED)
-    endif()
-
-    add_library(${${prefix}_NAME}
-      ${type}
-      ${${prefix}_SRC}
-      ${${prefix}_DOCUMENTATION}
-      ${${prefix}_UNPARSED_ARGUMENTS})
-  endif()
-
-  target_include_directories(${${prefix}_NAME} PRIVATE ${Matlab_INCLUDE_DIRS})
-
-  if(DEFINED Matlab_MX_LIBRARY)
-    target_link_libraries(${${prefix}_NAME} ${Matlab_MX_LIBRARY})
-  endif()
-
-  target_link_libraries(${${prefix}_NAME} ${Matlab_MEX_LIBRARY} ${${prefix}_LINK_TO})
-  set_target_properties(${${prefix}_NAME}
-      PROPERTIES
-        PREFIX ""
-        OUTPUT_NAME ${${prefix}_OUTPUT_NAME}
-        SUFFIX ".${Matlab_MEX_EXTENSION}")
-
-
-  # documentation
-  if(NOT ${${prefix}_DOCUMENTATION} STREQUAL "")
-    get_target_property(output_name ${${prefix}_NAME} OUTPUT_NAME)
-    add_custom_command(
-      TARGET ${${prefix}_NAME}
-      PRE_BUILD
-      COMMAND ${CMAKE_COMMAND} -E copy_if_different ${${prefix}_DOCUMENTATION} $<TARGET_FILE_DIR:${${prefix}_NAME}>/${output_name}.m
-      COMMENT "Copy ${${prefix}_NAME} documentation file into the output folder"
-    )
-  endif() # documentation
-
-  # entry point in the mex file + taking care of visibility and symbol clashes.
-  if(WIN32)
-    set_target_properties(${${prefix}_NAME}
-      PROPERTIES
-        DEFINE_SYMBOL "DLL_EXPORT_SYM=__declspec(dllexport)")
-  else()
-
-    if(HAS_MINUS_PTHREAD AND NOT APPLE)
-      # Apparently, compiling with -pthread generated the proper link flags
-      # and some defines at compilation
-      target_compile_options(${${prefix}_NAME} PRIVATE "-pthread")
-    endif()
-
-
-    # if we do not do that, the symbols linked from eg. boost remain weak and
-    # then clash with the ones defined in the matlab process. So by default
-    # the symbols are hidden.
-    # This also means that for shared libraries (like MEX), the entry point
-    # should be explicitly declared with default visibility, otherwise Matlab
-    # cannot find the entry point.
-    # Note that this is particularly meaningful if the MEX wrapper itself
-    # contains symbols that are clashing with Matlab (that are compiled in the
-    # MEX file). In order to propagate the visibility options to the libraries
-    # to which the MEX file is linked against, the -Wl,--exclude-libs,ALL
-    # option should also be specified.
-
-    set_target_properties(${${prefix}_NAME}
-      PROPERTIES
-        CXX_VISIBILITY_PRESET "hidden"
-        C_VISIBILITY_PRESET "hidden"
-        VISIBILITY_INLINES_HIDDEN ON
-    )
-
-    #  get_target_property(
-    #    _previous_link_flags
-    #    ${${prefix}_NAME}
-    #    LINK_FLAGS)
-    #  if(NOT _previous_link_flags)
-    #    set(_previous_link_flags)
-    #  endif()
-
-    #  if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
-    #    set_target_properties(${${prefix}_NAME}
-    #      PROPERTIES
-    #        LINK_FLAGS "${_previous_link_flags} -Wl,--exclude-libs,ALL"
-    #        # -Wl,--version-script=${_FindMatlab_SELF_DIR}/MatlabLinuxVisibility.map"
-    #    )
-    #  elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
-    #    # in this case, all other symbols become hidden.
-    #    set_target_properties(${${prefix}_NAME}
-    #      PROPERTIES
-    #        LINK_FLAGS "${_previous_link_flags} -Wl,-exported_symbol,_mexFunction"
-    #        #-Wl,-exported_symbols_list,${_FindMatlab_SELF_DIR}/MatlabOSXVisilibity.map"
-    #    )
-    #  endif()
-
-
-
-    set_target_properties(${${prefix}_NAME}
-      PROPERTIES
-        DEFINE_SYMBOL "DLL_EXPORT_SYM=__attribute__ ((visibility (\"default\")))"
-    )
-
-
-  endif()
-
-endfunction()
-
-
-# (internal)
-# Used to get the version of matlab, using caching. This basically transforms the
-# output of the root list, with possible unknown version, to a version
-#
-function(_Matlab_get_version_from_root matlab_root matlab_known_version matlab_final_version)
-
-  # if the version is not trivial, we query matlab for that
-  # we keep track of the location of matlab that induced this version
-  #if(NOT DEFINED Matlab_PROG_VERSION_STRING_AUTO_DETECT)
-  #  set(Matlab_PROG_VERSION_STRING_AUTO_DETECT "" CACHE INTERNAL "internal matlab location for the discovered version")
-  #endif()
-
-  if(NOT ${matlab_known_version} STREQUAL "NOTFOUND")
-    # the version is known, we just return it
-    set(${matlab_final_version} ${matlab_known_version} PARENT_SCOPE)
-    set(Matlab_VERSION_STRING_INTERNAL ${matlab_known_version} CACHE INTERNAL "Matlab version (automatically determined)" FORCE)
-    return()
-  endif()
-
-  #
-  set(_matlab_current_program ${Matlab_MAIN_PROGRAM})
-
-  # do we already have a matlab program?
-  if(NOT _matlab_current_program)
-
-    set(_find_matlab_options)
-    if(matlab_root AND EXISTS ${matlab_root})
-      set(_find_matlab_options PATHS ${matlab_root} ${matlab_root}/bin NO_DEFAULT_PATH)
-    endif()
-
-    find_program(
-        _matlab_current_program
-        matlab
-        ${_find_matlab_options}
-        DOC "Matlab main program"
-      )
-  endif()
-
-  if(NOT _matlab_current_program OR NOT EXISTS ${_matlab_current_program})
-    # if not found, clear the dependent variables
-    if(MATLAB_FIND_DEBUG)
-      message(WARNING "[MATLAB] Cannot find the main matlab program under ${matlab_root}")
-    endif()
-    set(Matlab_PROG_VERSION_STRING_AUTO_DETECT "" CACHE INTERNAL "internal matlab location for the discovered version" FORCE)
-    set(Matlab_VERSION_STRING_INTERNAL "" CACHE INTERNAL "internal matlab location for the discovered version" FORCE)
-    unset(_matlab_current_program)
-    unset(_matlab_current_program CACHE)
-    return()
-  endif()
-
-  # full real path for path comparison
-  get_filename_component(_matlab_main_real_path_tmp "${_matlab_current_program}" REALPATH)
-  unset(_matlab_current_program)
-  unset(_matlab_current_program CACHE)
-
-  # is it the same as the previous one?
-  if(_matlab_main_real_path_tmp STREQUAL Matlab_PROG_VERSION_STRING_AUTO_DETECT)
-    set(${matlab_final_version} ${Matlab_VERSION_STRING_INTERNAL} PARENT_SCOPE)
-    return()
-  endif()
-
-  # update the location of the program
-  set(Matlab_PROG_VERSION_STRING_AUTO_DETECT ${_matlab_main_real_path_tmp} CACHE INTERNAL "internal matlab location for the discovered version" FORCE)
-
-  set(matlab_list_of_all_versions)
-  matlab_get_version_from_matlab_run("${Matlab_PROG_VERSION_STRING_AUTO_DETECT}" matlab_list_of_all_versions)
-
-  list(LENGTH matlab_list_of_all_versions list_of_all_versions_length)
-  if(${list_of_all_versions_length} GREATER 0)
-    list(GET matlab_list_of_all_versions 0 _matlab_version_tmp)
-  else()
-    set(_matlab_version_tmp "unknown")
-  endif()
-
-  # set the version into the cache
-  set(Matlab_VERSION_STRING_INTERNAL ${_matlab_version_tmp} CACHE INTERNAL "Matlab version (automatically determined)" FORCE)
-
-  # warning, just in case several versions found (should not happen)
-  if((${list_of_all_versions_length} GREATER 1) AND MATLAB_FIND_DEBUG)
-    message(WARNING "[MATLAB] Found several versions, taking the first one (versions found ${matlab_list_of_all_versions})")
-  endif()
-
-  # return the updated value
-  set(${matlab_final_version} ${Matlab_VERSION_STRING_INTERNAL} PARENT_SCOPE)
-
-endfunction()
-
-
-
-
-
-
-
-# ###################################
-# Exploring the possible Matlab_ROOTS
-
-# this variable will get all Matlab installations found in the current system.
-set(_matlab_possible_roots)
-
-
-
-if(Matlab_ROOT_DIR)
-  # if the user specifies a possible root, we keep this one
-
-  if(NOT EXISTS ${Matlab_ROOT_DIR})
-    # if Matlab_ROOT_DIR specified but erroneous
-    if(MATLAB_FIND_DEBUG)
-      message(WARNING "[MATLAB] the specified path for Matlab_ROOT_DIR does not exist (${Matlab_ROOT_DIR})")
-    endif()
-  else()
-    # NOTFOUND indicates the code below to search for the version automatically
-    if("${Matlab_VERSION_STRING_INTERNAL}" STREQUAL "")
-      list(APPEND _matlab_possible_roots "NOTFOUND" ${Matlab_ROOT_DIR}) # empty version
-    else()
-      list(APPEND _matlab_possible_roots ${Matlab_VERSION_STRING_INTERNAL} ${Matlab_ROOT_DIR}) # cached version
-    endif()
-  endif()
-
-
-else()
-
-  # if the user does not specify the possible installation root, we look for
-  # one installation using the appropriate heuristics
-
-  if(WIN32)
-
-    # On WIN32, we look for Matlab installation in the registry
-    # if unsuccessful, we look for all known revision and filter the existing
-    # ones.
-
-    # testing if we are able to extract the needed information from the registry
-    set(_matlab_versions_from_registry)
-
-    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
-      set(_matlab_win64 ON)
-    else()
-      set(_matlab_win64 OFF)
-    endif()
-
-    matlab_extract_all_installed_versions_from_registry(_matlab_win64 _matlab_versions_from_registry)
-
-    # the returned list is empty, doing the search on all known versions
-    if(NOT _matlab_versions_from_registry)
-
-      if(MATLAB_FIND_DEBUG)
-        message(STATUS "[MATLAB] Search for Matlab from the registry unsuccessful, testing all supported versions")
-      endif()
-
-      extract_matlab_versions_from_registry_brute_force(_matlab_versions_from_registry)
-    endif()
-
-    # filtering the results with the registry keys
-    matlab_get_all_valid_matlab_roots_from_registry("${_matlab_versions_from_registry}" _matlab_possible_roots)
-    unset(_matlab_versions_from_registry)
-
-  elseif(APPLE)
-
-    # on mac, we look for the /Application paths
-    # this corresponds to the behaviour on Windows. On Linux, we do not have
-    # any other guess.
-    matlab_get_supported_releases(_matlab_releases)
-    if(MATLAB_FIND_DEBUG)
-      message(STATUS "[MATLAB] Matlab supported versions ${_matlab_releases}. If more version should be supported "
-                   "the variable MATLAB_ADDITIONAL_VERSIONS can be set according to the documentation")
-    endif()
-
-    foreach(_matlab_current_release IN LISTS _matlab_releases)
-      set(_matlab_full_string "/Applications/MATLAB_${_matlab_current_release}.app")
-      if(EXISTS ${_matlab_full_string})
-        set(_matlab_current_version)
-        matlab_get_version_from_release_name("${_matlab_current_release}" _matlab_current_version)
-        if(MATLAB_FIND_DEBUG)
-          message(STATUS "[MATLAB] Found version ${_matlab_current_release} (${_matlab_current_version}) in ${_matlab_full_string}")
-        endif()
-        list(APPEND _matlab_possible_roots ${_matlab_current_version} ${_matlab_full_string})
-        unset(_matlab_current_version)
-      endif()
-
-      unset(_matlab_full_string)
-    endforeach(_matlab_current_release)
-
-    unset(_matlab_current_release)
-    unset(_matlab_releases)
-
-  endif()
-
-endif()
-
-
-
-list(LENGTH _matlab_possible_roots _numbers_of_matlab_roots)
-if(_numbers_of_matlab_roots EQUAL 0)
-  # if we have not found anything, we fall back on the PATH
-
-
-  # At this point, we have no other choice than trying to find it from PATH.
-  # If set by the user, this wont change
-  find_program(
-    _matlab_main_tmp
-    NAMES matlab)
-
-
-  if(_matlab_main_tmp)
-    # we then populate the list of roots, with empty version
-    if(MATLAB_FIND_DEBUG)
-      message(STATUS "[MATLAB] matlab found from PATH: ${_matlab_main_tmp}")
-    endif()
-
-    # resolve symlinks
-    get_filename_component(_matlab_current_location "${_matlab_main_tmp}" REALPATH)
-
-    # get the directory (the command below has to be run twice)
-    # this will be the matlab root
-    get_filename_component(_matlab_current_location "${_matlab_current_location}" DIRECTORY)
-    get_filename_component(_matlab_current_location "${_matlab_current_location}" DIRECTORY) # Matlab should be in bin
-
-    list(APPEND _matlab_possible_roots "NOTFOUND" ${_matlab_current_location})
-
-    unset(_matlab_current_location)
-
-  endif()
-  unset(_matlab_main_tmp CACHE)
-
-endif()
-
-
-
-
-
-if(MATLAB_FIND_DEBUG)
-  message(STATUS "[MATLAB] Matlab root folders are ${_matlab_possible_roots}")
-endif()
-
-
-
-
-
-# take the first possible Matlab root
-list(LENGTH _matlab_possible_roots _numbers_of_matlab_roots)
-set(Matlab_VERSION_STRING "NOTFOUND")
-if(_numbers_of_matlab_roots GREATER 0)
-  list(GET _matlab_possible_roots 0 Matlab_VERSION_STRING)
-  list(GET _matlab_possible_roots 1 Matlab_ROOT_DIR)
-
-  # adding a warning in case of ambiguity
-  if(_numbers_of_matlab_roots GREATER 2 AND MATLAB_FIND_DEBUG)
-    message(WARNING "[MATLAB] Found several distributions of Matlab. Setting the current version to ${Matlab_VERSION_STRING} (located ${Matlab_ROOT_DIR})."
-                    " If this is not the desired behaviour, provide the -DMatlab_ROOT_DIR=... on the command line")
-  endif()
-endif()
-
-
-# check if the root changed wrt. the previous defined one, if so
-# clear all the cached variables for being able to reconfigure properly
-if(DEFINED Matlab_ROOT_DIR_LAST_CACHED)
-
-  if(NOT Matlab_ROOT_DIR_LAST_CACHED STREQUAL Matlab_ROOT_DIR)
-    set(_Matlab_cached_vars
-        Matlab_INCLUDE_DIRS
-        Matlab_MEX_LIBRARY
-        Matlab_MEX_COMPILER
-        Matlab_MAIN_PROGRAM
-        Matlab_MX_LIBRARY
-        Matlab_ENG_LIBRARY
-        Matlab_MAT_LIBRARY
-        Matlab_MEX_EXTENSION
-        Matlab_SIMULINK_INCLUDE_DIR
-
-        # internal
-        Matlab_MEXEXTENSIONS_PROG
-        Matlab_ROOT_DIR_LAST_CACHED
-        #Matlab_PROG_VERSION_STRING_AUTO_DETECT
-        Matlab_VERSION_STRING_INTERNAL
-        )
-    foreach(_var IN LISTS _Matlab_cached_vars)
-      if(DEFINED ${_var})
-        unset(${_var} CACHE)
-      endif()
-    endforeach()
-  endif()
-endif()
-
-set(Matlab_ROOT_DIR_LAST_CACHED ${Matlab_ROOT_DIR} CACHE INTERNAL "last Matlab root dir location")
-set(Matlab_ROOT_DIR ${Matlab_ROOT_DIR} CACHE PATH "Matlab installation root path" FORCE)
-
-# Fix the version, in case this one is NOTFOUND
-_Matlab_get_version_from_root(
-  "${Matlab_ROOT_DIR}"
-  ${Matlab_VERSION_STRING}
-  Matlab_VERSION_STRING
-)
-
-
-
-
-if(MATLAB_FIND_DEBUG)
-  message(STATUS "[MATLAB] Current version is ${Matlab_VERSION_STRING} located ${Matlab_ROOT_DIR}")
-endif()
-
-
-
-if(Matlab_ROOT_DIR)
-  file(TO_CMAKE_PATH ${Matlab_ROOT_DIR} Matlab_ROOT_DIR)
-endif()
-
-if(CMAKE_SIZEOF_VOID_P EQUAL 4)
-  set(_matlab_64Build FALSE)
-else()
-  set(_matlab_64Build TRUE)
-endif()
-
-if(APPLE)
-  set(_matlab_bin_prefix "mac") # i should be for intel
-  set(_matlab_bin_suffix_32bits "i")
-  set(_matlab_bin_suffix_64bits "i64")
-elseif(UNIX)
-  set(_matlab_bin_prefix "gln")
-  set(_matlab_bin_suffix_32bits "x86")
-  set(_matlab_bin_suffix_64bits "xa64")
-else()
-  set(_matlab_bin_prefix "win")
-  set(_matlab_bin_suffix_32bits "32")
-  set(_matlab_bin_suffix_64bits "64")
-endif()
-
-
-
-set(MATLAB_INCLUDE_DIR_TO_LOOK ${Matlab_ROOT_DIR}/extern/include)
-if(_matlab_64Build)
-  set(_matlab_current_suffix ${_matlab_bin_suffix_64bits})
-else()
-  set(_matlab_current_suffix ${_matlab_bin_suffix_32bits})
-endif()
-
-set(Matlab_BINARIES_DIR
-    ${Matlab_ROOT_DIR}/bin/${_matlab_bin_prefix}${_matlab_current_suffix})
-set(Matlab_EXTERN_LIBRARY_DIR
-    ${Matlab_ROOT_DIR}/extern/lib/${_matlab_bin_prefix}${_matlab_current_suffix})
-
-if(WIN32)
-  if(MINGW)
-    set(_matlab_lib_dir_for_search ${Matlab_EXTERN_LIBRARY_DIR}/mingw64)
-  else()
-    set(_matlab_lib_dir_for_search ${Matlab_EXTERN_LIBRARY_DIR}/microsoft)
-  endif()
-  set(_matlab_lib_prefix_for_search "lib")
-else()
-  set(_matlab_lib_dir_for_search ${Matlab_BINARIES_DIR})
-  set(_matlab_lib_prefix_for_search "lib")
-endif()
-
-unset(_matlab_64Build)
-
-
-if(NOT DEFINED Matlab_MEX_EXTENSION)
-  set(_matlab_mex_extension "")
-  matlab_get_mex_suffix("${Matlab_ROOT_DIR}" _matlab_mex_extension)
-
-  # This variable goes to the cache.
-  set(Matlab_MEX_EXTENSION ${_matlab_mex_extension} CACHE STRING "Extensions for the mex targets (automatically given by Matlab)")
-  unset(_matlab_mex_extension)
-endif()
-
-
-if(MATLAB_FIND_DEBUG)
-  message(STATUS "[MATLAB] [DEBUG]_matlab_lib_prefix_for_search = ${_matlab_lib_prefix_for_search} | _matlab_lib_dir_for_search = ${_matlab_lib_dir_for_search}")
-endif()
-
-
-
-# internal
-# This small stub around find_library is to prevent any pollution of CMAKE_FIND_LIBRARY_PREFIXES in the global scope.
-# This is the function to be used below instead of the find_library directives.
-function(_Matlab_find_library _matlab_library_prefix)
-  set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} ${_matlab_library_prefix})
-  find_library(${ARGN})
-endfunction()
-
-
-set(_matlab_required_variables)
-
-
-# the MEX library/header are required
-find_path(
-  Matlab_INCLUDE_DIRS
-  mex.h
-  PATHS ${MATLAB_INCLUDE_DIR_TO_LOOK}
-  NO_DEFAULT_PATH
-  )
-list(APPEND _matlab_required_variables Matlab_INCLUDE_DIRS)
-
-_Matlab_find_library(
-  ${_matlab_lib_prefix_for_search}
-  Matlab_MEX_LIBRARY
-  mex
-  PATHS ${_matlab_lib_dir_for_search}
-  NO_DEFAULT_PATH
-)
-
-list(APPEND _matlab_required_variables Matlab_MEX_LIBRARY)
-
-# the MEX extension is required
-list(APPEND _matlab_required_variables Matlab_MEX_EXTENSION)
-
-# the matlab root is required
-list(APPEND _matlab_required_variables Matlab_ROOT_DIR)
-
-# component Mex Compiler
-list(FIND Matlab_FIND_COMPONENTS MEX_COMPILER _matlab_find_mex_compiler)
-if(_matlab_find_mex_compiler GREATER -1)
-  find_program(
-    Matlab_MEX_COMPILER
-    "mex"
-    PATHS ${Matlab_BINARIES_DIR}
-    DOC "Matlab MEX compiler"
-    NO_DEFAULT_PATH
-  )
-  if(Matlab_MEX_COMPILER)
-    set(Matlab_MEX_COMPILER_FOUND TRUE)
-  endif()
-endif()
-unset(_matlab_find_mex_compiler)
-
-# component Matlab program
-list(FIND Matlab_FIND_COMPONENTS MAIN_PROGRAM _matlab_find_matlab_program)
-if(_matlab_find_matlab_program GREATER -1)
-  find_program(
-    Matlab_MAIN_PROGRAM
-    matlab
-    PATHS ${Matlab_ROOT_DIR} ${Matlab_ROOT_DIR}/bin
-    DOC "Matlab main program"
-    NO_DEFAULT_PATH
-  )
-  if(Matlab_MAIN_PROGRAM)
-    set(Matlab_MAIN_PROGRAM_FOUND TRUE)
-  endif()
-endif()
-unset(_matlab_find_matlab_program)
-
-# Component MX library
-list(FIND Matlab_FIND_COMPONENTS MX_LIBRARY _matlab_find_mx)
-if(_matlab_find_mx GREATER -1)
-  _Matlab_find_library(
-    ${_matlab_lib_prefix_for_search}
-    Matlab_MX_LIBRARY
-    mx
-    PATHS ${_matlab_lib_dir_for_search}
-    NO_DEFAULT_PATH
-  )
-  if(Matlab_MX_LIBRARY)
-    set(Matlab_MX_LIBRARY_FOUND TRUE)
-  endif()
-endif()
-unset(_matlab_find_mx)
-
-# Component ENG library
-list(FIND Matlab_FIND_COMPONENTS ENG_LIBRARY _matlab_find_eng)
-if(_matlab_find_eng GREATER -1)
-  _Matlab_find_library(
-    ${_matlab_lib_prefix_for_search}
-    Matlab_ENG_LIBRARY
-    eng
-    PATHS ${_matlab_lib_dir_for_search}
-    NO_DEFAULT_PATH
-  )
-  if(Matlab_ENG_LIBRARY)
-    set(Matlab_ENG_LIBRARY_FOUND TRUE)
-  endif()
-endif()
-unset(_matlab_find_eng)
-
-# Component MAT library
-list(FIND Matlab_FIND_COMPONENTS MAT_LIBRARY _matlab_find_mat)
-if(_matlab_find_mat GREATER -1)
-  _Matlab_find_library(
-    ${_matlab_lib_prefix_for_search}
-    Matlab_MAT_LIBRARY
-    mat
-    PATHS ${_matlab_lib_dir_for_search}
-    NO_DEFAULT_PATH
-  )
-  if(Matlab_MAT_LIBRARY)
-    set(Matlab_MAT_LIBRARY_FOUND TRUE)
-  endif()
-endif()
-unset(_matlab_find_mat)
-
-# Component Simulink
-list(FIND Matlab_FIND_COMPONENTS SIMULINK _matlab_find_simulink)
-if(_matlab_find_simulink GREATER -1)
-  find_path(
-    Matlab_SIMULINK_INCLUDE_DIR
-    simstruc.h
-    PATHS "${Matlab_ROOT_DIR}/simulink/include"
-    NO_DEFAULT_PATH
-    )
-  if(Matlab_SIMULINK_INCLUDE_DIR)
-    set(Matlab_SIMULINK_FOUND TRUE)
-    list(APPEND Matlab_INCLUDE_DIRS "${Matlab_SIMULINK_INCLUDE_DIR}")
-  endif()
-endif()
-unset(_matlab_find_simulink)
-
-unset(_matlab_lib_dir_for_search)
-
-set(Matlab_LIBRARIES ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY} ${Matlab_ENG_LIBRARY} ${Matlab_MAT_LIBRARY})
-
-find_package_handle_standard_args(
-  Matlab
-  FOUND_VAR Matlab_FOUND
-  REQUIRED_VARS ${_matlab_required_variables}
-  VERSION_VAR Matlab_VERSION_STRING
-  HANDLE_COMPONENTS)
-
-unset(_matlab_required_variables)
-unset(_matlab_bin_prefix)
-unset(_matlab_bin_suffix_32bits)
-unset(_matlab_bin_suffix_64bits)
-unset(_matlab_current_suffix)
-unset(_matlab_lib_dir_for_search)
-unset(_matlab_lib_prefix_for_search)
-
-if(Matlab_INCLUDE_DIRS AND Matlab_LIBRARIES)
-  mark_as_advanced(
-    Matlab_MEX_LIBRARY
-    Matlab_MX_LIBRARY
-    Matlab_ENG_LIBRARY
-    Matlab_MAT_LIBRARY
-    Matlab_INCLUDE_DIRS
-    Matlab_FOUND
-    Matlab_MAIN_PROGRAM
-    Matlab_MEXEXTENSIONS_PROG
-    Matlab_MEX_EXTENSION
-  )
-endif()

+ 0 - 198
cmake/LibiglDownloadExternal.cmake

@@ -1,198 +0,0 @@
-################################################################################
-include(DownloadProject)
-
-# With CMake 3.8 and above, we can hide warnings about git being in a
-# detached head by passing an extra GIT_CONFIG option.
-set(LIBIGL_EXTRA_OPTIONS TLS_VERIFY OFF)
-if(NOT (${CMAKE_VERSION} VERSION_LESS "3.8.0"))
-	list(APPEND LIBIGL_EXTRA_OPTIONS GIT_CONFIG advice.detachedHead=false)
-endif()
-
-# On CMake 3.6.3 and above, there is an option to use shallow clones of git repositories.
-# The shallow clone option only works with real tags, not SHA1, so we use a separate option.
-set(LIBIGL_BRANCH_OPTIONS)
-if(NOT (${CMAKE_VERSION} VERSION_LESS "3.6.3"))
-	# Disabled for now until we can make sure that it has no adverse effects
-	# (Downside is that the eigen mirror is huge again)
-	# list(APPEND LIBIGL_BRANCH_OPTIONS GIT_SHALLOW 1)
-endif()
-
-option(LIBIGL_SKIP_DOWNLOAD "Skip downloading external libraries" OFF)
-
-# Shortcut functions
-function(igl_download_project_aux name source)
-	if(NOT LIBIGL_SKIP_DOWNLOAD)
-		download_project(
-			PROJ         ${name}
-			SOURCE_DIR   "${source}"
-			DOWNLOAD_DIR "${LIBIGL_EXTERNAL}/.cache/${name}"
-			QUIET
-			${LIBIGL_EXTRA_OPTIONS}
-			${ARGN}
-		)
-	endif()
-endfunction()
-
-function(igl_download_project name)
-	igl_download_project_aux(${name} "${LIBIGL_EXTERNAL}/${name}" ${ARGN})
-endfunction()
-
-################################################################################
-
-## CGAL
-function(igl_download_cgal)
-	igl_download_project(cgal
-		GIT_REPOSITORY https://github.com/CGAL/cgal.git
-		GIT_TAG        f7c3c8212b56c0d6dae63787efc99093f4383415
-	)
-endfunction()
-
-## CoMISo
-function(igl_download_comiso)
-	igl_download_project(CoMISo
-		GIT_REPOSITORY https://github.com/libigl/CoMISo.git
-		GIT_TAG        d60aa4759fba76b0b793b1efb090b7a771dd7c56
-	)
-endfunction()
-
-## Cork
-function(igl_download_cork)
-	igl_download_project(cork
-		GIT_REPOSITORY https://github.com/libigl/cork.git
-		GIT_TAG        27ad8a285838f5a480d856429e39d3d56d4338f9
-	)
-endfunction()
-
-## Eigen
-set(LIBIGL_EIGEN_VERSION 3.3.7 CACHE STRING "Default version of Eigen used by libigl.")
-function(igl_download_eigen)
-	igl_download_project(eigen
-		GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
-		GIT_TAG        ${LIBIGL_EIGEN_VERSION}
-		${LIBIGL_BRANCH_OPTIONS}
-	)
-endfunction()
-
-## Embree
-function(igl_download_embree)
-	igl_download_project(embree
-		GIT_REPOSITORY https://github.com/embree/embree.git
-		GIT_TAG        v3.12.1
-		${LIBIGL_BRANCH_OPTIONS}
-	)
-endfunction()
-
-## glad
-function(igl_download_glad)
-	igl_download_project(glad
-		GIT_REPOSITORY https://github.com/libigl/libigl-glad.git
-		GIT_TAG        09b4969c56779f7ddf8e6176ec1873184aec890f
-	)
-endfunction()
-
-## GLFW
-function(igl_download_glfw)
-	igl_download_project(glfw
-		GIT_REPOSITORY https://github.com/glfw/glfw.git
-		GIT_TAG        3327050ca66ad34426a82c217c2d60ced61526b7
-		${LIBIGL_BRANCH_OPTIONS}
-	)
-endfunction()
-
-## ImGui
-function(igl_download_imgui)
-	igl_download_project(imgui
-		GIT_REPOSITORY https://github.com/ocornut/imgui.git
-		GIT_TAG        61b19489f1ba35934d9114c034b24eb5bff149e7 # 1.81 + patch for #1669
-		${LIBIGL_BRANCH_OPTIONS}
-	)
-	igl_download_project(libigl-imgui
-		GIT_REPOSITORY https://github.com/libigl/libigl-imgui.git
-		GIT_TAG        7e1053e750b0f4c129b046f4e455243cb7f804f3
-	)
-endfunction()
-
-## ImGuizmo
-function(igl_download_imguizmo)
-	igl_download_project(imguizmo
-		GIT_REPOSITORY https://github.com/CedricGuillemet/ImGuizmo.git
-		GIT_TAG        a23567269f6617342bcc112394bdad937b54b2d7
-		${LIBIGL_BRANCH_OPTIONS}
-	)
-endfunction()
-
-## pybind11
-function(igl_download_pybind11)
-	igl_download_project(pybind11
-		GIT_REPOSITORY https://github.com/pybind/pybind11.git
-		GIT_TAG        2d0507db43cd5a117f7843e053b17dffca114107
-	)
-endfunction()
-
-## stb_image
-function(igl_download_stb)
-	igl_download_project(stb
-		GIT_REPOSITORY https://github.com/libigl/libigl-stb.git
-		GIT_TAG        cd0fa3fcd90325c83be4d697b00214e029f94ca3
-	)
-endfunction()
-
-## TetGen
-function(igl_download_tetgen)
-	igl_download_project(tetgen
-		GIT_REPOSITORY https://github.com/libigl/tetgen.git
-		GIT_TAG        4f3bfba3997f20aa1f96cfaff604313a8c2c85b6
-	)
-endfunction()
-
-## TinyXML
-function(igl_download_tinyxml2)
-	igl_download_project(tinyxml2
-		GIT_REPOSITORY https://github.com/leethomason/tinyxml2.git
-		GIT_TAG        d175e9de0be0d4db75d0a8cf065599a435a87eb6
-	)
-endfunction()
-
-## Triangle
-function(igl_download_triangle)
-	igl_download_project(triangle
-		GIT_REPOSITORY https://github.com/libigl/triangle.git
-		GIT_TAG        3ee6cac2230f0fe1413879574f741c7b6da11221
-	)
-endfunction()
-
-## Catch2
-function(igl_download_catch2)
-	igl_download_project(catch2
-		GIT_REPOSITORY https://github.com/catchorg/Catch2.git
-		GIT_TAG        v2.11.0
-	)
-endfunction()
-
-## Predicates
-function(igl_download_predicates)
-	igl_download_project(predicates
-		GIT_REPOSITORY https://github.com/libigl/libigl-predicates.git
-		GIT_TAG        488242fa2b1f98a9c5bd1441297fb4a99a6a9ae4
-	)
-endfunction()
-
-################################################################################
-
-## Test data
-function(igl_download_test_data)
-	igl_download_project_aux(test_data
-		"${LIBIGL_EXTERNAL}/../tests/data"
-		GIT_REPOSITORY https://github.com/libigl/libigl-tests-data
-		GIT_TAG        19cedf96d70702d8b3a83eb27934780c542356fe
-	)
-endfunction()
-
-## Tutorial data
-function(igl_download_tutorial_data)
-	igl_download_project_aux(tutorial_data
-		"${LIBIGL_EXTERNAL}/../tutorial/data"
-		GIT_REPOSITORY https://github.com/libigl/libigl-tutorial-data
-		GIT_TAG        c1f9ede366d02e3531ecbaec5e3769312f31cccd
-	)
-endfunction()

+ 0 - 118
cmake/LibiglFolders.cmake

@@ -1,118 +0,0 @@
-# Sort projects inside the solution
-set_property(GLOBAL PROPERTY USE_FOLDERS ON)
-
-function(igl_folder_targets FOLDER_NAME)
-    foreach(target IN ITEMS ${ARGN})
-        if(TARGET ${target})
-            get_target_property(TYPE ${target} TYPE)
-            if(NOT (TYPE STREQUAL "INTERFACE_LIBRARY"))
-                set_target_properties(${target} PROPERTIES FOLDER "${FOLDER_NAME}")
-            endif()
-        endif()
-    endforeach()
-endfunction()
-
-function(igl_set_folders)
-
-igl_folder_targets("ThirdParty/Embree"
-    algorithms
-    embree
-    lexers
-    math
-    simd
-    sys
-    tasking
-)
-
-igl_folder_targets("ThirdParty"
-    CoMISo
-    glad
-    glfw
-    imgui
-    predicates
-    tetgen
-    tinyxml2
-    triangle
-)
-
-igl_folder_targets("Libigl"
-    igl
-    igl_comiso
-    igl_embree
-    igl_opengl
-    igl_opengl_glfw
-    igl_opengl_glfw_imgui
-    igl_png
-    igl_predicates
-    igl_stb_image
-    igl_tetgen
-    igl_triangle
-    igl_xml
-)
-
-igl_folder_targets("Unit Tests"
-    libigl_tests
-)
-
-igl_folder_targets("Tutorials"
-    101_FileIO_bin
-    102_DrawMesh_bin
-    103_Events_bin
-    104_Colors_bin
-    105_Overlays_bin
-    106_ViewerMenu_bin
-    107_MultipleMeshes_bin
-    108_MultipleViews_bin
-    201_Normals_bin
-    202_GaussianCurvature_bin
-    203_CurvatureDirections_bin
-    204_Gradient_bin
-    205_Laplacian_bin
-    206_GeodesicDistance_bin
-    301_Slice_bin
-    302_Sort_bin
-    303_LaplaceEquation_bin
-    304_LinearEqualityConstraints_bin
-    305_QuadraticProgramming_bin
-    306_EigenDecomposition_bin
-    401_BiharmonicDeformation_bin
-    402_PolyharmonicDeformation_bin
-    403_BoundedBiharmonicWeights_bin
-    404_DualQuaternionSkinning_bin
-    405_AsRigidAsPossible_bin
-    406_FastAutomaticSkinningTransformations_bin
-    407_BiharmonicCoordinates_bin
-    408_DirectDeltaMush_bin
-    501_HarmonicParam_bin
-    502_LSCMParam_bin
-    503_ARAPParam_bin
-    504_NRosyDesign_bin
-    505_MIQ_bin
-    506_FrameField_bin
-    507_Planarization_bin
-    601_Serialization_bin
-    604_Triangle_bin
-    605_Tetgen_bin
-    606_AmbientOcclusion_bin
-    607_ScreenCapture_bin
-    701_Statistics_bin
-    702_WindingNumber_bin
-    703_Decimation_bin
-    704_SignedDistance_bin
-    705_MarchingCubes_bin
-    706_FacetOrientation_bin
-    707_SweptVolume_bin
-    708_Picking_bin
-    709_SLIM_bin
-    710_SCAF_bin
-    711_Subdivision_bin
-    712_DataSmoothing_bin
-    713_ShapeUp_bin
-    714_MarchingTets_bin
-    715_MeshImplicitFunction_bin
-    716_HeatGeodesics_bin
-    718_IterativeClosestPoint_bin
-    719_ExplodedView_bin
-)
-
-endfunction()

+ 0 - 26
cmake/LibiglWindows.cmake

@@ -1,26 +0,0 @@
-if(MSVC)
-	option(IGL_STATIC_RUNTIME "Use libigl with the static MSVC runtime." OFF)
-	if(IGL_STATIC_RUNTIME)
-		message(STATUS "MSVC -> forcing use of statically-linked runtime.")
-		foreach(config ${CMAKE_CONFIGURATION_TYPES})
-			string(TOUPPER ${config} config)
-			string(REPLACE /MD /MT CMAKE_C_FLAGS_${config} "${CMAKE_C_FLAGS_${config}}")
-			string(REPLACE /MD /MT CMAKE_CXX_FLAGS_${config} "${CMAKE_CXX_FLAGS_${config}}")
-		endforeach()
-		string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
-	else()
-		message(STATUS "MSVC -> forcing use of dynamically-linked runtime.")
-		foreach(config ${CMAKE_CONFIGURATION_TYPES})
-			string(TOUPPER ${config} config)
-			string(REPLACE /MT /MD CMAKE_C_FLAGS_${config} "${CMAKE_C_FLAGS_${config}}")
-			string(REPLACE /MT /MD CMAKE_CXX_FLAGS_${config} "${CMAKE_CXX_FLAGS_${config}}")
-		endforeach()
-		string(REPLACE "/MTd" "/MDd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
-	endif()
-
-	# https://github.com/mozilla/sccache/issues/242
-	if(CMAKE_CXX_COMPILER_LAUNCHER STREQUAL "sccache")
-		string(REGEX REPLACE "/Z[iI7]" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
-		set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Z7")
-	endif()
-endif()

+ 95 - 0
cmake/find/FindGMP.cmake

@@ -0,0 +1,95 @@
+# Try to find the GNU Multiple Precision Arithmetic Library (GMP)
+# See http://gmplib.org/
+
+if(${CMAKE_VERSION} VERSION_LESS "3.18.0")
+    set(REQUIRED_FLAG "")
+else()
+    set(REQUIRED_FLAG REQUIRED)
+endif()
+
+# On Windows, we must use the pre-compiled versions downloaded with libigl
+if(WIN32)
+    set(NO_DEFAULT_FLAG NO_DEFAULT_PATH)
+else()
+    set(NO_DEFAULT_FLAG "")
+endif()
+
+find_path(GMP_INCLUDES
+    NAMES
+        gmp.h
+    PATHS
+        ENV GMP_DIR
+        ${INCLUDE_INSTALL_DIR}
+    PATH_SUFFIXES
+        include
+    ${REQUIRED_FLAG}
+    ${NO_DEFAULT_FLAG}
+)
+
+find_library(GMP_LIBRARIES
+    NAMES
+        gmp
+        libgmp-10
+    PATHS
+        ENV GMP_DIR
+        ${LIB_INSTALL_DIR}
+    PATH_SUFFIXES
+        lib
+    ${REQUIRED_FLAG}
+    ${NO_DEFAULT_FLAG}
+)
+
+set(GMP_EXTRA_VARS "")
+if(WIN32)
+    # Find dll file and set IMPORTED_LOCATION to the .dll file
+    find_file(GMP_RUNTIME_LIB
+        NAMES
+            gmp.dll
+            libgmp-10.dll
+        PATHS
+            ENV GMP_DIR
+            ${LIB_INSTALL_DIR}
+        PATH_SUFFIXES
+            lib
+        ${REQUIRED_FLAG}
+        ${NO_DEFAULT_FLAG}
+    )
+    list(APPEND GMP_EXTRA_VARS GMP_RUNTIME_LIB)
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GMP
+    REQUIRED_VARS
+        GMP_INCLUDES
+        GMP_LIBRARIES
+        ${GMP_EXTRA_VARS}
+    REASON_FAILURE_MESSAGE
+        "GMP is not installed on your system. Either install GMP using your preferred package manager, or disable libigl modules that depend on GMP, such as CGAL. See LibiglOptions.cmake.sample for configuration options. Do not forget to delete your <build>/CMakeCache.txt for the changes to take effect."
+)
+mark_as_advanced(GMP_INCLUDES GMP_LIBRARIES)
+
+if(GMP_INCLUDES AND GMP_LIBRARIES AND NOT TARGET gmp::gmp)
+    if(GMP_RUNTIME_LIB)
+        add_library(gmp::gmp SHARED IMPORTED)
+    else()
+        add_library(gmp::gmp UNKNOWN IMPORTED)
+    endif()
+
+    # Set public header location and link language
+    set_target_properties(gmp::gmp PROPERTIES
+        IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+        INTERFACE_INCLUDE_DIRECTORIES "${GMP_INCLUDES}"
+    )
+
+    # Set lib location. On Windows we specify both the .lib and the .dll paths
+    if(GMP_RUNTIME_LIB)
+        set_target_properties(gmp::gmp PROPERTIES
+            IMPORTED_IMPLIB "${GMP_LIBRARIES}"
+            IMPORTED_LOCATION "${GMP_RUNTIME_LIB}"
+        )
+    else()
+        set_target_properties(gmp::gmp PROPERTIES
+            IMPORTED_LOCATION "${GMP_LIBRARIES}"
+        )
+    endif()
+endif()

+ 0 - 0
cmake/FindMOSEK.cmake → cmake/find/FindMOSEK.cmake


+ 95 - 0
cmake/find/FindMPFR.cmake

@@ -0,0 +1,95 @@
+# Try to find the MPFR library
+# See http://www.mpfr.org/
+
+if(${CMAKE_VERSION} VERSION_LESS "3.18.0")
+    set(REQUIRED_FLAG "")
+else()
+    set(REQUIRED_FLAG REQUIRED)
+endif()
+
+# On Windows, we must use the pre-compiled versions downloaded with libigl
+if(WIN32)
+    set(NO_DEFAULT_FLAG NO_DEFAULT_PATH)
+else()
+    set(NO_DEFAULT_FLAG "")
+endif()
+
+find_path(MPFR_INCLUDES
+    NAMES
+        mpfr.h
+    PATHS
+        ENV MPFR_DIR
+        ${INCLUDE_INSTALL_DIR}
+    PATH_SUFFIXES
+        include
+    ${REQUIRED_FLAG}
+    ${NO_DEFAULT_FLAG}
+)
+
+find_library(MPFR_LIBRARIES
+    NAMES
+        mpfr
+        libmpfr-4
+    PATHS
+        ENV MPFR_DIR
+        ${LIB_INSTALL_DIR}
+    PATH_SUFFIXES
+        lib
+    ${REQUIRED_FLAG}
+    ${NO_DEFAULT_FLAG}
+)
+
+set(MPFR_EXTRA_VARS "")
+if(WIN32)
+    # Find dll file and set IMPORTED_LOCATION to the .dll file
+    find_file(MPFR_RUNTIME_LIB
+        NAMES
+            mpfr.dll
+            libmpfr-4.dll
+        PATHS
+            ENV MPFR_DIR
+            ${LIB_INSTALL_DIR}
+        PATH_SUFFIXES
+            lib
+        ${REQUIRED_FLAG}
+        ${NO_DEFAULT_FLAG}
+    )
+    list(APPEND MPFR_EXTRA_VARS MPFR_RUNTIME_LIB)
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(MPFR
+    REQUIRED_VARS
+        MPFR_INCLUDES
+        MPFR_LIBRARIES
+        ${MPFR_EXTRA_VARS}
+    REASON_FAILURE_MESSAGE
+        "MPFR is not installed on your system. Either install MPFR using your preferred package manager, or disable libigl modules that depend on MPFR, such as CGAL. See LibiglOptions.cmake.sample for configuration options. Do not forget to delete your <build>/CMakeCache.txt for the changes to take effect."
+)
+mark_as_advanced(MPFR_INCLUDES MPFR_LIBRARIES)
+
+if(MPFR_INCLUDES AND MPFR_LIBRARIES AND NOT TARGET mpfr::mpfr)
+    if(MPFR_RUNTIME_LIB)
+        add_library(mpfr::mpfr SHARED IMPORTED)
+    else()
+        add_library(mpfr::mpfr UNKNOWN IMPORTED)
+    endif()
+
+    # Set public header location and link language
+    set_target_properties(mpfr::mpfr PROPERTIES
+        IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+        INTERFACE_INCLUDE_DIRECTORIES "${MPFR_INCLUDES}"
+    )
+
+    # Set lib location. On Windows we specify both the .lib and the .dll paths
+    if(MPFR_RUNTIME_LIB)
+        set_target_properties(mpfr::mpfr PROPERTIES
+            IMPORTED_IMPLIB "${MPFR_LIBRARIES}"
+            IMPORTED_LOCATION "${MPFR_RUNTIME_LIB}"
+        )
+    else()
+        set_target_properties(mpfr::mpfr PROPERTIES
+            IMPORTED_LOCATION "${MPFR_LIBRARIES}"
+        )
+    endif()
+endif()

+ 75 - 0
cmake/igl/igl_add_library.cmake

@@ -0,0 +1,75 @@
+# Creates a CMake target for a given libigl module. This convenience function also defines common
+# compilation flags, as well as installation rules for the target. Target sources and dependencies
+# need to be added separately.
+function(igl_add_library module_name)
+    # Check if category is `copyleft` or `restricted`
+    if(${module_name} MATCHES "^igl_copyleft")
+        set(suffix "_copyleft")
+    elseif(${module_name} MATCHES "^igl_restricted")
+        set(suffix "_restricted")
+    else()
+        set(suffix "")
+    endif()
+
+    # Check module name
+    if(NOT ${module_name} MATCHES "^igl_")
+        message(FATAL_ERROR "Libigl module name should start with 'igl_'")
+    endif()
+    string(REPLACE "igl${suffix}_" "" module_shortname ${module_name})
+
+    # Define target
+    if(LIBIGL_USE_STATIC_LIBRARY)
+        add_library(${module_name} STATIC)
+    else()
+        add_library(${module_name} INTERFACE)
+    endif()
+
+    # Alias target name
+    message(STATUS "Creating target: igl${suffix}::${module_shortname} (${module_name})")
+    add_library(igl${suffix}::${module_shortname} ALIAS ${module_name})
+
+    # Compile definitions
+    if(LIBIGL_USE_STATIC_LIBRARY)
+        target_compile_definitions(${module_name} ${IGL_SCOPE} -DIGL_STATIC_LIBRARY)
+    endif()
+
+    # C++11 features
+    target_compile_features(${module_name} ${IGL_SCOPE} cxx_std_11)
+
+    # Other compilation flags
+    if(MSVC)
+        # Enable parallel compilation for Visual Studio
+        target_compile_options(${module_name} ${IGL_SCOPE} $<$<COMPILE_LANGUAGE:CXX>:/MP> $<$<COMPILE_LANGUAGE:CXX>:/bigobj>)
+        target_compile_definitions(${module_name} ${IGL_SCOPE} -DNOMINMAX)
+
+        # Silencing some compilation warnings
+        if(LIBIGL_USE_STATIC_LIBRARY)
+            target_compile_options(${module_name} PRIVATE
+                # Type conversion warnings. These can be fixed with some effort and possibly more verbose code.
+                /wd4267 # conversion from 'size_t' to 'type', possible loss of data
+                /wd4244 # conversion from 'type1' to 'type2', possible loss of data
+                /wd4018 # signed/unsigned mismatch
+                /wd4305 # truncation from 'double' to 'float'
+                # This one is from template instantiations generated by autoexplicit.sh:
+                /wd4667 # no function template defined that matches forced instantiation ()
+                # This one is easy to fix, just need to switch to safe version of C functions
+                /wd4996 # this function or variable may be unsafe
+                # This one is when using bools in adjacency matrices
+                /wd4804 #'+=': unsafe use of type 'bool' in operation
+            )
+        endif()
+    endif()
+
+    # Generate position independent code
+    if(LIBIGL_POSITION_INDEPENDENT_CODE)
+        set_target_properties(${module_name} PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE ON)
+        if(LIBIGL_USE_STATIC_LIBRARY)
+            set_target_properties(${module_name} PROPERTIES POSITION_INDEPENDENT_CODE ON)
+        endif()
+    endif()
+
+    # Folder for IDE
+    if(LIBIGL_USE_STATIC_LIBRARY OR CMAKE_VERSION VERSION_GREATER_EQUAL 3.19.0)
+        set_target_properties(${module_name} PROPERTIES FOLDER "Libigl")
+    endif()
+endfunction()

+ 51 - 0
cmake/igl/igl_add_test.cmake

@@ -0,0 +1,51 @@
+function(igl_add_test module_name)
+    if(NOT LIBIGL_BUILD_TESTS)
+        return()
+    endif()
+
+    if(NOT TARGET ${module_name})
+        message(FATAL_ERROR "'${module_name}' is not a CMake target")
+    endif()
+
+    # Check if category is `copyleft` or `restricted`
+    if(${module_name} MATCHES "^igl_copyleft")
+        set(suffix "_copyleft")
+    elseif(${module_name} MATCHES "^igl_restricted")
+        set(suffix "_restricted")
+    else()
+        set(suffix "")
+    endif()
+
+    # Create test executable
+    add_executable(test_${module_name}
+        ${PROJECT_SOURCE_DIR}/tests/main.cpp
+        ${PROJECT_SOURCE_DIR}/tests/test_common.h
+        ${ARGN}
+    )
+
+    # Include headers
+    target_include_directories(test_${module_name} PUBLIC ${PROJECT_SOURCE_DIR}/tests)
+
+    # Compile definitions
+    target_compile_definitions(test_${module_name} PUBLIC CATCH_CONFIG_ENABLE_BENCHMARKING)
+
+    # Dependencies
+    include(catch2)
+    include(libigl_tests_data)
+    target_link_libraries(test_${module_name} PUBLIC
+        ${module_name}
+        igl::tests_data
+        Catch2::Catch2
+    )
+
+    # IDE Folder
+    set_target_properties(test_${module_name} PROPERTIES FOLDER Libigl_Tests)
+
+    # Output directory
+    set_target_properties(test_${module_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests")
+
+    # Register tests
+    FetchContent_GetProperties(catch2)
+    include("${catch2_SOURCE_DIR}/contrib/Catch.cmake")
+    catch_discover_tests(test_${module_name})
+endfunction()

+ 18 - 0
cmake/igl/igl_add_tutorial.cmake

@@ -0,0 +1,18 @@
+function(igl_add_tutorial name)
+    # Only create tutorial if dependencies have been enabled in the current build
+    foreach(module IN ITEMS ${ARGN})
+        if(NOT TARGET ${module})
+            return()
+        endif()
+    endforeach()
+
+    message(STATUS "Creating libigl tutorial: ${name}")
+    add_executable(${name} ${CMAKE_CURRENT_SOURCE_DIR}/${name}/main.cpp)
+    target_link_libraries(${name} PRIVATE
+        igl::core
+        igl::tutorial_data
+        ${ARGN}
+    )
+
+    set_target_properties(${name} PROPERTIES FOLDER Libigl_Tutorials)
+endfunction()

+ 97 - 0
cmake/igl/igl_copy_dll.cmake

@@ -0,0 +1,97 @@
+# Transitively list all link libraries of a target (recursive call)
+function(igl_get_dependencies_recursive OUTPUT_VARIABLE TARGET)
+    get_target_property(_aliased ${TARGET} ALIASED_TARGET)
+    if(_aliased)
+        set(TARGET ${_aliased})
+    endif()
+
+    get_target_property(_IMPORTED ${TARGET} IMPORTED)
+    get_target_property(_TYPE ${TARGET} TYPE)
+    if(_IMPORTED OR (${_TYPE} STREQUAL "INTERFACE_LIBRARY"))
+        get_target_property(TARGET_DEPENDENCIES ${TARGET} INTERFACE_LINK_LIBRARIES)
+    else()
+        get_target_property(TARGET_DEPENDENCIES ${TARGET} LINK_LIBRARIES)
+    endif()
+
+    # MKL-specific list of runtime dependencies
+    get_property(RUNTIME_DEPENDENCIES TARGET ${TARGET} PROPERTY mkl_RUNTIME_DEPENDENCIES)
+    if(RUNTIME_DEPENDENCIES)
+        list(APPEND TARGET_DEPENDENCIES ${RUNTIME_DEPENDENCIES})
+    endif()
+
+    set(VISITED_TARGETS ${${OUTPUT_VARIABLE}})
+    foreach(DEPENDENCY IN ITEMS ${TARGET_DEPENDENCIES})
+        if(TARGET ${DEPENDENCY})
+            get_target_property(_aliased ${DEPENDENCY} ALIASED_TARGET)
+            if(_aliased)
+                set(DEPENDENCY ${_aliased})
+            endif()
+
+            if(NOT (DEPENDENCY IN_LIST VISITED_TARGETS))
+                list(APPEND VISITED_TARGETS ${DEPENDENCY})
+                igl_get_dependencies_recursive(VISITED_TARGETS ${DEPENDENCY})
+            endif()
+        endif()
+    endforeach()
+    set(${OUTPUT_VARIABLE} ${VISITED_TARGETS} PARENT_SCOPE)
+endfunction()
+
+# Transitively list all link libraries of a target
+function(igl_get_dependencies OUTPUT_VARIABLE TARGET)
+    set(DISCOVERED_TARGETS "")
+    igl_get_dependencies_recursive(DISCOVERED_TARGETS ${TARGET})
+    set(${OUTPUT_VARIABLE} ${DISCOVERED_TARGETS} PARENT_SCOPE)
+endfunction()
+
+# Copy .dll dependencies to a target executable's folder. This function must be called *after* all the CMake
+# dependencies of the executable target have been defined, otherwise some .dlls might not be copied to the target
+# folder.
+function(igl_copy_dll target)
+    if(NOT WIN32)
+        return()
+    endif()
+
+    # Sanity checks
+    get_target_property(TYPE ${target} TYPE)
+    if(NOT ${TYPE} STREQUAL "EXECUTABLE")
+        message(FATAL_ERROR "igl_copy_dll() was called on a non-executable target: ${target}")
+    endif()
+
+    # Create a custom command to do the actual copy. This needs to be executed before Catch2's POST_BUILD command,
+    # so we define this as a PRE_LINK command for the executable target.
+    add_custom_command(
+        TARGET ${target}
+        PRE_LINK
+        COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_BINARY_DIR}/runtime_deps/copy_dll_${target}_$<CONFIG>.cmake"
+        COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/runtime_deps/copy_dll_${target}_$<CONFIG>.cmake"
+        COMMENT "Copying dlls for target ${target}"
+    )
+
+    # Retrieve all target dependencies
+    igl_get_dependencies(TARGET_DEPENDENCIES ${target})
+
+    # Iterate over dependencies, and create a copy rule for each .dll that we find
+    set(COPY_SCRIPT_CONTENT "")
+    foreach(DEPENDENCY IN ITEMS ${TARGET_DEPENDENCIES})
+        get_target_property(TYPE ${DEPENDENCY} TYPE)
+        if(NOT (${TYPE} STREQUAL "SHARED_LIBRARY" OR ${TYPE} STREQUAL "MODULE_LIBRARY"))
+            continue()
+        endif()
+
+        # Instruction to copy target file if it exists
+        string(APPEND COPY_SCRIPT_CONTENT
+            "if(EXISTS \"$<TARGET_FILE:${DEPENDENCY}>\")\n    "
+                "execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "
+                "\"$<TARGET_FILE:${DEPENDENCY}>\" "
+                "\"$<TARGET_FILE_DIR:${target}>/$<TARGET_FILE_NAME:${DEPENDENCY}>\")\n"
+            "endif()\n"
+        )
+    endforeach()
+
+    # Finally generate one script for each configuration supported by this generator
+    message(STATUS "Populating copy rules for target: ${target}")
+    file(GENERATE
+        OUTPUT ${CMAKE_BINARY_DIR}/runtime_deps/copy_dll_${target}_$<CONFIG>.cmake
+        CONTENT "${COPY_SCRIPT_CONTENT}"
+    )
+endfunction()

+ 45 - 0
cmake/igl/igl_include.cmake

@@ -0,0 +1,45 @@
+# Helper functions to include libigl modules
+function(_igl_include_full prefix name force)
+    string(TOUPPER "${prefix}" prefix_uc)
+    string(TOUPPER "${name}" name_uc)
+    if(prefix_uc)
+        string(PREPEND prefix_uc _)
+    endif()
+    string(TOLOWER "${prefix_uc}" prefix_lc)
+
+    if(TARGET igl${prefix_lc}::${name})
+        # Target already exists, skip
+        return()
+    endif()
+
+    if(${force} AND NOT ${name} STREQUAL "core")
+        message(STATUS "Forcing include of libigl module: ${name}")
+    endif()
+
+    # Include igl target definition
+    if(LIBIGL${prefix_uc}_WITH_${name_uc} OR ${force})
+        include(${PROJECT_SOURCE_DIR}/cmake/igl/modules/${prefix}/${name}.cmake)
+    endif()
+endfunction()
+
+# Include module only if CMake option is provided
+function(igl_include_optional name)
+    if(ARGC GREATER_EQUAL 2)
+        # Two args given: prefix + name
+        _igl_include_full(${name} ${ARGV1} FALSE)
+    else()
+        # Only one arg given: prefix (which contains module name)
+        _igl_include_full("" ${name} FALSE)
+    endif()
+endfunction()
+
+# Include module only unconditionally (e.g. if module is a dependency of another module)
+function(igl_include name)
+    if(ARGC GREATER_EQUAL 2)
+        # Two args given: prefix + name
+        _igl_include_full(${name} ${ARGV1} TRUE)
+    else()
+        # Only one arg given: prefix (which contains module name)
+        _igl_include_full("" ${name} TRUE)
+    endif()
+endfunction()

+ 63 - 0
cmake/igl/igl_install.cmake

@@ -0,0 +1,63 @@
+function(igl_install module_name)
+    if(NOT LIBIGL_INSTALL)
+        return()
+    endif()
+
+    # Check if category is `copyleft` or `restricted`
+    if(${module_name} MATCHES "^igl_copyleft")
+        set(suffix "_copyleft")
+    elseif(${module_name} MATCHES "^igl_restricted")
+        set(suffix "_restricted")
+    else()
+        set(suffix "")
+    endif()
+
+    ########################
+    # Install CMake target #
+    ########################
+
+    set_property(TARGET ${module_name} PROPERTY EXPORT_NAME ${module_export})
+
+    include(GNUInstallDirs)
+    install(TARGETS ${module_name}
+        EXPORT LibiglTargets${suffix}
+        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+                COMPONENT LibiglRuntime
+        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+                COMPONENT          LibiglRuntime
+                NAMELINK_COMPONENT LibiglDevelopment
+        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+                COMPONENT LibiglRuntime
+        PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+                COMPONENT LibiglDevelopment
+        INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+    )
+
+    ###################
+    # Install headers #
+    ###################
+
+    # TODO: When moving module definition to their own CMakeLists.txt, we should
+    # refactor this to use the folder where the target was defined (via the
+    # target property SOURCE_DIR).
+    set(target_include_dir ${PROJECT_SOURCE_DIR}/include)
+    foreach(source_path IN ITEMS ${ARGN})
+        # Filter out .cpp files in "static lib" mode
+        if(LIBIGL_USE_STATIC_LIBRARY)
+            get_filename_component(extension ${source_path} LAST_EXT)
+            if(extension MATCHES ".cpp")
+                continue()
+            endif()
+        endif()
+
+        # Compute relative path to copy
+        get_filename_component(source_directory ${source_path} DIRECTORY)
+        file(RELATIVE_PATH source_subdir ${target_include_dir} ${source_directory})
+
+        # Create install rule to copy specific header
+        install(
+            FILES ${source_path}
+            DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${source_subdir}
+        )
+    endforeach()
+endfunction()

+ 8 - 0
cmake/igl/igl_target_sources.cmake

@@ -0,0 +1,8 @@
+function(igl_target_sources module_name)
+    if(${CMAKE_VERSION} VERSION_LESS 3.19 AND NOT LIBIGL_USE_STATIC_LIBRARY)
+        # Old approach: defines a dummy custom target for the IDE
+        add_custom_target(${module_name}_ SOURCES ${ARGN})
+    else()
+        target_sources(${module_name} PRIVATE ${ARGN})
+    endif()
+endfunction()

+ 7 - 0
cmake/igl/igl_windows.cmake

@@ -0,0 +1,7 @@
+if(MSVC)
+	# https://github.com/mozilla/sccache/issues/242
+	if(CMAKE_CXX_COMPILER_LAUNCHER STREQUAL "sccache")
+		string(REGEX REPLACE "/Z[iI7]" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
+		set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Z7")
+	endif()
+endif()

+ 3 - 0
cmake/igl/libigl-config.cmake.in

@@ -0,0 +1,3 @@
+@PACKAGE_INIT@
+
+check_required_components(Libigl)

+ 34 - 0
cmake/igl/modules/copyleft/cgal.cmake

@@ -0,0 +1,34 @@
+# 1. Define module
+igl_add_library(igl_copyleft_cgal)
+
+# 2. Include headers
+include(GNUInstallDirs)
+target_include_directories(igl_copyleft_cgal ${IGL_SCOPE}
+    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+# 3. Target sources
+file(GLOB INC_FILES "${PROJECT_SOURCE_DIR}/include/igl/copyleft/cgal/*.h")
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/include/igl/copyleft/cgal/*.cpp")
+igl_target_sources(igl_copyleft_cgal ${INC_FILES} ${SRC_FILES})
+
+# 4. Dependencies
+include(cgal)
+igl_include(copyleft core)
+target_link_libraries(igl_copyleft_cgal ${IGL_SCOPE}
+    igl::core
+    igl_copyleft::core
+    CGAL::CGAL
+    CGAL::CGAL_Core
+)
+
+# 5. Unit tests
+file(GLOB SRC_FILES
+    "${PROJECT_SOURCE_DIR}/tests/include/igl/copyleft/boolean/*.cpp"
+    "${PROJECT_SOURCE_DIR}/tests/include/igl/copyleft/cgal/*.cpp"
+)
+igl_add_test(igl_copyleft_cgal ${SRC_FILES})
+if(TARGET test_igl_copyleft_cgal)
+    igl_copy_dll(test_igl_copyleft_cgal)
+endif()

+ 27 - 0
cmake/igl/modules/copyleft/comiso.cmake

@@ -0,0 +1,27 @@
+# 1. Define module
+igl_add_library(igl_copyleft_comiso)
+
+# 2. Include headers
+include(GNUInstallDirs)
+target_include_directories(igl_copyleft_comiso ${IGL_SCOPE}
+    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+# 3. Target sources
+file(GLOB INC_FILES "${PROJECT_SOURCE_DIR}/include/igl/copyleft/comiso/*.h")
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/include/igl/copyleft/comiso/*.cpp")
+igl_target_sources(igl_copyleft_comiso ${INC_FILES} ${SRC_FILES})
+
+# 4. Dependencies
+include(comiso)
+igl_include(copyleft core)
+target_link_libraries(igl_copyleft_comiso ${IGL_SCOPE}
+    igl::core
+    igl_copyleft::core
+    CoMISo::CoMISo
+)
+
+# 5. Unit tests
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/tests/include/igl/copyleft/comiso/*.cpp")
+igl_add_test(igl_copyleft_comiso ${SRC_FILES})

+ 19 - 0
cmake/igl/modules/copyleft/core.cmake

@@ -0,0 +1,19 @@
+# 1. Define module
+igl_add_library(igl_copyleft_core)
+
+# 2. Include headers
+include(GNUInstallDirs)
+target_include_directories(igl_copyleft_core ${IGL_SCOPE}
+    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+# 3. Target sources
+file(GLOB INC_FILES "${PROJECT_SOURCE_DIR}/include/igl/copyleft/*.h")
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/include/igl/copyleft/*.cpp")
+igl_target_sources(igl_copyleft_core ${INC_FILES} ${SRC_FILES})
+
+# 4. Dependencies
+target_link_libraries(igl_copyleft_core ${IGL_SCOPE}
+    igl::core
+)

+ 27 - 0
cmake/igl/modules/copyleft/tetgen.cmake

@@ -0,0 +1,27 @@
+# 1. Define module
+igl_add_library(igl_copyleft_tetgen)
+
+# 2. Include headers
+include(GNUInstallDirs)
+target_include_directories(igl_copyleft_tetgen ${IGL_SCOPE}
+    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+# 3. Target sources
+file(GLOB INC_FILES "${PROJECT_SOURCE_DIR}/include/igl/copyleft/tetgen/*.h")
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/include/igl/copyleft/tetgen/*.cpp")
+igl_target_sources(igl_copyleft_tetgen ${INC_FILES} ${SRC_FILES})
+
+# 4. Dependencies
+include(tetgen)
+igl_include(copyleft core)
+target_link_libraries(igl_copyleft_tetgen ${IGL_SCOPE}
+    igl::core
+    igl_copyleft::core
+    tetgen::tetgen
+)
+
+# 5. Unit tests
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/tests/include/igl/copyleft/tetgen/*.cpp")
+igl_add_test(igl_copyleft_tetgen ${SRC_FILES})

+ 32 - 0
cmake/igl/modules/core.cmake

@@ -0,0 +1,32 @@
+# 1. Define module
+igl_add_library(igl_core)
+if(LIBIGL_USE_STATIC_LIBRARY)
+    set_target_properties(igl_core PROPERTIES OUTPUT_NAME igl)
+endif()
+
+# 2. Include headers
+include(GNUInstallDirs)
+target_include_directories(igl_core ${IGL_SCOPE}
+    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+# 3. Target sources
+file(GLOB INC_FILES "${PROJECT_SOURCE_DIR}/include/igl/*.h")
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/include/igl/*.cpp")
+igl_target_sources(igl_core ${INC_FILES} ${SRC_FILES})
+
+# 4. Install target & headers
+igl_install(igl_core ${INC_FILES} ${SRC_FILES})
+
+# 5. Dependencies
+include(eigen)
+find_package(Threads REQUIRED)
+target_link_libraries(igl_core ${IGL_SCOPE}
+    Eigen3::Eigen
+    Threads::Threads
+)
+
+# 6. Unit tests
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/tests/include/igl/*.cpp")
+igl_add_test(igl_core ${SRC_FILES})

+ 25 - 0
cmake/igl/modules/embree.cmake

@@ -0,0 +1,25 @@
+# 1. Define module
+igl_add_library(igl_embree)
+
+# 2. Include headers
+include(GNUInstallDirs)
+target_include_directories(igl_embree ${IGL_SCOPE}
+    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+# 3. Target sources
+file(GLOB INC_FILES "${PROJECT_SOURCE_DIR}/include/igl/embree/*.h")
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/include/igl/embree/*.cpp")
+igl_target_sources(igl_embree ${INC_FILES} ${SRC_FILES})
+
+# 4. Dependencies
+include(embree)
+target_link_libraries(igl_embree ${IGL_SCOPE}
+    igl::core
+    embree::embree
+)
+
+# 5. Unit tests
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/tests/include/igl/embree/*.cpp")
+igl_add_test(igl_embree ${SRC_FILES})

+ 23 - 0
cmake/igl/modules/glfw.cmake

@@ -0,0 +1,23 @@
+# 1. Define module
+igl_add_library(igl_glfw)
+
+# 2. Include headers
+include(GNUInstallDirs)
+target_include_directories(igl_glfw ${IGL_SCOPE}
+    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+# 3. Target sources
+file(GLOB INC_FILES "${PROJECT_SOURCE_DIR}/include/igl/opengl/glfw/*.h")
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/include/igl/opengl/glfw/*.cpp")
+igl_target_sources(igl_glfw ${INC_FILES} ${SRC_FILES})
+
+# 4. Dependencies
+include(glfw)
+igl_include(opengl)
+target_link_libraries(igl_glfw ${IGL_SCOPE}
+    igl::core
+    igl::opengl
+    glfw::glfw
+)

+ 27 - 0
cmake/igl/modules/imgui.cmake

@@ -0,0 +1,27 @@
+# 1. Define module
+igl_add_library(igl_imgui)
+
+# 2. Include headers
+include(GNUInstallDirs)
+target_include_directories(igl_imgui ${IGL_SCOPE}
+    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+# 3. Target sources
+file(GLOB INC_FILES "${PROJECT_SOURCE_DIR}/include/igl/opengl/glfw/imgui/*.h")
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/include/igl/opengl/glfw/imgui/*.cpp")
+igl_target_sources(igl_imgui ${INC_FILES} ${SRC_FILES})
+
+# 4. Dependencies
+include(imgui)
+include(imguizmo)
+include(libigl_imgui_fonts)
+igl_include(glfw)
+target_link_libraries(igl_imgui ${IGL_SCOPE}
+    igl::core
+    igl::glfw
+    imgui::imgui
+    imguizmo::imguizmo
+    igl::imgui_fonts
+)

+ 24 - 0
cmake/igl/modules/opengl.cmake

@@ -0,0 +1,24 @@
+# 1. Define module
+igl_add_library(igl_opengl)
+
+# 2. Include headers
+include(GNUInstallDirs)
+target_include_directories(igl_opengl ${IGL_SCOPE}
+    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+# 3. Target sources
+file(GLOB INC_FILES "${PROJECT_SOURCE_DIR}/include/igl/opengl/*.h")
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/include/igl/opengl/*.cpp")
+igl_target_sources(igl_opengl ${INC_FILES} ${SRC_FILES})
+
+# 4. Dependencies
+include(glad)
+find_package(OpenGL REQUIRED OPTIONAL_COMPONENTS OpenGL)
+target_link_libraries(igl_opengl ${IGL_SCOPE}
+    igl::core
+    glad::glad
+    # Link against OpenGL::OpenGL if available, or fallback to OpenGL::GL
+    $<IF:$<TARGET_EXISTS:OpenGL::OpenGL>,OpenGL::OpenGL,OpenGL::GL>
+)

+ 23 - 0
cmake/igl/modules/png.cmake

@@ -0,0 +1,23 @@
+# 1. Define module
+igl_add_library(igl_png)
+
+# 2. Include headers
+include(GNUInstallDirs)
+target_include_directories(igl_png ${IGL_SCOPE}
+    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+# 3. Target sources
+file(GLOB INC_FILES "${PROJECT_SOURCE_DIR}/include/igl/png/*.h")
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/include/igl/png/*.cpp")
+igl_target_sources(igl_png ${INC_FILES} ${SRC_FILES})
+
+# 4. Dependencies
+include(stb)
+igl_include(opengl)
+target_link_libraries(igl_png ${IGL_SCOPE}
+    igl::core
+    igl::opengl
+    stb::stb
+)

+ 25 - 0
cmake/igl/modules/predicates.cmake

@@ -0,0 +1,25 @@
+# 1. Define module
+igl_add_library(igl_predicates)
+
+# 2. Include headers
+include(GNUInstallDirs)
+target_include_directories(igl_predicates ${IGL_SCOPE}
+    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+# 3. Target sources
+file(GLOB INC_FILES "${PROJECT_SOURCE_DIR}/include/igl/predicates/*.h")
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/include/igl/predicates/*.cpp")
+igl_target_sources(igl_predicates ${INC_FILES} ${SRC_FILES})
+
+# 4. Dependencies
+include(predicates)
+target_link_libraries(igl_predicates ${IGL_SCOPE}
+    igl::core
+    predicates::predicates
+)
+
+# 5. Unit tests
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/tests/include/igl/predicates/*.cpp")
+igl_add_test(igl_predicates ${SRC_FILES})

+ 25 - 0
cmake/igl/modules/restricted/matlab.cmake

@@ -0,0 +1,25 @@
+# 1. Define module
+igl_add_library(igl_restricted_matlab)
+
+# 2. Include headers
+include(GNUInstallDirs)
+target_include_directories(igl_restricted_matlab ${IGL_SCOPE}
+    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+# 3. Target sources
+file(GLOB INC_FILES "${PROJECT_SOURCE_DIR}/include/igl/matlab/*.h")
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/include/igl/matlab/*.cpp")
+igl_target_sources(igl_restricted_matlab ${INC_FILES} ${SRC_FILES})
+
+# 4. Dependencies
+# MATLAB_ADDITIONAL_VERSIONS should have already been set in libigl/CMakeLists.txt
+find_package(Matlab REQUIRED COMPONENTS MEX_COMPILER MX_LIBRARY ENG_LIBRARY MAT_LIBRARY)
+# to-do detect if imported targets are available (cmake 3.22's findmatlab has
+# them)  and use those instead of hard coding these.
+target_link_libraries(igl_restricted_matlab ${IGL_SCOPE} igl::core ${Matlab_LIBRARIES})
+target_include_directories(igl_restricted_matlab ${IGL_SCOPE} ${Matlab_INCLUDE_DIRS})
+
+# 5. Unit tests
+# to-do write some matlab tests

+ 27 - 0
cmake/igl/modules/restricted/mosek.cmake

@@ -0,0 +1,27 @@
+# 1. Define module
+igl_add_library(igl_restricted_mosek)
+
+# 2. Include headers
+include(GNUInstallDirs)
+target_include_directories(igl_restricted_mosek ${IGL_SCOPE}
+    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+# 3. Target sources
+file(GLOB INC_FILES "${PROJECT_SOURCE_DIR}/include/igl/mosek/*.h")
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/include/igl/mosek/*.cpp")
+igl_target_sources(igl_restricted_mosek ${INC_FILES} ${SRC_FILES})
+
+# 4. Dependencies
+find_package(MOSEK REQUIRED)
+target_include_directories(igl_restricted_mosek ${IGL_SCOPE} ${MOSEK_INCLUDE_DIRS})
+target_link_libraries(igl_restricted_mosek ${IGL_SCOPE} igl::core ${MOSEK_LIBRARIES})
+
+# 5. Unit tests
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/tests/include/igl/mosek/*.cpp")
+igl_add_test(igl_restricted_mosek ${SRC_FILES})
+IF(APPLE)
+  INCLUDE(${PROJECT_SOURCE_DIR}/cmake/misc/OSXFixDylibReferences.cmake)
+  OSX_FIX_DYLIB_REFERENCES(test_igl_restricted_mosek "${MOSEK_LIBRARIES}")
+ENDIF()

+ 29 - 0
cmake/igl/modules/restricted/triangle.cmake

@@ -0,0 +1,29 @@
+# 1. Define module
+igl_add_library(igl_restricted_triangle)
+
+# 2. Include headers
+include(GNUInstallDirs)
+target_include_directories(igl_restricted_triangle ${IGL_SCOPE}
+    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+# 3. Target sources
+file(GLOB INC_FILES "${PROJECT_SOURCE_DIR}/include/igl/triangle/*.h")
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/include/igl/triangle/*.cpp")
+igl_target_sources(igl_restricted_triangle ${INC_FILES} ${SRC_FILES})
+
+# 4. Dependencies
+include(triangle)
+target_link_libraries(igl_restricted_triangle ${IGL_SCOPE}
+    igl::core
+    triangle::triangle
+)
+
+# 5. Unit tests
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/tests/include/igl/triangle/*.cpp")
+igl_add_test(igl_restricted_triangle ${SRC_FILES})
+if(TARGET test_igl_restricted_triangle)
+    igl_include(predicates)
+    target_link_libraries(test_igl_restricted_triangle PUBLIC igl::predicates)
+endif()

+ 21 - 0
cmake/igl/modules/xml.cmake

@@ -0,0 +1,21 @@
+# 1. Define module
+igl_add_library(igl_xml)
+
+# 2. Include headers
+include(GNUInstallDirs)
+target_include_directories(igl_xml ${IGL_SCOPE}
+    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+# 3. Target sources
+file(GLOB INC_FILES "${PROJECT_SOURCE_DIR}/include/igl/xml/*.h")
+file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/include/igl/xml/*.cpp")
+igl_target_sources(igl_xml ${INC_FILES} ${SRC_FILES})
+
+# 4. Dependencies
+include(tinyxml2)
+target_link_libraries(igl_xml ${IGL_SCOPE}
+    igl::core
+    tinyxml2::tinyxml2
+)

+ 0 - 8
cmake/libigl-cgal.yml

@@ -1,8 +0,0 @@
-# This is a conda environment that can be used to compile libigl with CGAL on Windows
-# Only boost is required to be installed on the system, CGAL is automatically downloaded
-# by CMake and is built with libigl.
-name: libigl-cgal
-channels:
-  - conda-forge
-dependencies:
-  - boost-cpp=1.65.0

+ 0 - 31
cmake/libigl-config.cmake.in

@@ -1,31 +0,0 @@
-@PACKAGE_INIT@
-
-include(${CMAKE_CURRENT_LIST_DIR}/libigl-export.cmake)
-
-# Check if Eigen3 target is avaiable, if not try to locate it
-# with find_package.
-message(STATUS "[libigl] Looking for Eigen3")
-if (NOT TARGET Eigen3::Eigen)
-  # Try if Eigen3 can be found with find_package
-  find_package(Eigen3 CONFIG REQUIRED)
-endif()
-
-
-if (TARGET igl::core)
-  if (TARGET Eigen3::Eigen)
-    # Inject dependency
-    set_target_properties(igl::core PROPERTIES INTERFACE_LINK_LIBRARIES Eigen3::Eigen)
-    set(libigl_core_FOUND TRUE)
-  endif()
-endif()
-
-if (TARGET igl::common)
-  if (TARGET Eigen3::Eigen)
-    # Inject dependency
-    set_target_properties(igl::common PROPERTIES INTERFACE_LINK_LIBRARIES Eigen3::Eigen)
-    set(libigl_common_FOUND TRUE)
-  endif()
-endif()
-
-check_required_components(libigl)
-

+ 35 - 571
cmake/libigl.cmake

@@ -1,576 +1,40 @@
-cmake_minimum_required(VERSION 3.8)
-
-# https://github.com/libigl/libigl/issues/751
-# http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160425/351643.html
-if(APPLE)
-  if(NOT CMAKE_LIBTOOL)
-    find_program(CMAKE_LIBTOOL NAMES libtool)
-  endif()
-  if(CMAKE_LIBTOOL)
-    set(CMAKE_LIBTOOL ${CMAKE_LIBTOOL} CACHE PATH "libtool executable")
-    message(STATUS "Found libtool - ${CMAKE_LIBTOOL}")
-    get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
-    foreach(lang ${languages})
-      # Added -c
-      set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
-        "${CMAKE_LIBTOOL} -c -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
-    endforeach()
-  endif()
-endif()
-
-### Available options ###
-option(LIBIGL_USE_STATIC_LIBRARY     "Use libigl as static library" OFF)
-option(LIBIGL_WITH_CGAL              "Use CGAL"                     OFF)
-option(LIBIGL_WITH_COMISO            "Use CoMiso"                   OFF)
-option(LIBIGL_WITH_CORK              "Use Cork"                     OFF)
-option(LIBIGL_WITH_EMBREE            "Use Embree"                   OFF)
-option(LIBIGL_WITH_MATLAB            "Use Matlab"                   OFF)
-option(LIBIGL_WITH_MOSEK             "Use MOSEK"                    OFF)
-option(LIBIGL_WITH_OPENGL            "Use OpenGL"                   OFF)
-option(LIBIGL_WITH_OPENGL_GLFW       "Use GLFW"                     OFF)
-option(LIBIGL_WITH_OPENGL_GLFW_IMGUI "Use ImGui"                    OFF)
-option(LIBIGL_WITH_PNG               "Use PNG"                      OFF)
-option(LIBIGL_WITH_TETGEN            "Use Tetgen"                   OFF)
-option(LIBIGL_WITH_TRIANGLE          "Use Triangle"                 OFF)
-option(LIBIGL_WITH_PREDICATES        "Use exact predicates"         OFF)
-option(LIBIGL_WITH_XML               "Use XML"                      OFF)
-option(LIBIGL_WITHOUT_COPYLEFT       "Disable Copyleft libraries"   OFF)
-option(LIBIGL_EXPORT_TARGETS         "Export libigl CMake targets"  OFF)
-
-if(LIBIGL_BUILD_PYTHON)
-  message(FATAL_ERROR "Python bindings have been removed in this version. Please use an older version of libigl, or wait for the new bindings to be released.")
+# Sanity check for backward compatibility
+get_filename_component(PATH_X "${PROJECT_SOURCE_DIR}" REALPATH)
+get_filename_component(PATH_Y "${CMAKE_CURRENT_LIST_DIR}/.." REALPATH)
+if(NOT PATH_X STREQUAL PATH_Y)
+    message(FATAL_ERROR "You included libigl.cmake directly from your own project. This behavior "
+                        "is not supported anymore. Please add libigl to your project via "
+                        "add_subdirectory(<path_to_libigl>). See the libigl example project for "
+                        "more information: https://github.com/libigl/libigl-example-project/")
 endif()
 
-################################################################################
-
-### Configuration
-set(LIBIGL_ROOT "${CMAKE_CURRENT_LIST_DIR}/..")
-set(LIBIGL_SOURCE_DIR "${LIBIGL_ROOT}/include")
-set(LIBIGL_EXTERNAL "${LIBIGL_ROOT}/external")
-
 # Dependencies are linked as INTERFACE targets unless libigl is compiled as a static library
 if(LIBIGL_USE_STATIC_LIBRARY)
-  set(IGL_SCOPE PUBLIC)
-else()
-  set(IGL_SCOPE INTERFACE)
-endif()
-
-# Download and update 3rdparty libraries
-list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
-include(LibiglDownloadExternal)
-
-# Provides igl_set_folders() to set folders for Visual Studio/Xcode
-include(LibiglFolders)
-
-################################################################################
-### IGL Common
-################################################################################
-
-add_library(igl_common INTERFACE)
-target_include_directories(igl_common SYSTEM INTERFACE
-  $<BUILD_INTERFACE:${LIBIGL_SOURCE_DIR}>
-  $<INSTALL_INTERFACE:include>
-)
-# Export igl_common as igl::common
-set_property(TARGET igl_common PROPERTY EXPORT_NAME igl::common)
-if(LIBIGL_USE_STATIC_LIBRARY)
-  target_compile_definitions(igl_common INTERFACE -DIGL_STATIC_LIBRARY)
-endif()
-
-# Transitive C++11 flags
-include(CXXFeatures)
-target_compile_features(igl_common INTERFACE ${CXX11_FEATURES})
-
-# Other compilation flags
-if(MSVC)
-  # Enable parallel compilation for Visual Studio
-  target_compile_options(igl_common INTERFACE $<$<COMPILE_LANGUAGE:CXX>:/MP> $<$<COMPILE_LANGUAGE:CXX>:/bigobj>)
-  target_compile_definitions(igl_common INTERFACE -DNOMINMAX)
-endif()
-
-# Controls whether to use the static MSVC runtime or not
-include(LibiglWindows)
-
-if(BUILD_SHARED_LIBS)
-  # Generate position independent code
-  set_target_properties(igl_common PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE ON)
-endif()
-
-if(UNIX AND NOT HUNTER_ENABLED)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
-endif()
-
-if(HUNTER_ENABLED)
-  hunter_add_package(Eigen)
-  find_package(Eigen3 CONFIG REQUIRED)
-endif()
-
-# Eigen
-if(NOT TARGET Eigen3::Eigen)
-  igl_download_eigen()
-  add_library(igl_eigen INTERFACE)
-  target_include_directories(igl_eigen SYSTEM INTERFACE
-    $<BUILD_INTERFACE:${LIBIGL_EXTERNAL}/eigen>
-    $<INSTALL_INTERFACE:include>
-  )
-  set_property(TARGET igl_eigen PROPERTY EXPORT_NAME Eigen3::Eigen)
-  add_library(Eigen3::Eigen ALIAS igl_eigen)
-endif()
-target_link_libraries(igl_common INTERFACE Eigen3::Eigen)
-
-# C++11 Thread library
-find_package(Threads REQUIRED)
-target_link_libraries(igl_common INTERFACE ${CMAKE_THREAD_LIBS_INIT})
-
-################################################################################
-
-## CGAL dependencies on Windows: GMP & MPFR
-function(igl_download_cgal_deps)
-  if(WIN32)
-    igl_download_project(gmp
-        URL     https://cgal.geometryfactory.com/CGAL/precompiled_libs/auxiliary/x64/GMP/5.0.1/gmp-all-CGAL-3.9.zip
-        URL_MD5 508c1292319c832609329116a8234c9f
-    )
-    igl_download_project(mpfr
-        URL https://cgal.geometryfactory.com/CGAL/precompiled_libs/auxiliary/x64/MPFR/3.0.0/mpfr-all-CGAL-3.9.zip
-        URL_MD5 48840454eef0ff18730050c05028734b
-    )
-    set(ENV{GMP_DIR} "${LIBIGL_EXTERNAL}/gmp")
-    set(ENV{MPFR_DIR} "${LIBIGL_EXTERNAL}/mpfr")
-  endif()
-endfunction()
-
-################################################################################
-
-function(compile_igl_module module_dir)
-  string(REPLACE "/" "_" module_name "${module_dir}")
-  if(module_name STREQUAL "core")
-    set(module_libname "igl")
-  else()
-    set(module_libname "igl_${module_name}")
-  endif()
-  if(LIBIGL_USE_STATIC_LIBRARY)
-    file(GLOB SOURCES_IGL_${module_name}
-      "${LIBIGL_SOURCE_DIR}/igl/${module_dir}/*.cpp"
-      "${LIBIGL_SOURCE_DIR}/igl/${module_dir}/*.h*"
-    )
-    if(NOT LIBIGL_WITHOUT_COPYLEFT)
-      file(GLOB COPYLEFT_SOURCES_IGL_${module_name}
-        "${LIBIGL_SOURCE_DIR}/igl/copyleft/${module_dir}/*.cpp"
-        "${LIBIGL_SOURCE_DIR}/igl/copyleft/${module_dir}/*.h*"
-      )
-      list(APPEND SOURCES_IGL_${module_name} ${COPYLEFT_SOURCES_IGL_${module_name}})
-    endif()
-    add_library(${module_libname} STATIC ${SOURCES_IGL_${module_name}} ${ARGN})
-    if(MSVC)
-      # Silencing some compile warnings
-      target_compile_options(${module_libname} PRIVATE
-        # Type conversion warnings. These can be fixed with some effort and possibly more verbose code.
-        /wd4267 # conversion from 'size_t' to 'type', possible loss of data
-        /wd4244 # conversion from 'type1' to 'type2', possible loss of data
-        /wd4018 # signed/unsigned mismatch
-        /wd4305 # truncation from 'double' to 'float'
-        # This one is from template instantiations generated by autoexplicit.sh:
-        /wd4667 # no function template defined that matches forced instantiation ()
-        # This one is easy to fix, just need to switch to safe version of C functions
-        /wd4996 # this function or variable may be unsafe
-        # This one is when using bools in adjacency matrices
-        /wd4804 #'+=': unsafe use of type 'bool' in operation
-      )
-    endif()
-  else()
-    add_library(${module_libname} INTERFACE)
-  endif()
-
-  target_link_libraries(${module_libname} ${IGL_SCOPE} igl_common)
-  if(NOT module_name STREQUAL "core")
-    target_link_libraries(${module_libname} ${IGL_SCOPE} igl)
-  endif()
-
-  # Alias target because it looks nicer
-  message(STATUS "Creating target: igl::${module_name} (${module_libname})")
-  add_library(igl::${module_name} ALIAS ${module_libname})
-  # Export as igl::${module_name}
-  set_property(TARGET ${module_libname} PROPERTY EXPORT_NAME igl::${module_name})
-endfunction()
-
-################################################################################
-### IGL Core
-################################################################################
-
-if(LIBIGL_USE_STATIC_LIBRARY)
-  file(GLOB SOURCES_IGL
-    "${LIBIGL_SOURCE_DIR}/igl/*.cpp"
-    "${LIBIGL_SOURCE_DIR}/igl/*.h*"
-    "${LIBIGL_SOURCE_DIR}/igl/copyleft/*.cpp"
-    "${LIBIGL_SOURCE_DIR}/igl/copyleft/*.h*"
-  )
-endif()
-compile_igl_module("core" ${SOURCES_IGL})
-
-################################################################################
-### Download the python part ###
-if(LIBIGL_WITH_PYTHON)
-endif()
-
-################################################################################
-### Compile the CGAL part ###
-if(LIBIGL_WITH_CGAL)
-  # Try to find the CGAL library
-  # CGAL Core is needed for
-  # `Exact_predicates_exact_constructions_kernel_with_sqrt`
-  if(NOT TARGET CGAL::CGAL)
-    set(CGAL_DIR "${LIBIGL_EXTERNAL}/cgal")
-    igl_download_cgal()
-    igl_download_cgal_deps()
-    message("BOOST_ROOT: ${BOOST_ROOT}")
-    if(EXISTS ${LIBIGL_EXTERNAL}/boost)
-      set(BOOST_ROOT "${LIBIGL_EXTERNAL}/boost")
-    endif()
-    option(CGAL_Boost_USE_STATIC_LIBS "Use static Boost libs with CGAL" ON)
-
-    find_package(CGAL CONFIG COMPONENTS Core PATHS ${CGAL_DIR} NO_DEFAULT_PATH)
-  endif()
-
-  # If CGAL has been found, then build the libigl module
-  if(TARGET CGAL::CGAL AND TARGET CGAL::CGAL_Core)
-    compile_igl_module("cgal")
-    target_link_libraries(igl_cgal ${IGL_SCOPE} CGAL::CGAL CGAL::CGAL_Core)
-  else()
-    message(FATAL_ERROR "Could not define CGAL::CGAL and CGAL::CGAL_Core.")
-  endif()
-endif()
-
-# Helper function for `igl_copy_cgal_dll()`
-function(igl_copy_imported_dll src_target dst_target)
-  get_target_property(other_libs ${src_target} INTERFACE_LINK_LIBRARIES)
-  set(locations)
-  list(APPEND locations ${main_lib} ${other_libs})
-  foreach(location ${locations})
-    string(REGEX MATCH "^(.*)\\.[^.]*$" dummy ${location})
-    set(location "${CMAKE_MATCH_1}.dll")
-    if(EXISTS "${location}" AND location MATCHES "^.*\\.dll$")
-      add_custom_command(TARGET ${dst_target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${location}" $<TARGET_FILE_DIR:${dst_target}>)
-    endif()
-  endforeach()
-endfunction()
-
-# Convenient functions to copy CGAL dlls into a target (executable) destination folder (for Windows)
-function(igl_copy_cgal_dll target)
-  if(WIN32 AND LIBIGL_WITH_CGAL)
-    igl_copy_imported_dll(CGAL::CGAL ${target})
-    igl_copy_imported_dll(CGAL::CGAL_Core ${target})
-  endif()
-endfunction()
-
-################################################################################
-### Compile the CoMISo part ###
-# NOTE: this cmakefile works only with the
-# comiso available here: https://github.com/libigl/CoMISo
-if(LIBIGL_WITH_COMISO)
-  compile_igl_module("comiso")
-  if(NOT TARGET CoMISo)
-    igl_download_comiso()
-    add_subdirectory("${LIBIGL_EXTERNAL}/CoMISo" CoMISo)
-  endif()
-  target_link_libraries(igl_comiso ${IGL_SCOPE} CoMISo)
-endif()
-
-################################################################################
-### Compile the cork part ###
-if(LIBIGL_WITH_CORK)
-  set(CORK_DIR "${LIBIGL_EXTERNAL}/cork")
-  if(NOT TARGET cork)
-    # call this "lib-cork" instead of "cork", otherwise cmake gets confused about
-    # "cork" executable
-    igl_download_cork()
-    add_subdirectory("${CORK_DIR}" "lib-cork")
-  endif()
-  compile_igl_module("cork")
-  target_include_directories(igl_cork ${IGL_SCOPE} cork)
-  target_include_directories(igl_cork ${IGL_SCOPE} "${CORK_DIR}/src")
-  target_link_libraries(igl_cork ${IGL_SCOPE} cork)
-endif()
-
-################################################################################
-### Compile the embree part ###
-if(LIBIGL_WITH_EMBREE)
-  set(EMBREE_DIR "${LIBIGL_EXTERNAL}/embree")
-
-  if(NOT TARGET embree)
-    igl_download_embree()
-
-    # Note: On macOS, building embree as a static lib can only be done with a single ISA target.
-    set(EMBREE_MAX_ISA "DEFAULT" CACHE STRING "Selects highest ISA to support.")
-    set(EMBREE_TESTING_INTENSITY 0 CACHE STRING "")
-    set(EMBREE_ISPC_SUPPORT OFF CACHE BOOL " ")
-    set(EMBREE_TASKING_SYSTEM "INTERNAL" CACHE BOOL " ")
-    set(EMBREE_TUTORIALS OFF CACHE BOOL " ")
-    set(EMBREE_STATIC_LIB ON CACHE BOOL " ")
-    if(MSVC)
-      set(EMBREE_STATIC_RUNTIME ${IGL_STATIC_RUNTIME} CACHE BOOL "Use the static version of the C/C++ runtime library.")
-    endif()
-
-    add_subdirectory("${EMBREE_DIR}" "embree" EXCLUDE_FROM_ALL)
-  endif()
-
-  compile_igl_module("embree")
-  target_link_libraries(igl_embree ${IGL_SCOPE} embree)
-  target_include_directories(igl_embree ${IGL_SCOPE} ${EMBREE_DIR}/include)
-  target_compile_definitions(igl_embree ${IGL_SCOPE} -DEMBREE_STATIC_LIB)
-endif()
-
-################################################################################
-### Compile the matlab part ###
-if(LIBIGL_WITH_MATLAB)
-  find_package(Matlab REQUIRED COMPONENTS MEX_COMPILER MX_LIBRARY ENG_LIBRARY MAT_LIBRARY)
-  compile_igl_module("matlab")
-  target_link_libraries(igl_matlab ${IGL_SCOPE} ${Matlab_LIBRARIES})
-  target_include_directories(igl_matlab ${IGL_SCOPE} ${Matlab_INCLUDE_DIRS})
-endif()
-
-################################################################################
-### Compile the mosek part ###
-if(LIBIGL_WITH_MOSEK)
-  find_package(MOSEK REQUIRED)
-  compile_igl_module("mosek")
-  target_link_libraries(igl_mosek ${IGL_SCOPE} ${MOSEK_LIBRARIES})
-  target_include_directories(igl_mosek ${IGL_SCOPE} ${MOSEK_INCLUDE_DIRS})
-  target_compile_definitions(igl_mosek ${IGL_SCOPE} -DLIBIGL_WITH_MOSEK)
-endif()
-
-################################################################################
-### Compile the opengl part ###
-if(LIBIGL_WITH_OPENGL)
-  # OpenGL module
-  compile_igl_module("opengl")
-
-  # OpenGL library
-  if (NOT CMAKE_VERSION VERSION_LESS "3.11")
-    cmake_policy(SET CMP0072 NEW)
-  endif()
-  find_package(OpenGL REQUIRED OPTIONAL_COMPONENTS OpenGL)
-  if(TARGET OpenGL::OpenGL)
-    target_link_libraries(igl_opengl ${IGL_SCOPE} OpenGL::OpenGL)
-  else()
-    target_link_libraries(igl_opengl ${IGL_SCOPE} OpenGL::GL)
-  endif()
-
-  # glad module
-  if(NOT TARGET glad)
-    igl_download_glad()
-    add_subdirectory(${LIBIGL_EXTERNAL}/glad glad)
-  endif()
-  target_link_libraries(igl_opengl ${IGL_SCOPE} glad)
-endif()
-
-################################################################################
-### Compile the GLFW part ###
-if(LIBIGL_WITH_OPENGL_GLFW)
-  if(TARGET igl::opengl)
-    # GLFW module
-    compile_igl_module("opengl/glfw")
-    if(NOT TARGET glfw)
-      igl_download_glfw()
-      option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF)
-      option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF)
-      option(GLFW_BUILD_DOCS "Build the GLFW documentation" OFF)
-      option(GLFW_INSTALL "Generate installation target" OFF)
-      if(IGL_STATIC_RUNTIME)
-        set(USE_MSVC_RUNTIME_LIBRARY_DLL OFF CACHE BOOL "Use MSVC runtime library DLL" FORCE)
-      else()
-        set(USE_MSVC_RUNTIME_LIBRARY_DLL ON CACHE BOOL "Use MSVC runtime library DLL" FORCE)
-      endif()
-      add_subdirectory(${LIBIGL_EXTERNAL}/glfw glfw)
-    endif()
-    target_link_libraries(igl_opengl_glfw ${IGL_SCOPE} igl_opengl glfw)
-  endif()
-endif()
-
-################################################################################
-### Compile the ImGui part ###
-if(LIBIGL_WITH_OPENGL_GLFW_IMGUI)
-  if(TARGET igl::opengl_glfw)
-    # ImGui module
-    compile_igl_module("opengl/glfw/imgui")
-    if(NOT TARGET imgui)
-      igl_download_imgui()
-      add_subdirectory(${LIBIGL_EXTERNAL}/libigl-imgui imgui)
-    endif()
-    if(NOT TARGET imguizmo)
-      igl_download_imguizmo()
-      add_library(imguizmo ${LIBIGL_EXTERNAL}/imguizmo/ImGuizmo.cpp ${LIBIGL_EXTERNAL}/imguizmo/ImGuizmo.h)
-      target_compile_features(imguizmo PUBLIC cxx_std_11)
-      target_link_libraries(imguizmo PUBLIC imgui)
-    endif()
-    target_link_libraries(igl_opengl_glfw_imgui ${IGL_SCOPE} igl_opengl_glfw imgui imguizmo)
-  endif()
-endif()
-
-################################################################################
-### Compile the png part ###
-if(LIBIGL_WITH_PNG)
-  # png/ module is anomalous because it also depends on opengl it really should
-  # be moved into the opengl/ directory and namespace ...
-  if(TARGET igl_opengl)
-    if(NOT TARGET stb_image)
-      igl_download_stb()
-      add_subdirectory(${LIBIGL_EXTERNAL}/stb stb_image)
-    endif()
-    compile_igl_module("png" "")
-    target_link_libraries(igl_png ${IGL_SCOPE} igl_stb_image igl_opengl)
-  endif()
-endif()
-
-################################################################################
-### Compile the tetgen part ###
-if(LIBIGL_WITH_TETGEN)
-  set(TETGEN_DIR "${LIBIGL_EXTERNAL}/tetgen")
-  if(NOT TARGET tetgen)
-    igl_download_tetgen()
-    add_subdirectory("${TETGEN_DIR}" "tetgen")
-  endif()
-  compile_igl_module("tetgen")
-  target_link_libraries(igl_tetgen ${IGL_SCOPE} tetgen)
-  target_include_directories(igl_tetgen ${IGL_SCOPE} ${TETGEN_DIR})
-endif()
-
-################################################################################
-### Compile the triangle part ###
-if(LIBIGL_WITH_TRIANGLE)
-  set(TRIANGLE_DIR "${LIBIGL_EXTERNAL}/triangle")
-  if(NOT TARGET triangle)
-    igl_download_triangle()
-    add_subdirectory("${TRIANGLE_DIR}" "triangle")
-  endif()
-  compile_igl_module("triangle")
-  target_link_libraries(igl_triangle ${IGL_SCOPE} triangle)
-  target_include_directories(igl_triangle ${IGL_SCOPE} ${TRIANGLE_DIR})
-endif()
-
-################################################################################
-### Compile the predicates part ###
-if(LIBIGL_WITH_PREDICATES)
-  set(PREDICATES_DIR "${LIBIGL_EXTERNAL}/predicates")
-  if(NOT TARGET predicates)
-    igl_download_predicates()
-    add_subdirectory("${PREDICATES_DIR}" "predicates")
-  endif()
-  compile_igl_module("predicates")
-  target_link_libraries(igl_predicates ${IGL_SCOPE} predicates)
-  target_include_directories(igl_predicates ${IGL_SCOPE} ${PREDICATES_DIR})
-  target_compile_definitions(igl_predicates ${IGL_SCOPE} -DLIBIGL_WITH_PREDICATES)
-endif()
-
-################################################################################
-### Compile the xml part ###
-if(LIBIGL_WITH_XML)
-  set(TINYXML2_DIR "${LIBIGL_EXTERNAL}/tinyxml2")
-  if(NOT TARGET tinyxml2)
-    igl_download_tinyxml2()
-    add_library(tinyxml2 STATIC ${TINYXML2_DIR}/tinyxml2.cpp ${TINYXML2_DIR}/tinyxml2.h)
-    target_include_directories(tinyxml2 PUBLIC ${TINYXML2_DIR})
-    set_target_properties(tinyxml2 PROPERTIES
-            COMPILE_DEFINITIONS "TINYXML2_EXPORT"
-            VERSION "3.0.0"
-            SOVERSION "3")
-  endif()
-  compile_igl_module("xml")
-  target_link_libraries(igl_xml ${IGL_SCOPE} tinyxml2)
-  target_include_directories(igl_xml ${IGL_SCOPE} ${TINYXML2_DIR})
-endif()
-
-################################################################################
-### Install and export all modules
-
-if(NOT LIBIGL_EXPORT_TARGETS)
-  return()
-endif()
-
-function(install_dir_files dir_name)
-  if (dir_name STREQUAL "core")
-    set(subpath "")
-  else()
-    set(subpath "/${dir_name}")
-  endif()
-
-  file(GLOB public_headers
-    ${CMAKE_CURRENT_SOURCE_DIR}/include/igl${subpath}/*.h
-    ${CMAKE_CURRENT_SOURCE_DIR}/include/igl${subpath}/*.hpp
-  )
-
-  set(files_to_install ${public_headers})
-
-  if(NOT LIBIGL_USE_STATIC_LIBRARY)
-    file(GLOB public_sources
-      ${CMAKE_CURRENT_SOURCE_DIR}/include/igl${subpath}/*.cpp
-      ${CMAKE_CURRENT_SOURCE_DIR}/include/igl${subpath}/*.c
-    )
-  endif()
-  list(APPEND files_to_install ${public_sources})
-
-  install(
-    FILES ${files_to_install}
-    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/igl${subpath}
-  )
-endfunction()
-
-################################################################################
-
-include(GNUInstallDirs)
-include(CMakePackageConfigHelpers)
-
-if(TARGET igl_eigen)
-  set(IGL_EIGEN igl_eigen)
+    set(IGL_SCOPE PUBLIC)
 else()
-  set(IGL_EIGEN)
-  message(WARNING "Trying to export igl targets while using an imported target for Eigen.")
-endif()
-
-# Install and export core library
-install(
-  TARGETS
-    igl
-    igl_common
-    ${IGL_EIGEN}
-  EXPORT igl-export
-  PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
-  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
-  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
-)
-export(
-  TARGETS
-    igl
-    igl_common
-    ${IGL_EIGEN}
-  FILE libigl-export.cmake
-)
-
-# Install headers for core library
-install_dir_files(core)
-install_dir_files(copyleft)
-
-# Write package configuration file
-configure_package_config_file(
-  ${CMAKE_CURRENT_LIST_DIR}/libigl-config.cmake.in
-  ${CMAKE_BINARY_DIR}/libigl-config.cmake
-  INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/libigl/cmake
-)
-install(
-  FILES
-    ${CMAKE_BINARY_DIR}/libigl-config.cmake
-  DESTINATION
-    ${CMAKE_INSTALL_DATADIR}/libigl/cmake
-)
-
-# Write export file
-export(EXPORT igl-export
-  FILE "${CMAKE_BINARY_DIR}/libigl-export.cmake"
-)
-install(EXPORT igl-export DESTINATION ${CMAKE_INSTALL_DATADIR}/libigl/cmake FILE libigl-export.cmake)
-
-
-export(PACKAGE libigl)
-
+    set(IGL_SCOPE INTERFACE)
+endif()
+
+# Global options
+include(igl_windows)
+
+# Libigl permissive modules
+igl_include(core)
+igl_include_optional(embree)
+igl_include_optional(opengl)
+igl_include_optional(glfw)
+igl_include_optional(imgui)
+igl_include_optional(predicates)
+igl_include_optional(png)
+igl_include_optional(xml)
+
+# Libigl copyleft modules
+igl_include_optional(copyleft core)
+igl_include_optional(copyleft cgal)
+igl_include_optional(copyleft comiso)
+igl_include_optional(copyleft tetgen)
+
+# Libigl restricted modules
+igl_include_optional(restricted matlab)
+igl_include_optional(restricted mosek)
+igl_include_optional(restricted triangle)

+ 24 - 27
cmake/HunterGate.cmake → cmake/misc/HunterGate.cmake

@@ -1,4 +1,4 @@
-# Copyright (c) 2013-2018, Ruslan Baratov
+# Copyright (c) 2013-2019, Ruslan Baratov
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -59,8 +59,9 @@ include(CMakeParseArguments) # cmake_parse_arguments
 option(HUNTER_STATUS_PRINT "Print working status" ON)
 option(HUNTER_STATUS_DEBUG "Print a lot info" OFF)
 option(HUNTER_TLS_VERIFY "Enable/disable TLS certificate checking on downloads" ON)
+set(HUNTER_ROOT "" CACHE FILEPATH "Override the HUNTER_ROOT.")
 
-set(HUNTER_WIKI "https://github.com/ruslo/hunter/wiki")
+set(HUNTER_ERROR_PAGE "https://hunter.readthedocs.io/en/latest/reference/errors")
 
 function(hunter_gate_status_print)
   if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG)
@@ -79,9 +80,9 @@ function(hunter_gate_status_debug)
   endif()
 endfunction()
 
-function(hunter_gate_wiki wiki_page)
-  message("------------------------------ WIKI -------------------------------")
-  message("    ${HUNTER_WIKI}/${wiki_page}")
+function(hunter_gate_error_page error_page)
+  message("------------------------------ ERROR ------------------------------")
+  message("    ${HUNTER_ERROR_PAGE}/${error_page}.html")
   message("-------------------------------------------------------------------")
   message("")
   message(FATAL_ERROR "")
@@ -94,14 +95,13 @@ function(hunter_gate_internal_error)
   endforeach()
   message("[hunter ** INTERNAL **] [Directory:${CMAKE_CURRENT_LIST_DIR}]")
   message("")
-  hunter_gate_wiki("error.internal")
+  hunter_gate_error_page("error.internal")
 endfunction()
 
 function(hunter_gate_fatal_error)
-  cmake_parse_arguments(hunter "" "WIKI" "" "${ARGV}")
-  string(COMPARE EQUAL "${hunter_WIKI}" "" have_no_wiki)
-  if(have_no_wiki)
-    hunter_gate_internal_error("Expected wiki")
+  cmake_parse_arguments(hunter "" "ERROR_PAGE" "" "${ARGV}")
+  if("${hunter_ERROR_PAGE}" STREQUAL "")
+    hunter_gate_internal_error("Expected ERROR_PAGE")
   endif()
   message("")
   foreach(x ${hunter_UNPARSED_ARGUMENTS})
@@ -109,11 +109,11 @@ function(hunter_gate_fatal_error)
   endforeach()
   message("[hunter ** FATAL ERROR **] [Directory:${CMAKE_CURRENT_LIST_DIR}]")
   message("")
-  hunter_gate_wiki("${hunter_WIKI}")
+  hunter_gate_error_page("${hunter_ERROR_PAGE}")
 endfunction()
 
 function(hunter_gate_user_error)
-  hunter_gate_fatal_error(${ARGV} WIKI "error.incorrect.input.data")
+  hunter_gate_fatal_error(${ARGV} ERROR_PAGE "error.incorrect.input.data")
 endfunction()
 
 function(hunter_gate_self root version sha1 result)
@@ -149,24 +149,21 @@ endfunction()
 # Set HUNTER_GATE_ROOT cmake variable to suitable value.
 function(hunter_gate_detect_root)
   # Check CMake variable
-  string(COMPARE NOTEQUAL "${HUNTER_ROOT}" "" not_empty)
-  if(not_empty)
+  if(HUNTER_ROOT)
     set(HUNTER_GATE_ROOT "${HUNTER_ROOT}" PARENT_SCOPE)
     hunter_gate_status_debug("HUNTER_ROOT detected by cmake variable")
     return()
   endif()
 
   # Check environment variable
-  string(COMPARE NOTEQUAL "$ENV{HUNTER_ROOT}" "" not_empty)
-  if(not_empty)
+  if(DEFINED ENV{HUNTER_ROOT})
     set(HUNTER_GATE_ROOT "$ENV{HUNTER_ROOT}" PARENT_SCOPE)
     hunter_gate_status_debug("HUNTER_ROOT detected by environment variable")
     return()
   endif()
 
   # Check HOME environment variable
-  string(COMPARE NOTEQUAL "$ENV{HOME}" "" result)
-  if(result)
+  if(DEFINED ENV{HOME})
     set(HUNTER_GATE_ROOT "$ENV{HOME}/.hunter" PARENT_SCOPE)
     hunter_gate_status_debug("HUNTER_ROOT set using HOME environment variable")
     return()
@@ -174,8 +171,7 @@ function(hunter_gate_detect_root)
 
   # Check SYSTEMDRIVE and USERPROFILE environment variable (windows only)
   if(WIN32)
-    string(COMPARE NOTEQUAL "$ENV{SYSTEMDRIVE}" "" result)
-    if(result)
+    if(DEFINED ENV{SYSTEMDRIVE})
       set(HUNTER_GATE_ROOT "$ENV{SYSTEMDRIVE}/.hunter" PARENT_SCOPE)
       hunter_gate_status_debug(
           "HUNTER_ROOT set using SYSTEMDRIVE environment variable"
@@ -183,8 +179,7 @@ function(hunter_gate_detect_root)
       return()
     endif()
 
-    string(COMPARE NOTEQUAL "$ENV{USERPROFILE}" "" result)
-    if(result)
+    if(DEFINED ENV{USERPROFILE})
       set(HUNTER_GATE_ROOT "$ENV{USERPROFILE}/.hunter" PARENT_SCOPE)
       hunter_gate_status_debug(
           "HUNTER_ROOT set using USERPROFILE environment variable"
@@ -195,7 +190,7 @@ function(hunter_gate_detect_root)
 
   hunter_gate_fatal_error(
       "Can't detect HUNTER_ROOT"
-      WIKI "error.detect.hunter.root"
+      ERROR_PAGE "error.detect.hunter.root"
   )
 endfunction()
 
@@ -214,7 +209,7 @@ function(hunter_gate_download dir)
         "Settings:"
         "  HUNTER_ROOT: ${HUNTER_GATE_ROOT}"
         "  HUNTER_SHA1: ${HUNTER_GATE_SHA1}"
-        WIKI "error.run.install"
+        ERROR_PAGE "error.run.install"
     )
   endif()
   string(COMPARE EQUAL "${dir}" "" is_bad)
@@ -400,7 +395,7 @@ macro(HunterGate)
       hunter_gate_fatal_error(
           "Please set HunterGate *before* 'project' command. "
           "Detected project: ${PROJECT_NAME}"
-          WIKI "error.huntergate.before.project"
+          ERROR_PAGE "error.huntergate.before.project"
       )
     endif()
 
@@ -470,7 +465,7 @@ macro(HunterGate)
             "HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces."
             "Set HUNTER_ALLOW_SPACES_IN_PATH=ON to skip this error"
             "(Use at your own risk!)"
-            WIKI "error.spaces.in.hunter.root"
+            ERROR_PAGE "error.spaces.in.hunter.root"
         )
       endif()
     endif()
@@ -518,7 +513,9 @@ macro(HunterGate)
         hunter_gate_internal_error("${_sha1_location} not found")
       endif()
       file(READ "${_sha1_location}" _sha1_value)
-      string(COMPARE EQUAL "${_sha1_value}" "${HUNTER_GATE_SHA1}" _is_equal)
+      string(TOLOWER "${_sha1_value}" _sha1_value_lower)
+      string(TOLOWER "${HUNTER_GATE_SHA1}" _HUNTER_GATE_SHA1_lower)
+      string(COMPARE EQUAL "${_sha1_value_lower}" "${_HUNTER_GATE_SHA1_lower}" _is_equal)
       if(NOT _is_equal)
         hunter_gate_internal_error(
             "Short SHA1 collision:"

+ 0 - 0
cmake/OSXFixDylibReferences.cmake → cmake/misc/OSXFixDylibReferences.cmake


+ 64 - 0
cmake/recipes/external/boost.cmake

@@ -0,0 +1,64 @@
+if(TARGET Boost::boost)
+    return()
+endif()
+
+message(STATUS "Third-party: creating targets 'Boost::boost'...")
+
+include(FetchContent)
+FetchContent_Declare(
+    boost-cmake
+    GIT_REPOSITORY https://github.com/Orphis/boost-cmake.git
+    GIT_TAG 7f97a08b64bd5d2e53e932ddf80c40544cf45edf
+)
+
+set(PREVIOUS_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
+set(OLD_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE})
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+
+# This guy will download boost using FetchContent
+FetchContent_GetProperties(boost-cmake)
+if(NOT boost-cmake_POPULATED)
+    FetchContent_Populate(boost-cmake)
+    # File lcid.cpp from Boost_locale.cpp doesn't compile on MSVC, so we exclude them from the default
+    # targets being built by the project (only targets explicitly used by other targets will be built).
+    add_subdirectory(${boost-cmake_SOURCE_DIR} ${boost-cmake_BINARY_DIR} EXCLUDE_FROM_ALL)
+endif()
+
+set(CMAKE_POSITION_INDEPENDENT_CODE ${OLD_CMAKE_POSITION_INDEPENDENT_CODE})
+set(CMAKE_CXX_FLAGS "${PREVIOUS_CMAKE_CXX_FLAGS}")
+
+# Set VS target folders
+set(boost_modules
+    container
+    regex
+    atomic
+    exception
+    chrono
+    wave
+    context
+    coroutine
+    date_time
+    fiber
+    filesystem
+    graph
+    iostreams
+    locale
+    log
+    log_setup
+    unit_test_framework
+    math
+    program_options
+    timer
+    random
+    serialization
+    system
+    thread
+    type_erasure
+)
+foreach(module IN ITEMS ${boost_modules})
+    if(TARGET Boost_${module})
+        set_target_properties(Boost_${module} PROPERTIES FOLDER ThirdParty/Boost)
+    endif()
+endforeach()
+

+ 14 - 0
cmake/recipes/external/catch2.cmake

@@ -0,0 +1,14 @@
+if(TARGET Catch2::Catch2)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'Catch2::Catch2'")
+
+include(FetchContent)
+FetchContent_Declare(
+    catch2
+    GIT_REPOSITORY https://github.com/catchorg/Catch2.git
+    GIT_TAG v2.13.3
+    GIT_SHALLOW TRUE
+)
+FetchContent_MakeAvailable(catch2)

+ 58 - 0
cmake/recipes/external/cgal.cmake

@@ -0,0 +1,58 @@
+if(TARGET CGAL::CGAL)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'CGAL::CGAL'")
+
+include(FetchContent)
+FetchContent_Declare(
+    cgal
+    GIT_REPOSITORY https://github.com/CGAL/cgal.git
+    GIT_TAG        f7c3c8212b56c0d6dae63787efc99093f4383415
+    # URL https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.12.2/CGAL-4.12.2.tar.xz
+    # URL_MD5 c94a0081c3836fd01ccb4d1e8bdd5d4f
+    # URL https://github.com/CGAL/cgal/releases/download/v5.2.1/CGAL-5.2.1-library.tar.xz
+    # URL_MD5 c1c3a9abe9106b5f3ff8dccaf2ddc0b7
+)
+FetchContent_GetProperties(cgal)
+if(cgal_POPULATED)
+    return()
+endif()
+FetchContent_Populate(cgal)
+
+function(cgal_import_target)
+    macro(ignore_package NAME VERSION_NUM)
+        include(CMakePackageConfigHelpers)
+        file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${NAME}/${NAME}Config.cmake "")
+        write_basic_package_version_file(
+            ${CMAKE_CURRENT_BINARY_DIR}/${NAME}/${NAME}ConfigVersion.cmake
+            VERSION ${VERSION_NUM}
+            COMPATIBILITY AnyNewerVersion
+        )
+        set(${NAME}_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NAME} CACHE PATH "")
+        set(${NAME}_ROOT ${CMAKE_CURRENT_BINARY_DIR}/${NAME} CACHE PATH "")
+    endmacro()
+
+    include(gmp)
+    include(mpfr)
+    include(boost)
+
+    ignore_package(GMP 5.0.1)
+    set(GMP_INCLUDE_DIR "")
+    set(GMP_LIBRARIES gmp::gmp)
+
+    ignore_package(MPFR 3.0.0)
+    set(MPFR_INCLUDE_DIR "")
+    set(MPFR_LIBRARIES mpfr::mpfr)
+
+    ignore_package(Boost 1.71.0)
+    set(Boost_INCLUDE_DIRS "")
+    set(Boost_LIBRARIES Boost::thread Boost::system)
+
+    # Prefer Config mode before Module mode to prevent CGAL from loading its own FindXXX.cmake
+    set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
+
+    find_package(CGAL CONFIG COMPONENTS Core PATHS ${cgal_SOURCE_DIR} NO_DEFAULT_PATH)
+endfunction()
+
+cgal_import_target()

+ 31 - 0
cmake/recipes/external/comiso.cmake

@@ -0,0 +1,31 @@
+if(TARGET CoMISo::CoMISo)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'CoMISo::CoMISo'")
+
+include(FetchContent)
+FetchContent_Declare(
+    comiso
+    GIT_REPOSITORY https://github.com/libigl/CoMISo.git
+    GIT_TAG 536440e714f412e7ef6c0b96b90ba37b1531bb39
+)
+
+include(eigen)
+
+FetchContent_MakeAvailable(comiso)
+
+add_library(CoMISo::CoMISo ALIAS CoMISo)
+
+# Copy .hh headers into a subfolder `CoMISo/`
+file(GLOB_RECURSE INC_FILES "${comiso_SOURCE_DIR}/*.hh" "${comiso_SOURCE_DIR}/*.cc")
+set(output_folder "${CMAKE_CURRENT_BINARY_DIR}/CoMISo/include/CoMISo")
+message(VERBOSE "Copying CoMISo headers to '${output_folder}'")
+foreach(filepath IN ITEMS ${INC_FILES})
+    file(RELATIVE_PATH filename "${comiso_SOURCE_DIR}" ${filepath})
+    configure_file(${filepath} "${output_folder}/${filename}" COPYONLY)
+endforeach()
+
+target_include_directories(CoMISo PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/CoMISo/include)
+
+set_target_properties(CoMISo PROPERTIES FOLDER ThirdParty)

+ 43 - 0
cmake/recipes/external/eigen.cmake

@@ -0,0 +1,43 @@
+if(TARGET Eigen3::Eigen)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'Eigen3::Eigen'")
+
+include(FetchContent)
+FetchContent_Declare(
+    eigen
+    GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
+    GIT_TAG tags/3.3.7
+    GIT_SHALLOW TRUE
+)
+FetchContent_GetProperties(eigen)
+if(NOT eigen_POPULATED)
+    FetchContent_Populate(eigen)
+endif()
+
+add_library(Eigen3_Eigen INTERFACE)
+add_library(Eigen3::Eigen ALIAS Eigen3_Eigen)
+
+include(GNUInstallDirs)
+target_include_directories(Eigen3_Eigen SYSTEM INTERFACE
+    $<BUILD_INTERFACE:${eigen_SOURCE_DIR}>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+option(EIGEN_MPL2_ONLY "Compile Eigen with MPL2 code only" OFF)
+if(EIGEN_MPL2_ONLY)
+    target_compile_definitions(Eigen3_Eigen INTERFACE EIGEN_MPL2_ONLY)
+endif()
+
+# On Windows, enable natvis files to improve debugging experience
+if(WIN32 AND eigen_SOURCE_DIR)
+    target_sources(Eigen3_Eigen INTERFACE $<BUILD_INTERFACE:${eigen_SOURCE_DIR}/debug/msvc/eigen.natvis>)
+endif()
+
+# Install rules
+set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME eigen)
+set_target_properties(Eigen3_Eigen PROPERTIES EXPORT_NAME Eigen)
+install(DIRECTORY ${eigen_SOURCE_DIR}/Eigen DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+install(TARGETS Eigen3_Eigen EXPORT EigenTargets)
+install(EXPORT EigenTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eigen NAMESPACE Eigen3::)

+ 54 - 0
cmake/recipes/external/embree.cmake

@@ -0,0 +1,54 @@
+if(TARGET embree::embree)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'embree::embree'")
+
+include(FetchContent)
+FetchContent_Declare(
+    embree
+    GIT_REPOSITORY https://github.com/embree/embree.git
+    GIT_TAG        v3.12.1
+    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    "INTERNAL" CACHE STRING "Selects tasking system")
+set(EMBREE_MAX_ISA           "DEFAULT"  CACHE STRING "Selects highest ISA to support.")
+
+# 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
+include(GNUInstallDirs)
+target_include_directories(embree SYSTEM INTERFACE
+    "$<BUILD_INTERFACE:${embree_SOURCE_DIR}/include>"
+    "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/>"
+)
+
+add_library(embree::embree ALIAS embree)
+
+# Some order for IDEs
+set_target_properties(embree PROPERTIES FOLDER "ThirdParty//Embree")
+set_target_properties(algorithms PROPERTIES FOLDER "ThirdParty//Embree")
+set_target_properties(lexers PROPERTIES FOLDER "ThirdParty//Embree")
+set_target_properties(math PROPERTIES FOLDER "ThirdParty//Embree")
+set_target_properties(simd PROPERTIES FOLDER "ThirdParty//Embree")
+set_target_properties(sys PROPERTIES FOLDER "ThirdParty//Embree")
+set_target_properties(tasking PROPERTIES FOLDER "ThirdParty//Embree")
+set_target_properties(uninstall PROPERTIES FOLDER "ThirdParty//Embree")

+ 17 - 0
cmake/recipes/external/glad.cmake

@@ -0,0 +1,17 @@
+if(TARGET glad::glad)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'glad::glad'")
+
+include(FetchContent)
+FetchContent_Declare(
+    glad
+    GIT_REPOSITORY https://github.com/libigl/libigl-glad.git
+    GIT_TAG        09b4969c56779f7ddf8e6176ec1873184aec890f
+)
+
+FetchContent_MakeAvailable(glad)
+add_library(glad::glad ALIAS glad)
+
+set_target_properties(glad PROPERTIES FOLDER ThirdParty)

+ 42 - 0
cmake/recipes/external/glfw.cmake

@@ -0,0 +1,42 @@
+if(TARGET glfw::glfw)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'glfw::glfw'")
+
+include(FetchContent)
+FetchContent_Declare(
+    glfw
+    GIT_REPOSITORY https://github.com/glfw/glfw.git
+    GIT_TAG 3327050ca66ad34426a82c217c2d60ced61526b7
+)
+
+option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF)
+option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF)
+option(GLFW_BUILD_DOCS "Build the GLFW documentation" OFF)
+option(GLFW_INSTALL "Generate installation target" OFF)
+option(GLFW_VULKAN_STATIC "Use the Vulkan loader statically linked into application" OFF)
+FetchContent_MakeAvailable(glfw)
+
+add_library(glfw::glfw ALIAS glfw)
+
+set_target_properties(glfw PROPERTIES FOLDER ThirdParty)
+
+# Warning config
+if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
+    target_compile_options(glfw PRIVATE
+        "-Wno-missing-field-initializers"
+        "-Wno-objc-multiple-method-names"
+    )
+elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+    target_compile_options(glfw PRIVATE
+        "-Wno-missing-field-initializers"
+        "-Wno-objc-multiple-method-names"
+    )
+elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+    target_compile_options(glfw PRIVATE
+        "-Wno-missing-field-initializers"
+        "-Wno-sign-compare"
+        "-Wno-unused-parameter"
+    )
+endif()

+ 15 - 0
cmake/recipes/external/gmp.cmake

@@ -0,0 +1,15 @@
+if(TARGET gmp::gmp)
+    return()
+endif()
+
+# Download precompiled .dll on Windows
+include(gmp_mpfr)
+
+message(STATUS "Third-party: creating target 'gmp::gmp'")
+
+# Find_package will look for our downloaded lib on Windows, and system-wide on Linux/macOS
+find_package(GMP REQUIRED)
+
+if(NOT TARGET gmp::gmp)
+    message(FATAL_ERROR "Creation of target 'gmp::gmp' failed")
+endif()

+ 34 - 0
cmake/recipes/external/gmp_mpfr.cmake

@@ -0,0 +1,34 @@
+if(WIN32)
+    message(STATUS "Third-party: downloading gmp + mpfr")
+
+    include(FetchContent)
+
+    # CGAL 5+ ships with a single .zip combining GMP + MPFR's precompiled dlls.
+    # For now we still download them separately.
+
+    FetchContent_Declare(
+        gmp
+        URL     https://cgal.geometryfactory.com/CGAL/precompiled_libs/auxiliary/x64/GMP/5.0.1/gmp-all-CGAL-3.9.zip
+        URL_MD5 508c1292319c832609329116a8234c9f
+    )
+    FetchContent_MakeAvailable(gmp)
+
+    FetchContent_Declare(
+        mpfr
+        URL https://cgal.geometryfactory.com/CGAL/precompiled_libs/auxiliary/x64/MPFR/3.0.0/mpfr-all-CGAL-3.9.zip
+        URL_MD5 48840454eef0ff18730050c05028734b
+    )
+    FetchContent_MakeAvailable(mpfr)
+
+    # FetchContent_Declare(
+    #     gmp_mpfr
+    #     URL https://github.com/CGAL/cgal/releases/download/v5.2.1/CGAL-5.2.1-win64-auxiliary-libraries-gmp-mpfr.zip
+    #     URL_MD5 247f4dca741c6b9a9be76286414070fa
+    # )
+
+    # For CGAL
+    set(ENV{GMP_DIR} "${gmp_SOURCE_DIR}")
+    set(ENV{MPFR_DIR} "${mpfr_SOURCE_DIR}")
+else()
+    # On Linux/macOS, gmp+mpfr should be installed system-wide
+endif()

+ 67 - 0
cmake/recipes/external/imgui.cmake

@@ -0,0 +1,67 @@
+if(TARGET imgui::imgui)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'imgui::imgui'")
+
+include(FetchContent)
+FetchContent_Declare(
+    imgui
+    GIT_REPOSITORY https://github.com/ocornut/imgui.git
+    GIT_TAG 61b19489f1ba35934d9114c034b24eb5bff149e7 # 1.81 + patch for #1669
+)
+FetchContent_MakeAvailable(imgui)
+
+set(IMGUI_SRC
+    "${imgui_SOURCE_DIR}/imgui.h"
+    "${imgui_SOURCE_DIR}/imconfig.h"
+    "${imgui_SOURCE_DIR}/imgui_internal.h"
+    "${imgui_SOURCE_DIR}/imgui.cpp"
+    "${imgui_SOURCE_DIR}/imgui_demo.cpp"
+    "${imgui_SOURCE_DIR}/imgui_draw.cpp"
+    "${imgui_SOURCE_DIR}/imgui_widgets.cpp"
+    "${imgui_SOURCE_DIR}/imgui_tables.cpp"
+    "${imgui_SOURCE_DIR}/imstb_rectpack.h"
+    "${imgui_SOURCE_DIR}/imstb_textedit.h"
+    "${imgui_SOURCE_DIR}/imstb_truetype.h"
+    "${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.h"
+    "${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp"
+    "${imgui_SOURCE_DIR}/backends/imgui_impl_glfw.h"
+    "${imgui_SOURCE_DIR}/backends/imgui_impl_glfw.cpp"
+    "${imgui_SOURCE_DIR}/misc/cpp/imgui_stdlib.h"
+    "${imgui_SOURCE_DIR}/misc/cpp/imgui_stdlib.cpp"
+)
+
+# Copy imgui source files into a subfolder `imgui/`
+set(output_folder "${CMAKE_CURRENT_BINARY_DIR}/imgui/include/imgui")
+message(VERBOSE "Copying imgui files to '${output_folder}'")
+foreach(filepath IN ITEMS ${IMGUI_SRC})
+    file(RELATIVE_PATH filename "${imgui_SOURCE_DIR}" ${filepath})
+    configure_file(${filepath} "${output_folder}/${filename}" COPYONLY)
+endforeach()
+
+file(GLOB_RECURSE IMGUI_SRC "${output_folder}/*.h" "${output_folder}/*.cpp")
+
+add_library(imgui ${IMGUI_SRC})
+add_library(imgui::imgui ALIAS imgui)
+
+# Include headers
+target_include_directories(imgui
+    PUBLIC
+        "${CMAKE_CURRENT_BINARY_DIR}/imgui/include"
+        "${CMAKE_CURRENT_BINARY_DIR}/imgui/include/imgui"
+        "${CMAKE_CURRENT_BINARY_DIR}/imgui/include/imgui/backends"
+)
+
+# Compile definitions
+target_compile_definitions(imgui PUBLIC
+    IMGUI_IMPL_OPENGL_LOADER_GLAD
+    IMGUI_DISABLE_OBSOLETE_FUNCTIONS # to check for obsolete functions
+)
+
+# Dependencies
+include(glfw)
+include(glad)
+target_link_libraries(imgui PUBLIC glfw::glfw glad::glad)
+
+set_target_properties(imgui PROPERTIES FOLDER ThirdParty)

+ 40 - 0
cmake/recipes/external/imguizmo.cmake

@@ -0,0 +1,40 @@
+if(TARGET imguizmo::imguizmo)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'imguizmo::imguizmo'")
+
+include(FetchContent)
+FetchContent_Declare(
+    imguizmo
+    GIT_REPOSITORY https://github.com/CedricGuillemet/ImGuizmo.git
+    GIT_TAG a23567269f6617342bcc112394bdad937b54b2d7
+)
+FetchContent_MakeAvailable(imguizmo)
+
+set(IMGUIZMO_SRC
+    "${imguizmo_SOURCE_DIR}/ImGuizmo.h"
+    "${imguizmo_SOURCE_DIR}/ImGuizmo.cpp"
+)
+
+# Copy imguizmo source files into a subfolder `imguizmo/`
+set(output_folder "${CMAKE_CURRENT_BINARY_DIR}/imguizmo/include/imguizmo")
+message(VERBOSE "Copying imguizmo files to '${output_folder}'")
+foreach(filepath IN ITEMS ${IMGUIZMO_SRC})
+    file(RELATIVE_PATH filename "${imguizmo_SOURCE_DIR}" ${filepath})
+    configure_file(${filepath} "${output_folder}/${filename}" COPYONLY)
+endforeach()
+
+file(GLOB_RECURSE IMGUIZMO_SRC "${output_folder}/*.h" "${output_folder}/*.cpp")
+
+add_library(imguizmo ${IMGUIZMO_SRC})
+add_library(imguizmo::imguizmo ALIAS imguizmo)
+
+target_compile_features(imguizmo PUBLIC cxx_std_11)
+
+target_include_directories(imguizmo PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/imguizmo/include")
+
+include(imgui)
+target_link_libraries(imguizmo PUBLIC imgui::imgui)
+
+set_target_properties(imguizmo PROPERTIES FOLDER ThirdParty)

+ 25 - 0
cmake/recipes/external/libigl_imgui_fonts.cmake

@@ -0,0 +1,25 @@
+if(TARGET igl::imgui_fonts)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'igl::imgui_fonts'")
+
+include(FetchContent)
+FetchContent_Declare(
+    libigl_imgui_fonts
+    GIT_REPOSITORY https://github.com/libigl/libigl-imgui.git
+    GIT_TAG        7e1053e750b0f4c129b046f4e455243cb7f804f3
+)
+FetchContent_GetProperties(libigl_imgui_fonts)
+if(NOT libigl_imgui_fonts_POPULATED)
+    FetchContent_Populate(libigl_imgui_fonts)
+endif()
+
+add_library(igl_imgui_fonts INTERFACE)
+add_library(igl::imgui_fonts ALIAS igl_imgui_fonts)
+
+include(GNUInstallDirs)
+target_include_directories(igl_imgui_fonts SYSTEM INTERFACE
+    $<BUILD_INTERFACE:${libigl_imgui_fonts_SOURCE_DIR}>
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)

+ 18 - 0
cmake/recipes/external/libigl_tests_data.cmake

@@ -0,0 +1,18 @@
+if(TARGET igl::tests_data)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'igl::tests_data'")
+
+include(FetchContent)
+FetchContent_Declare(
+    libigl_tests_tata
+    GIT_REPOSITORY https://github.com/libigl/libigl-tests-data
+    GIT_TAG        19cedf96d70702d8b3a83eb27934780c542356fe
+)
+FetchContent_MakeAvailable(libigl_tests_tata)
+
+add_library(igl_tests_data INTERFACE)
+add_library(igl::tests_data ALIAS igl_tests_data)
+
+target_compile_definitions(igl_tests_data INTERFACE LIBIGL_DATA_DIR=\"${libigl_tests_tata_SOURCE_DIR}\")

+ 18 - 0
cmake/recipes/external/libigl_tutorial_data.cmake

@@ -0,0 +1,18 @@
+if(TARGET igl::tutorial_data)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'igl::tutorial_data'")
+
+include(FetchContent)
+FetchContent_Declare(
+    libigl_tutorial_tata
+    GIT_REPOSITORY https://github.com/libigl/libigl-tutorial-data
+    GIT_TAG        c1f9ede366d02e3531ecbaec5e3769312f31cccd
+)
+FetchContent_MakeAvailable(libigl_tutorial_tata)
+
+add_library(igl_tutorial_data INTERFACE)
+add_library(igl::tutorial_data ALIAS igl_tutorial_data)
+
+target_compile_definitions(igl_tutorial_data INTERFACE "-DTUTORIAL_SHARED_PATH=\"${libigl_tutorial_tata_SOURCE_DIR}\"")

+ 15 - 0
cmake/recipes/external/mpfr.cmake

@@ -0,0 +1,15 @@
+if(TARGET mpfr::mpfr)
+    return()
+endif()
+
+# Download precompiled .dll on Windows
+include(gmp_mpfr)
+
+message(STATUS "Third-party: creating target 'mpfr::mpfr'")
+
+# Find_package will look for our downloaded lib on Windows, and system-wide on Linux/macOS
+find_package(MPFR REQUIRED)
+
+if(NOT TARGET mpfr::mpfr)
+    message(FATAL_ERROR "Creation of target 'mpfr::mpfr' failed")
+endif()

+ 17 - 0
cmake/recipes/external/predicates.cmake

@@ -0,0 +1,17 @@
+if(TARGET predicates::predicates)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'predicates::predicates'")
+
+include(FetchContent)
+FetchContent_Declare(
+    predicates
+    GIT_REPOSITORY https://github.com/libigl/libigl-predicates.git
+    GIT_TAG        488242fa2b1f98a9c5bd1441297fb4a99a6a9ae4
+)
+
+FetchContent_MakeAvailable(predicates)
+add_library(predicates::predicates ALIAS predicates)
+
+set_target_properties(predicates PROPERTIES FOLDER ThirdParty)

+ 32 - 0
cmake/recipes/external/stb.cmake

@@ -0,0 +1,32 @@
+if(TARGET stb::stb)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'stb::stb'")
+
+include(FetchContent)
+FetchContent_Declare(
+    stb
+    GIT_REPOSITORY https://github.com/nothings/stb.git
+    GIT_TAG f67165c2bb2af3060ecae7d20d6f731173485ad0
+)
+FetchContent_MakeAvailable(stb)
+
+# Generate implementation file
+file(WRITE "${stb_BINARY_DIR}/stb_image.cpp.in" [[
+    #define STB_IMAGE_IMPLEMENTATION
+    #include <stb_image.h>
+
+    #define STB_IMAGE_WRITE_IMPLEMENTATION
+    #include <stb_image_write.h>
+]])
+
+configure_file(${stb_BINARY_DIR}/stb_image.cpp.in ${stb_BINARY_DIR}/stb_image.cpp COPYONLY)
+
+# Define stb library
+add_library(stb ${stb_BINARY_DIR}/stb_image.cpp)
+add_library(stb::stb ALIAS stb)
+
+target_include_directories(stb PUBLIC "${stb_SOURCE_DIR}")
+
+set_target_properties(stb PROPERTIES FOLDER ThirdParty)

+ 19 - 0
cmake/recipes/external/tetgen.cmake

@@ -0,0 +1,19 @@
+if(TARGET tetgen::tetgen)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'tetgen::tetgen'")
+
+include(FetchContent)
+FetchContent_Declare(
+    tetgen
+    GIT_REPOSITORY https://github.com/libigl/tetgen.git
+    GIT_TAG        4f3bfba3997f20aa1f96cfaff604313a8c2c85b6
+)
+
+FetchContent_MakeAvailable(tetgen)
+add_library(tetgen::tetgen ALIAS tetgen)
+
+target_include_directories(tetgen INTERFACE "${tetgen_SOURCE_DIR}")
+
+set_target_properties(tetgen PROPERTIES FOLDER ThirdParty)

+ 24 - 0
cmake/recipes/external/tinyxml2.cmake

@@ -0,0 +1,24 @@
+if(TARGET tinyxml2::tinyxml2)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'tinyxml2::tinyxml2'")
+
+# TODO: Update tinyxml2 version + use FetchContent_MakeAvailable with upstream CMake code
+include(FetchContent)
+FetchContent_Declare(
+    tinyxml2
+    GIT_REPOSITORY https://github.com/leethomason/tinyxml2.git
+    GIT_TAG        d175e9de0be0d4db75d0a8cf065599a435a87eb6
+)
+FetchContent_GetProperties(tinyxml2)
+if(NOT tinyxml2_POPULATED)
+    FetchContent_Populate(tinyxml2)
+endif()
+
+add_library(tinyxml2 STATIC ${tinyxml2_SOURCE_DIR}/tinyxml2.cpp ${tinyxml2_SOURCE_DIR}/tinyxml2.h)
+add_library(tinyxml2::tinyxml2 ALIAS tinyxml2)
+target_include_directories(tinyxml2 PUBLIC ${tinyxml2_SOURCE_DIR})
+set_target_properties(tinyxml2 PROPERTIES DEFINE_SYMBOL "TINYXML2_EXPORT")
+
+set_target_properties(tinyxml2 PROPERTIES FOLDER ThirdParty)

+ 19 - 0
cmake/recipes/external/triangle.cmake

@@ -0,0 +1,19 @@
+if(TARGET triangle::triangle)
+    return()
+endif()
+
+message(STATUS "Third-party: creating target 'triangle::triangle'")
+
+include(FetchContent)
+FetchContent_Declare(
+    triangle
+    GIT_REPOSITORY https://github.com/libigl/triangle.git
+    GIT_TAG        3ee6cac2230f0fe1413879574f741c7b6da11221
+)
+
+FetchContent_MakeAvailable(triangle)
+add_library(triangle::triangle ALIAS triangle)
+
+target_include_directories(triangle INTERFACE "${triangle_SOURCE_DIR}")
+
+set_target_properties(triangle PROPERTIES FOLDER ThirdParty)

+ 5 - 0
cmake/recipes/hunter/boost.cmake

@@ -0,0 +1,5 @@
+get_filename_component(current_filename ${CMAKE_CURRENT_LIST_FILE} NAME_WLE)
+message(FATAL_ERROR
+    "${current_filename} is not set up to be used with Hunter. "
+    "Please disable the libigl modules depending on it, or set HUNTER_ENABLED to OFF."
+)

+ 1 - 0
cmake/recipes/hunter/catch2.cmake

@@ -0,0 +1 @@
+include(${CMAKE_CURRENT_LIST_DIR}/../external/catch2.cmake)

+ 5 - 0
cmake/recipes/hunter/cgal.cmake

@@ -0,0 +1,5 @@
+get_filename_component(current_filename ${CMAKE_CURRENT_LIST_FILE} NAME_WLE)
+message(FATAL_ERROR
+    "${current_filename} is not set up to be used with Hunter. "
+    "Please disable the libigl modules depending on it, or set HUNTER_ENABLED to OFF."
+)

+ 5 - 0
cmake/recipes/hunter/comiso.cmake

@@ -0,0 +1,5 @@
+get_filename_component(current_filename ${CMAKE_CURRENT_LIST_FILE} NAME_WLE)
+message(FATAL_ERROR
+    "${current_filename} is not set up to be used with Hunter. "
+    "Please disable the libigl modules depending on it, or set HUNTER_ENABLED to OFF."
+)

+ 2 - 0
cmake/recipes/hunter/eigen.cmake

@@ -0,0 +1,2 @@
+hunter_add_package(Eigen)
+find_package(Eigen3 CONFIG REQUIRED)

+ 5 - 0
cmake/recipes/hunter/embree.cmake

@@ -0,0 +1,5 @@
+get_filename_component(current_filename ${CMAKE_CURRENT_LIST_FILE} NAME_WLE)
+message(FATAL_ERROR
+    "${current_filename} is not set up to be used with Hunter. "
+    "Please disable the libigl modules depending on it, or set HUNTER_ENABLED to OFF."
+)

+ 5 - 0
cmake/recipes/hunter/glad.cmake

@@ -0,0 +1,5 @@
+get_filename_component(current_filename ${CMAKE_CURRENT_LIST_FILE} NAME_WLE)
+message(FATAL_ERROR
+    "${current_filename} is not set up to be used with Hunter. "
+    "Please disable the libigl modules depending on it, or set HUNTER_ENABLED to OFF."
+)

+ 5 - 0
cmake/recipes/hunter/glfw.cmake

@@ -0,0 +1,5 @@
+get_filename_component(current_filename ${CMAKE_CURRENT_LIST_FILE} NAME_WLE)
+message(FATAL_ERROR
+    "${current_filename} is not set up to be used with Hunter. "
+    "Please disable the libigl modules depending on it, or set HUNTER_ENABLED to OFF."
+)

+ 5 - 0
cmake/recipes/hunter/gmp.cmake

@@ -0,0 +1,5 @@
+get_filename_component(current_filename ${CMAKE_CURRENT_LIST_FILE} NAME_WLE)
+message(FATAL_ERROR
+    "${current_filename} is not set up to be used with Hunter. "
+    "Please disable the libigl modules depending on it, or set HUNTER_ENABLED to OFF."
+)

+ 5 - 0
cmake/recipes/hunter/imgui.cmake

@@ -0,0 +1,5 @@
+get_filename_component(current_filename ${CMAKE_CURRENT_LIST_FILE} NAME_WLE)
+message(FATAL_ERROR
+    "${current_filename} is not set up to be used with Hunter. "
+    "Please disable the libigl modules depending on it, or set HUNTER_ENABLED to OFF."
+)

+ 5 - 0
cmake/recipes/hunter/imguizmo.cmake

@@ -0,0 +1,5 @@
+get_filename_component(current_filename ${CMAKE_CURRENT_LIST_FILE} NAME_WLE)
+message(FATAL_ERROR
+    "${current_filename} is not set up to be used with Hunter. "
+    "Please disable the libigl modules depending on it, or set HUNTER_ENABLED to OFF."
+)

+ 5 - 0
cmake/recipes/hunter/libigl_imgui_fonts.cmake

@@ -0,0 +1,5 @@
+get_filename_component(current_filename ${CMAKE_CURRENT_LIST_FILE} NAME_WLE)
+message(FATAL_ERROR
+    "${current_filename} is not set up to be used with Hunter. "
+    "Please disable the libigl modules depending on it, or set HUNTER_ENABLED to OFF."
+)

+ 1 - 0
cmake/recipes/hunter/libigl_tests_data.cmake

@@ -0,0 +1 @@
+include(${CMAKE_CURRENT_LIST_DIR}/../external/libigl_tests_data.cmake)

+ 1 - 0
cmake/recipes/hunter/libigl_tutorial_data.cmake

@@ -0,0 +1 @@
+include(${CMAKE_CURRENT_LIST_DIR}/../external/libigl_tutorial_data.cmake)

+ 5 - 0
cmake/recipes/hunter/mpfr.cmake

@@ -0,0 +1,5 @@
+get_filename_component(current_filename ${CMAKE_CURRENT_LIST_FILE} NAME_WLE)
+message(FATAL_ERROR
+    "${current_filename} is not set up to be used with Hunter. "
+    "Please disable the libigl modules depending on it, or set HUNTER_ENABLED to OFF."
+)

+ 5 - 0
cmake/recipes/hunter/predicates.cmake

@@ -0,0 +1,5 @@
+get_filename_component(current_filename ${CMAKE_CURRENT_LIST_FILE} NAME_WLE)
+message(FATAL_ERROR
+    "${current_filename} is not set up to be used with Hunter. "
+    "Please disable the libigl modules depending on it, or set HUNTER_ENABLED to OFF."
+)

+ 5 - 0
cmake/recipes/hunter/stb.cmake

@@ -0,0 +1,5 @@
+get_filename_component(current_filename ${CMAKE_CURRENT_LIST_FILE} NAME_WLE)
+message(FATAL_ERROR
+    "${current_filename} is not set up to be used with Hunter. "
+    "Please disable the libigl modules depending on it, or set HUNTER_ENABLED to OFF."
+)

+ 5 - 0
cmake/recipes/hunter/tetgen.cmake

@@ -0,0 +1,5 @@
+get_filename_component(current_filename ${CMAKE_CURRENT_LIST_FILE} NAME_WLE)
+message(FATAL_ERROR
+    "${current_filename} is not set up to be used with Hunter. "
+    "Please disable the libigl modules depending on it, or set HUNTER_ENABLED to OFF."
+)

+ 5 - 0
cmake/recipes/hunter/tinyxml2.cmake

@@ -0,0 +1,5 @@
+get_filename_component(current_filename ${CMAKE_CURRENT_LIST_FILE} NAME_WLE)
+message(FATAL_ERROR
+    "${current_filename} is not set up to be used with Hunter. "
+    "Please disable the libigl modules depending on it, or set HUNTER_ENABLED to OFF."
+)

+ 5 - 0
cmake/recipes/hunter/triangle.cmake

@@ -0,0 +1,5 @@
+get_filename_component(current_filename ${CMAKE_CURRENT_LIST_FILE} NAME_WLE)
+message(FATAL_ERROR
+    "${current_filename} is not set up to be used with Hunter. "
+    "Please disable the libigl modules depending on it, or set HUNTER_ENABLED to OFF."
+)

+ 11 - 11
include/igl/copyleft/cgal/assign.cpp

@@ -1,9 +1,9 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2016 Alec Jacobson <[email protected]>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "assign.h"
 #include "assign_scalar.h"
@@ -24,23 +24,23 @@ IGL_INLINE void igl::copyleft::cgal::assign(
 }
 
 template <typename ReturnScalar, typename DerivedC>
-IGL_INLINE 
+IGL_INLINE
 Eigen::Matrix<
   ReturnScalar,
-  DerivedC::RowsAtCompileTime, 
-  DerivedC::ColsAtCompileTime, 
+  DerivedC::RowsAtCompileTime,
+  DerivedC::ColsAtCompileTime,
   1,
-  DerivedC::MaxRowsAtCompileTime, 
+  DerivedC::MaxRowsAtCompileTime,
   DerivedC::MaxColsAtCompileTime>
 igl::copyleft::cgal::assign(
   const Eigen::MatrixBase<DerivedC> & C)
 {
   Eigen::Matrix<
     ReturnScalar,
-    DerivedC::RowsAtCompileTime, 
-    DerivedC::ColsAtCompileTime, 
+    DerivedC::RowsAtCompileTime,
+    DerivedC::ColsAtCompileTime,
     1,
-    DerivedC::MaxRowsAtCompileTime, 
+    DerivedC::MaxRowsAtCompileTime,
     DerivedC::MaxColsAtCompileTime> D;
   assign(C,D);
   return D;

+ 0 - 41
include/igl/copyleft/cork/from_cork_mesh.cpp

@@ -1,41 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2015 Alec Jacobson <[email protected]>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#include "from_cork_mesh.h"
-
-template <
-  typename DerivedV,
-  typename DerivedF>
-IGL_INLINE void igl::copyleft::cork::from_cork_mesh(
-  const CorkTriMesh & mesh,
-  Eigen::PlainObjectBase<DerivedV > & V,
-  Eigen::PlainObjectBase<DerivedF > & F)
-{
-  using namespace std;
-  F.resize(mesh.n_triangles,3);
-  V.resize(mesh.n_vertices,3);
-  for(size_t v = 0;v<mesh.n_vertices;v++)
-  {
-    for(size_t c = 0;c<3;c++)
-    {
-      V(v,c) = mesh.vertices[v*3+c];
-    }
-  }
-  for(size_t f = 0;f<mesh.n_triangles;f++)
-  {
-    for(size_t c = 0;c<3;c++)
-    {
-      F(f,c) = mesh.triangles[f*3+c];
-    }
-  }
-}
-
-#ifdef IGL_STATIC_LIBRARY
-// Explicit template instantiation
-template void igl::copyleft::cork::from_cork_mesh<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(CorkTriMesh const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
-template void igl::copyleft::cork::from_cork_mesh<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(CorkTriMesh const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
-#endif

+ 0 - 39
include/igl/copyleft/cork/from_cork_mesh.h

@@ -1,39 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2015 Alec Jacobson <[email protected]>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_COPYLEFT_CORK_FROM_CORK_MESH_H
-#define IGL_COPYLEFT_CORK_FROM_CORK_MESH_H
-#include "../../igl_inline.h"
-#include <cork.h>
-#include <Eigen/Core>
-namespace igl
-{
-  namespace copyleft
-  {
-    namespace cork
-    {
-      // Convert cork's triangle mesh representation to a (V,F) mesh.
-      //
-      // Inputs:
-      //   mesh  cork representation of mesh
-      // Outputs:
-      //   V  #V by 3 list of vertex positions
-      //   F  #F by 3 list of triangle indices into V
-      template <
-        typename DerivedV,
-        typename DerivedF>
-      IGL_INLINE void from_cork_mesh(
-        const CorkTriMesh & mesh,
-        Eigen::PlainObjectBase<DerivedV > & V,
-        Eigen::PlainObjectBase<DerivedF > & F);
-    }
-  }
-}
-#ifndef IGL_STATIC_LIBRARY
-#  include "from_cork_mesh.cpp"
-#endif
-#endif

+ 0 - 99
include/igl/copyleft/cork/mesh_boolean.cpp

@@ -1,99 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2015 Alec Jacobson <[email protected]>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#include "mesh_boolean.h"
-#include "to_cork_mesh.h"
-#include "from_cork_mesh.h"
-
-template <
-  typename DerivedVA,
-  typename DerivedFA,
-  typename DerivedVB,
-  typename DerivedFB,
-  typename DerivedVC,
-  typename DerivedFC>
-IGL_INLINE void igl::copyleft::cork::mesh_boolean(
-  const Eigen::PlainObjectBase<DerivedVA > & VA,
-  const Eigen::PlainObjectBase<DerivedFA > & FA,
-  const Eigen::PlainObjectBase<DerivedVB > & VB,
-  const Eigen::PlainObjectBase<DerivedFB > & FB,
-  const MeshBooleanType & type,
-  Eigen::PlainObjectBase<DerivedVC > & VC,
-  Eigen::PlainObjectBase<DerivedFC > & FC)
-{
-  CorkTriMesh A,B,C;
-  // pointer to output so it's easy to redirect on degenerate cases
-  CorkTriMesh *ret = &C;
-  to_cork_mesh(VA,FA,A);
-  to_cork_mesh(VB,FB,B);
-  switch(type)
-  {
-    case MESH_BOOLEAN_TYPE_UNION:
-      if(A.n_triangles == 0)
-      {
-        ret = &B;
-      }else if(B.n_triangles == 0)
-      {
-        ret = &A;
-      }else
-      {
-        computeUnion(A,B,ret);
-      }
-      break;
-    case MESH_BOOLEAN_TYPE_INTERSECT:
-      if(A.n_triangles == 0 || B.n_triangles == 0)
-      {
-        ret->n_triangles = 0;
-        ret->n_vertices = 0;
-      }else
-      {
-        computeIntersection(A,B,ret);
-      }
-      break;
-    case MESH_BOOLEAN_TYPE_MINUS:
-      if(A.n_triangles == 0)
-      {
-        ret->n_triangles = 0;
-        ret->n_vertices = 0;
-      }else if(B.n_triangles == 0)
-      {
-        ret = &A;
-      }else
-      {
-        computeDifference(A,B,ret);
-      }
-      break;
-    case MESH_BOOLEAN_TYPE_XOR:
-      if(A.n_triangles == 0)
-      {
-        ret = &B;
-      }else if(B.n_triangles == 0)
-      {
-        ret = &A;
-      }else
-      {
-        computeSymmetricDifference(A,B,&C);
-      }
-      break;
-    case MESH_BOOLEAN_TYPE_RESOLVE:
-      resolveIntersections(A,B,&C);
-      break;
-    default:
-      assert(false && "Unknown type");
-      return;
-  }
-  from_cork_mesh(*ret,VC,FC);
-  freeCorkTriMesh(&A);
-  freeCorkTriMesh(&B);
-  freeCorkTriMesh(&C);
-}
-#ifdef IGL_STATIC_LIBRARY
-// Explicit template instantiation
-template void igl::copyleft::cork::mesh_boolean<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, MeshBooleanType const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
-template void igl::copyleft::cork::mesh_boolean<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, igl::MeshBooleanType const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
-#endif
-

+ 0 - 55
include/igl/copyleft/cork/mesh_boolean.h

@@ -1,55 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2015 Alec Jacobson <[email protected]>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_COPYLEFT_CORK_MESH_BOOLEAN_H
-#define IGL_COPYLEFT_CORK_MESH_BOOLEAN_H
-#include "../../MeshBooleanType.h"
-#include "../../igl_inline.h"
-#include <Eigen/Core>
-#include <cork.h> // for consistent uint
-
-namespace igl
-{
-  namespace copyleft
-  {
-    namespace cork
-    {
-      // Compute a boolean operation on two input meshes using the cork library.
-      //
-      // Inputs:
-      //   VA  #VA by 3 list of vertex positions of first mesh
-      //   FA  #FA by 3 list of triangle indices into VA
-      //   VB  #VB by 3 list of vertex positions of second mesh
-      //   FB  #FB by 3 list of triangle indices into VB
-      //   type  of boolean operation see MeshBooleanType.h
-      // Outputs:
-      //   VC  #VC by 3 list of vertex positions of output mesh
-      //   FC  #FC by 3 list of triangle indices into VC
-      template <
-        typename DerivedVA,
-        typename DerivedFA,
-        typename DerivedVB,
-        typename DerivedFB,
-        typename DerivedVC,
-        typename DerivedFC>
-      IGL_INLINE void mesh_boolean(
-        const Eigen::PlainObjectBase<DerivedVA > & VA,
-        const Eigen::PlainObjectBase<DerivedFA > & FA,
-        const Eigen::PlainObjectBase<DerivedVB > & VB,
-        const Eigen::PlainObjectBase<DerivedFB > & FB,
-        const MeshBooleanType & type,
-        Eigen::PlainObjectBase<DerivedVC > & VC,
-        Eigen::PlainObjectBase<DerivedFC > & FC);
-    }
-  }
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "mesh_boolean.cpp"
-#endif
-
-#endif

+ 0 - 43
include/igl/copyleft/cork/to_cork_mesh.cpp

@@ -1,43 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2015 Alec Jacobson <[email protected]>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#include "to_cork_mesh.h"
-template <
-  typename DerivedV,
-  typename DerivedF>
-IGL_INLINE void igl::copyleft::cork::to_cork_mesh(
-  const Eigen::PlainObjectBase<DerivedV > & V,
-  const Eigen::PlainObjectBase<DerivedF > & F,
-  CorkTriMesh & mesh)
-{
-  using namespace std;
-  assert((F.cols() == 0 || F.cols() == 3) && "Facets should be triangles.");
-  assert((V.cols() == 0 || V.cols() == 3) && "Vertices should be in 3D.");
-  mesh.n_triangles = F.rows();
-  mesh.n_vertices = V.rows();
-  mesh.vertices = new float[mesh.n_vertices*3];
-  mesh.triangles = new uint[mesh.n_triangles*3];
-  for(size_t v = 0;v<mesh.n_vertices;v++)
-  {
-    for(size_t c = 0;c<3;c++)
-    {
-      mesh.vertices[v*3+c] = V(v,c);
-    }
-  }
-  for(size_t f = 0;f<mesh.n_triangles;f++)
-  {
-    for(size_t c = 0;c<3;c++)
-    {
-      mesh.triangles[f*3+c] = F(f,c);
-    }
-  }
-}
-#ifdef IGL_STATIC_LIBRARY
-// Explicit template instantiation
-template void igl::copyleft::cork::to_cork_mesh<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, CorkTriMesh&);
-template void igl::copyleft::cork::to_cork_mesh<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, CorkTriMesh&);
-#endif

+ 0 - 39
include/igl/copyleft/cork/to_cork_mesh.h

@@ -1,39 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2015 Alec Jacobson <[email protected]>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_COPYLEFT_CORK_TO_CORK_MESH_H
-#define IGL_COPYLEFT_CORK_TO_CORK_MESH_H
-#include "../../igl_inline.h"
-#include <cork.h>
-#include <Eigen/Core>
-namespace igl
-{
-  namespace copyleft
-  {
-    namespace cork
-    {
-      // Convert a (V,F) mesh to a cork's triangle mesh representation.
-      //
-      // Inputs:
-      //   V  #V by 3 list of vertex positions
-      //   F  #F by 3 list of triangle indices into V
-      // Outputs:
-      //   mesh  cork representation of mesh
-      template <
-        typename DerivedV,
-        typename DerivedF>
-      IGL_INLINE void to_cork_mesh(
-        const Eigen::PlainObjectBase<DerivedV > & V,
-        const Eigen::PlainObjectBase<DerivedF > & F,
-        CorkTriMesh & mesh);
-    }
-  }
-}
-#ifndef IGL_STATIC_LIBRARY
-#  include "to_cork_mesh.cpp"
-#endif
-#endif

+ 2 - 2
include/igl/opengl/glfw/imgui/ImGuiMenu.cpp

@@ -185,7 +185,7 @@ IGL_INLINE void ImGuiMenu::draw_viewer_menu()
   // Workspace
   if (ImGui::CollapsingHeader("Workspace", ImGuiTreeNodeFlags_DefaultOpen))
   {
-    float w = ImGui::GetContentRegionAvailWidth();
+    float w = ImGui::GetContentRegionAvail().x;
     float p = ImGui::GetStyle().FramePadding.x;
     if (ImGui::Button("Load##Workspace", ImVec2((w-p)/2.f, 0)))
     {
@@ -201,7 +201,7 @@ IGL_INLINE void ImGuiMenu::draw_viewer_menu()
   // Mesh
   if (ImGui::CollapsingHeader("Mesh", ImGuiTreeNodeFlags_DefaultOpen))
   {
-    float w = ImGui::GetContentRegionAvailWidth();
+    float w = ImGui::GetContentRegionAvail().x;
     float p = ImGui::GetStyle().FramePadding.x;
     if (ImGui::Button("Load##Mesh", ImVec2((w-p)/2.f, 0)))
     {

+ 2 - 2
include/igl/png/readPNG.cpp

@@ -6,7 +6,7 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "readPNG.h"
-#include <igl_stb_image.h>
+#include <stb_image.h>
 
 IGL_INLINE bool igl::png::readPNG(
   const std::string png_file,
@@ -36,7 +36,7 @@ IGL_INLINE bool igl::png::readPNG(
     }
   }
 
-  igl::stbi_image_free(data);
+  stbi_image_free(data);
 
   return true;
 }

+ 2 - 2
include/igl/png/render_to_png.cpp

@@ -6,7 +6,7 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "render_to_png.h"
-#include <igl_stb_image.h>
+#include <stb_image_write.h>
 
 #include "../opengl/gl.h"
 
@@ -35,7 +35,7 @@ IGL_INLINE bool igl::png::render_to_png(
       data[4*(i+j*width)+3] = 255;
     }
   }
-  bool ret = igl::stbi_write_png(png_file.c_str(), width, height, 4, data, 4*width*sizeof(unsigned char));
+  bool ret = stbi_write_png(png_file.c_str(), width, height, 4, data, 4*width*sizeof(unsigned char));
   delete [] data;
   return ret;
 }

+ 2 - 2
include/igl/png/render_to_png_async.cpp

@@ -7,7 +7,7 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "render_to_png_async.h"
 #include "../opengl/gl.h"
-#include <igl_stb_image.h>
+#include <stb_image_write.h>
 
 static IGL_INLINE bool render_to_png_async_helper(
   unsigned char * img, int width, int height,
@@ -25,7 +25,7 @@ static IGL_INLINE bool render_to_png_async_helper(
     }
   }
 
-  bool ret = igl::stbi_write_png(png_file.c_str(), width, height, 4, img, width*sizeof(unsigned char));
+  bool ret = stbi_write_png(png_file.c_str(), width, height, 4, img, width*sizeof(unsigned char));
   delete [] img;
   return ret;
 }

+ 5 - 5
include/igl/png/texture_from_png.cpp

@@ -8,12 +8,12 @@
 #include "texture_from_png.h"
 
 #include "../opengl/report_gl_error.h"
-#include <igl_stb_image.h>
+#include <stb_image.h>
 
 IGL_INLINE bool igl::png::texture_from_png(const std::string png_file, const bool flip, GLuint & id)
 {
   int width,height,n;
-  unsigned char *data = igl::stbi_load(png_file.c_str(), &width, &height, &n, 4);
+  unsigned char *data = stbi_load(png_file.c_str(), &width, &height, &n, 4);
   if(data == NULL) {
     return false;
   }
@@ -35,7 +35,7 @@ IGL_INLINE bool igl::png::texture_from_png(const std::string png_file, const boo
     width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
   glBindTexture(GL_TEXTURE_2D, 0);
 
-  igl::stbi_image_free(data);
+  stbi_image_free(data);
 
   return true;
 }
@@ -55,7 +55,7 @@ IGL_INLINE bool igl::png::texture_from_png(
 )
 {
   int width,height,n;
-  unsigned char *data = igl::stbi_load(png_file.c_str(), &width, &height, &n, 4);
+  unsigned char *data = stbi_load(png_file.c_str(), &width, &height, &n, 4);
   if(data == NULL) {
     return false;
   }
@@ -77,7 +77,7 @@ IGL_INLINE bool igl::png::texture_from_png(
     }
   }
 
-  igl::stbi_image_free(data);
+  stbi_image_free(data);
 
   return true;
 }

+ 2 - 2
include/igl/png/writePNG.cpp

@@ -6,7 +6,7 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "writePNG.h"
-#include <igl_stb_image.h>
+#include <stb_image_write.h>
 #include <vector>
 
 IGL_INLINE bool igl::png::writePNG(
@@ -35,7 +35,7 @@ IGL_INLINE bool igl::png::writePNG(
     }
   }
 
-  igl::stbi_write_png(png_file.c_str(), R.rows(), R.cols(), comp, data.data(), stride_in_bytes);
+  stbi_write_png(png_file.c_str(), R.rows(), R.cols(), comp, data.data(), stride_in_bytes);
 
   return true;
 }

+ 0 - 119
tests/CMakeLists.txt

@@ -1,119 +0,0 @@
-cmake_minimum_required(VERSION 3.1)
-project(libigl_tests)
-
-list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake)
-
-### Adding libIGL: choose the path to your local copy libIGL
-if(NOT TARGET igl::core)
-  include(libigl)
-else()
-  include(LibiglDownloadExternal)
-endif()
-
-### Download data
-igl_download_test_data()
-set(IGL_TEST_DATA ${LIBIGL_EXTERNAL}/../tests/data)
-
-### Download Catch2 unit test framework
-igl_download_catch2()
-list(APPEND CMAKE_MODULE_PATH ${LIBIGL_EXTERNAL}/catch2/contrib)
-
-
-# Add catch2
-add_subdirectory(${LIBIGL_EXTERNAL}/catch2 catch2)
-
-
-# Create test executable
-add_executable(libigl_tests main.cpp test_common.h)
-target_link_libraries(libigl_tests PUBLIC igl::core Catch2::Catch2)
-target_include_directories(libigl_tests PUBLIC ${CMAKE_CURRENT_LIST_DIR})
-target_compile_definitions(libigl_tests PUBLIC CATCH_CONFIG_ENABLE_BENCHMARKING)
-
-# Set DATA_DIR definition
-set(DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/data/")
-target_compile_definitions(libigl_tests PUBLIC -DLIBIGL_DATA_DIR="${IGL_TEST_DATA}")
-
-# Silencing some compile warnings
-if(MSVC)
-  target_compile_options(libigl_tests PRIVATE
-    # Type conversion warnings. These can be fixed with some effort and possibly more verbose code.
-    /wd4267 # conversion from 'size_t' to 'type', possible loss of data
-    /wd4244 # conversion from 'type1' to 'type2', possible loss of data
-    /wd4018 # signed/unsigned mismatch
-    /wd4305 # truncation from 'double' to 'float'
-  )
-endif(MSVC)
-
-# Process code in each subdirectories: add in decreasing order of complexity
-# (last added will run first and those should be the fastest tests)
-if(LIBIGL_WITH_MOSEK)
-  file(GLOB TEST_SRC_FILES ./include/igl/mosek/*.cpp)
-  file(GLOB TEST_INC_FILES ./include/igl/mosek/*.h ./include/igl/mosek/*.inl)
-  target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES})
-
-  target_link_libraries(libigl_tests PUBLIC igl::mosek)
-  # fix mosek
-  IF(APPLE)
-    INCLUDE(../cmake/OSXFixDylibReferences.cmake)
-    OSX_FIX_DYLIB_REFERENCES(libigl_tests "${MOSEK_LIBRARIES}")
-  ENDIF()
-endif()
-
-if(LIBIGL_WITH_CGAL)
-  file(GLOB TEST_SRC_FILES ./include/igl/copyleft/boolean/*.cpp ./include/igl/copyleft/cgal/*.cpp)
-  file(GLOB TEST_INC_FILES ./include/igl/copyleft/boolean/*.h ./include/igl/copyleft/cgal/*.h ./include/igl/copyleft/boolean/*.inl ./include/igl/copyleft/cgal/*.inl)
-  target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES})
-
-  target_link_libraries(libigl_tests PUBLIC igl::cgal)
-  igl_copy_cgal_dll(libigl_tests)
-endif()
-
-if(LIBIGL_WITH_TETGEN)
-  file(GLOB TEST_SRC_FILES ./include/igl/copyleft/tetgen/*.cpp)
-  file(GLOB TEST_INC_FILES ./include/igl/copyleft/tetgen/*.h ./include/igl/copyleft/tetgen/*.inl)
-  target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES})
-
-  target_link_libraries(libigl_tests PUBLIC igl::tetgen)
-endif()
-
-if(LIBIGL_WITH_COMISO)
-  file(GLOB TEST_SRC_FILES ./include/igl/copyleft/comiso/*.cpp)
-  file(GLOB TEST_INC_FILES ./include/igl/copyleft/comiso/*.h ./include/igl/copyleft/comiso/*.inl)
-  target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES})
-
-  target_link_libraries(libigl_tests PUBLIC igl::comiso)
-endif()
-
-if(LIBIGL_WITH_EMBREE)
-  file(GLOB TEST_SRC_FILES ./include/igl/embree/*.cpp)
-  file(GLOB TEST_INC_FILES ./include/igl/embree/*.h ./include/igl/embree/*.inl)
-  target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES})
-
-  target_link_libraries(libigl_tests PUBLIC igl::embree)
-endif()
-
-if(LIBIGL_WITH_PREDICATES AND LIBIGL_WITH_TRIANGLE)
-  file(GLOB TEST_SRC_FILES ./include/igl/predicates/*.cpp)
-  file(GLOB TEST_INC_FILES ./include/igl/predicates/*.h ./include/igl/predicates/*.inl)
-  target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES})
-
-  target_link_libraries(libigl_tests PUBLIC igl::predicates igl::triangle)
-endif()
-
-if(LIBIGL_WITH_TRIANGLE)
-  file(GLOB TEST_SRC_FILES ./include/igl/triangle/*.cpp)
-  file(GLOB TEST_INC_FILES ./include/igl/triangle/*.h ./include/igl/triangle/*.inl)
-  target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES})
-
-  target_link_libraries(libigl_tests PUBLIC igl::triangle)
-endif()
-
-file(GLOB TEST_SRC_FILES ./include/igl/*.cpp)
-file(GLOB TEST_INC_FILES ./include/igl/*.h ./include/igl/*.inl)
-target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES})
-
-
-# Register tests
-set(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS ON)
-include(Catch)
-catch_discover_tests(libigl_tests)

Some files were not shown because too many files changed in this diff