瀏覽代碼

Merge branch 'cmake' of https://github.com/jdumas/libigl

Former-commit-id: dc9af94b447454ac56179e0d3d53e57a802ad8f1
Daniele Panozzo 7 年之前
父節點
當前提交
017c21a0f5
共有 83 個文件被更改,包括 816 次插入583 次删除
  1. 2 1
      .appveyor.yml
  2. 4 4
      .gitmodules
  3. 3 2
      .travis.yml
  4. 4 4
      include/igl/copyleft/cgal/CGAL_includes.hpp
  5. 13 13
      include/igl/copyleft/cgal/insert_into_cdt.cpp
  6. 8 7
      include/igl/copyleft/cgal/insert_into_cdt.h
  7. 8 8
      include/igl/copyleft/cgal/projected_cdt.cpp
  8. 6 5
      include/igl/copyleft/cgal/projected_cdt.h
  9. 2 2
      include/igl/png/readPNG.cpp
  10. 2 2
      include/igl/png/render_to_png.cpp
  11. 2 2
      include/igl/png/render_to_png_async.cpp
  12. 6 6
      include/igl/png/texture_from_png.cpp
  13. 2 2
      include/igl/png/writePNG.cpp
  14. 1 0
      include/igl/sortrows.cpp
  15. 1 0
      include/igl/unique_rows.cpp
  16. 40 40
      include/igl/xml/XMLSerializable.h
  17. 18 18
      include/igl/xml/serialize_xml.h
  18. 3 3
      include/igl/xml/writeDAE.cpp
  19. 72 101
      python/CMakeLists.txt
  20. 2 1
      shared/cmake/CMakeLists.txt
  21. 85 0
      shared/cmake/CXXFeatures.cmake
  22. 27 18
      shared/cmake/FindMOSEK.cmake
  23. 362 0
      shared/cmake/libigl.cmake
  24. 2 5
      tutorial/101_FileIO/CMakeLists.txt
  25. 2 5
      tutorial/102_DrawMesh/CMakeLists.txt
  26. 2 5
      tutorial/103_Events/CMakeLists.txt
  27. 2 5
      tutorial/104_Colors/CMakeLists.txt
  28. 2 5
      tutorial/105_Overlays/CMakeLists.txt
  29. 2 5
      tutorial/106_ViewerMenu/CMakeLists.txt
  30. 2 5
      tutorial/201_Normals/CMakeLists.txt
  31. 2 5
      tutorial/202_GaussianCurvature/CMakeLists.txt
  32. 2 5
      tutorial/203_CurvatureDirections/CMakeLists.txt
  33. 2 5
      tutorial/204_Gradient/CMakeLists.txt
  34. 2 5
      tutorial/205_Laplacian/CMakeLists.txt
  35. 2 5
      tutorial/301_Slice/CMakeLists.txt
  36. 2 5
      tutorial/302_Sort/CMakeLists.txt
  37. 2 5
      tutorial/303_LaplaceEquation/CMakeLists.txt
  38. 2 5
      tutorial/304_LinearEqualityConstraints/CMakeLists.txt
  39. 2 5
      tutorial/305_QuadraticProgramming/CMakeLists.txt
  40. 2 5
      tutorial/306_EigenDecomposition/CMakeLists.txt
  41. 2 5
      tutorial/401_BiharmonicDeformation/CMakeLists.txt
  42. 2 5
      tutorial/402_PolyharmonicDeformation/CMakeLists.txt
  43. 4 7
      tutorial/403_BoundedBiharmonicWeights/CMakeLists.txt
  44. 7 10
      tutorial/403_BoundedBiharmonicWeights/main.cpp
  45. 2 5
      tutorial/404_DualQuaternionSkinning/CMakeLists.txt
  46. 2 5
      tutorial/405_AsRigidAsPossible/CMakeLists.txt
  47. 2 5
      tutorial/406_FastAutomaticSkinningTransformations/CMakeLists.txt
  48. 3 5
      tutorial/407_BiharmonicCoordinates/CMakeLists.txt
  49. 3 5
      tutorial/501_HarmonicParam/CMakeLists.txt
  50. 2 5
      tutorial/502_LSCMParam/CMakeLists.txt
  51. 2 5
      tutorial/503_ARAPParam/CMakeLists.txt
  52. 2 5
      tutorial/504_NRosyDesign/CMakeLists.txt
  53. 2 5
      tutorial/505_MIQ/CMakeLists.txt
  54. 2 5
      tutorial/506_FrameField/CMakeLists.txt
  55. 2 5
      tutorial/507_PolyVectorField/CMakeLists.txt
  56. 2 5
      tutorial/508_ConjugateField/CMakeLists.txt
  57. 2 5
      tutorial/509_Planarization/CMakeLists.txt
  58. 2 5
      tutorial/510_Integrable/CMakeLists.txt
  59. 2 5
      tutorial/511_PolyVectorFieldGeneral/CMakeLists.txt
  60. 2 5
      tutorial/601_Serialization/CMakeLists.txt
  61. 3 3
      tutorial/601_Serialization/main.cpp
  62. 2 5
      tutorial/602_Matlab/CMakeLists.txt
  63. 2 5
      tutorial/604_Triangle/CMakeLists.txt
  64. 1 3
      tutorial/605_Tetgen/CMakeLists.txt
  65. 2 5
      tutorial/606_AmbientOcclusion/CMakeLists.txt
  66. 2 5
      tutorial/607_ScreenCapture/CMakeLists.txt
  67. 2 5
      tutorial/608_LIM/CMakeLists.txt
  68. 2 5
      tutorial/609_Boolean/CMakeLists.txt
  69. 0 1
      tutorial/609_Boolean/main.cpp
  70. 2 5
      tutorial/610_CSGTree/CMakeLists.txt
  71. 2 5
      tutorial/701_Statistics/CMakeLists.txt
  72. 1 3
      tutorial/702_WindingNumber/CMakeLists.txt
  73. 2 5
      tutorial/703_Decimation/CMakeLists.txt
  74. 2 5
      tutorial/704_SignedDistance/CMakeLists.txt
  75. 2 5
      tutorial/705_MarchingCubes/CMakeLists.txt
  76. 1 3
      tutorial/706_FacetOrientation/CMakeLists.txt
  77. 2 5
      tutorial/707_SweptVolume/CMakeLists.txt
  78. 2 5
      tutorial/708_Picking/CMakeLists.txt
  79. 2 5
      tutorial/709_VectorFieldVisualizer/CMakeLists.txt
  80. 2 5
      tutorial/710_SLIM/CMakeLists.txt
  81. 2 5
      tutorial/711_Subdivision/CMakeLists.txt
  82. 2 5
      tutorial/712_DataSmoothing/CMakeLists.txt
  83. 20 54
      tutorial/CMakeLists.txt

+ 2 - 1
.appveyor.yml

@@ -6,6 +6,7 @@ branches:
   only:
     - master
     - alecjacobson
+    - cmake
 install:
   - git submodule update --init --recursive
   - cinstall: python
@@ -14,7 +15,7 @@ build_script:
   - cd c:\projects\libigl\tutorial
   - mkdir build
   - cd build
-  - cmake -D "LIBIGL_USE_STATIC_LIBRARY=ON" -G "Visual Studio 14 2015 Win64" ../
+  - cmake -D "LIBIGL_USE_STATIC_LIBRARY=ON" -D "LIBIGL_WITH_ANTTWEAKBAR=OFF" -G "Visual Studio 14 2015 Win64" ../
 #  - cmake -G "Visual Studio 14 2015 Win64" ../
   - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
 #  - set MSBuildOptions=/v:m /p:Configuration=Release /logger:%MSBuildLogger%

+ 4 - 4
.gitmodules

@@ -1,8 +1,8 @@
 [submodule "external/nanogui"]
 	path = external/nanogui
-url=https://github.com/libigl/nanogui.git
-        fetchRecursiveSubmodules = true
-        ignore = dirty
+	url=https://github.com/libigl/nanogui.git
+	fetchRecursiveSubmodules = true
+	ignore = dirty
 [submodule "external/embree"]
 	path = external/embree
 	url = https://github.com/embree/embree.git
@@ -20,7 +20,7 @@ url=https://github.com/libigl/nanogui.git
 	url = https://github.com/leethomason/tinyxml2.git
 [submodule "external/CoMISo"]
 	path = external/CoMISo
-	url = https://github.com/libigl/CoMISo.git
+	url = https://github.com/jdumas/CoMISo.git
 [submodule "external/cork"]
 	path = external/cork
 	url = https://github.com/libigl/cork.git

+ 3 - 2
.travis.yml

@@ -1,5 +1,6 @@
 language: cpp
 sudo: false
+dist: precise
 matrix:
   include:
     - os: linux
@@ -19,7 +20,7 @@ matrix:
         - cd tutorial
         - mkdir build
         - cd build
-        - cmake -DLIBIGL_USE_STATIC_LIBRARY=ON -DCMAKE_CXX_COMPILER=g++-4.8 -DCMAKE_C_COMPILER=gcc-4.8 ../
+        - cmake -DLIBIGL_USE_STATIC_LIBRARY=ON  -DCMAKE_CXX_COMPILER=g++-4.8 -DCMAKE_C_COMPILER=gcc-4.8 ../
         - make -j 2
       addons:
         apt:
@@ -62,5 +63,5 @@ matrix:
         - cd tutorial
         - mkdir build
         - cd build
-        - cmake -DLIBIGL_USE_STATIC_LIBRARY=ON ../
+        - cmake -DLIBIGL_USE_STATIC_LIBRARY=ON -DLIBIGL_WITH_NANOGUI=ON ../
         - make -j 2

+ 4 - 4
include/igl/copyleft/cgal/CGAL_includes.hpp

@@ -1,9 +1,9 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2014 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// 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/.
 #ifndef IGL_CGAL_INCLUDES_H
 #define IGL_CGAL_INCLUDES_H

+ 13 - 13
include/igl/copyleft/cgal/insert_into_cdt.cpp

@@ -1,9 +1,9 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2016 Alec Jacobson
-// 
-// 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 "insert_into_cdt.h"
 #include <CGAL/Point_3.h>
@@ -22,30 +22,30 @@ IGL_INLINE void igl::copyleft::cgal::insert_into_cdt(
         CGAL::Constrained_triangulation_face_base_2< Kernel>
       >,
       CGAL::Exact_intersections_tag
-    > 
-  > 
+    >
+  >
   & cdt)
 {
   typedef CGAL::Point_3<Kernel>    Point_3;
-  typedef CGAL::Segment_3<Kernel>  Segment_3; 
-  typedef CGAL::Triangle_3<Kernel> Triangle_3; 
+  typedef CGAL::Segment_3<Kernel>  Segment_3;
+  typedef CGAL::Triangle_3<Kernel> Triangle_3;
 
-  if(const Segment_3 *iseg = CGAL::object_cast<Segment_3 >(&obj)) 
+  if(const Segment_3 *iseg = CGAL::object_cast<Segment_3 >(&obj))
   {
     // Add segment constraint
     cdt.insert_constraint( P.to_2d(iseg->vertex(0)),P.to_2d(iseg->vertex(1)));
-  }else if(const Point_3 *ipoint = CGAL::object_cast<Point_3 >(&obj)) 
+  }else if(const Point_3 *ipoint = CGAL::object_cast<Point_3 >(&obj))
   {
     // Add point
     cdt.insert(P.to_2d(*ipoint));
-  } else if(const Triangle_3 *itri = CGAL::object_cast<Triangle_3 >(&obj)) 
+  } else if(const Triangle_3 *itri = CGAL::object_cast<Triangle_3 >(&obj))
   {
     // Add 3 segment constraints
     cdt.insert_constraint( P.to_2d(itri->vertex(0)),P.to_2d(itri->vertex(1)));
     cdt.insert_constraint( P.to_2d(itri->vertex(1)),P.to_2d(itri->vertex(2)));
     cdt.insert_constraint( P.to_2d(itri->vertex(2)),P.to_2d(itri->vertex(0)));
-  } else if(const std::vector<Point_3 > *polyp = 
-      CGAL::object_cast< std::vector<Point_3 > >(&obj)) 
+  } else if(const std::vector<Point_3 > *polyp =
+      CGAL::object_cast< std::vector<Point_3 > >(&obj))
   {
     const std::vector<Point_3 > & poly = *polyp;
     const size_t m = poly.size();

+ 8 - 7
include/igl/copyleft/cgal/insert_into_cdt.h

@@ -1,14 +1,15 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2016 Alec Jacobson
-// 
-// 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/.
 #ifndef IGL_COPYLEFT_CGAL_INSERT_INTO_CDT_H
 #define IGL_COPYLEFT_CGAL_INSERT_INTO_CDT_H
 #include "../../igl_inline.h"
 
+#include <CGAL/double.h> // Workaround https://github.com/CGAL/cgal/issues/2182 with CGAL 4.10-1
 #include <CGAL/Plane_3.h>
 #include <CGAL/Constrained_Delaunay_triangulation_2.h>
 #include <CGAL/Constrained_triangulation_plus_2.h>
@@ -33,7 +34,7 @@ namespace igl
       //   cdt  current CDT, see output
       // Outputs:
       //   cdt  CDT updated to contain constraints for the given object
-      // 
+      //
       template <typename Kernel>
       IGL_INLINE void insert_into_cdt(
         const CGAL::Object & obj,
@@ -46,8 +47,8 @@ namespace igl
               CGAL::Constrained_triangulation_face_base_2< Kernel>
             >,
             CGAL::Exact_intersections_tag
-          > 
-        > 
+          >
+        >
         & cdt);
     }
   }

+ 8 - 8
include/igl/copyleft/cgal/projected_cdt.cpp

@@ -1,9 +1,9 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2016 Alec Jacobson
-// 
-// 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 "projected_cdt.h"
 #include "insert_into_cdt.h"
@@ -29,8 +29,8 @@ IGL_INLINE void igl::copyleft::cgal::projected_cdt(
   size_t count=0;
   for (
     auto itr = cdt.finite_vertices_begin();
-    itr != cdt.finite_vertices_end(); 
-    itr++) 
+    itr != cdt.finite_vertices_end();
+    itr++)
   {
     vertices.push_back(P.to_3d(itr->point()));
     v2i[itr] = count;
@@ -39,10 +39,10 @@ IGL_INLINE void igl::copyleft::cgal::projected_cdt(
   // Read off faces and store index triples
   for (
     auto itr = cdt.finite_faces_begin();
-    itr != cdt.finite_faces_end(); 
+    itr != cdt.finite_faces_end();
     itr++)
   {
-    faces.push_back( 
+    faces.push_back(
       { v2i[itr->vertex(0)], v2i[itr->vertex(1)], v2i[itr->vertex(2)] });
   }
 }

+ 6 - 5
include/igl/copyleft/cgal/projected_cdt.h

@@ -1,9 +1,9 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2016 Alec Jacobson
-// 
-// 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/.
 #ifndef IGL_COPYLEFT_CGAL_PROJECTED_CDT_H
 #define IGL_COPYLEFT_CGAL_PROJECTED_CDT_H
@@ -11,6 +11,7 @@
 #include <Eigen/Core>
 #include <CGAL/Plane_3.h>
 #include <CGAL/Point_3.h>
+#include <CGAL/Object.h>
 #include <vector>
 namespace igl
 {
@@ -32,7 +33,7 @@ namespace igl
       // Outputs:
       //   vertices  list of vertices of the CDT mesh _back on the 3D plane_
       //   faces  list of list of triangle indices into vertices
-      //   
+      //
       template <typename Kernel, typename Index>
       IGL_INLINE void projected_cdt(
         const std::vector<CGAL::Object> & objects,

+ 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 <stb_image.h>
+#include <igl_stb_image.h>
 
 IGL_INLINE bool igl::png::readPNG(
   const std::string png_file,
@@ -36,7 +36,7 @@ IGL_INLINE bool igl::png::readPNG(
     }
   }
 
-  stbi_image_free(data);
+  igl::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 <stb_image_write.h>
+#include <igl_stb_image.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 = stbi_write_png(png_file.c_str(), width, height, 4, data, 4*width*sizeof(unsigned char));
+  bool ret = igl::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 <stb_image_write.h>
+#include <igl_stb_image.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 = stbi_write_png(png_file.c_str(), width, height, 4, img, width*sizeof(unsigned char));
+  bool ret = igl::stbi_write_png(png_file.c_str(), width, height, 4, img, width*sizeof(unsigned char));
   delete [] img;
   return ret;
 }

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

@@ -8,12 +8,12 @@
 #include "texture_from_png.h"
 
 #include "../opengl/report_gl_error.h"
-#include <stb_image.h>
+#include <igl_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 = stbi_load(png_file.c_str(), &width, &height, &n, 4);
+  unsigned char *data = igl::stbi_load(png_file.c_str(), &width, &height, &n, 4);
   if(data == NULL) {
     return false;
   }
@@ -23,7 +23,7 @@ IGL_INLINE bool igl::png::texture_from_png(const std::string png_file, const boo
   {
     yimg.flip();
   }*/
-  
+
   glGenTextures(1, &id);
   glBindTexture(GL_TEXTURE_2D, id);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@@ -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);
 
-  stbi_image_free(data);
+  igl::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 = stbi_load(png_file.c_str(), &width, &height, &n, 4);
+  unsigned char *data = igl::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(
     }
   }
 
-  stbi_image_free(data);
+  igl::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 <stb_image_write.h>
+#include <igl_stb_image.h>
 #include <vector>
 
 IGL_INLINE bool igl::png::writePNG(
@@ -35,7 +35,7 @@ IGL_INLINE bool igl::png::writePNG(
     }
   }
 
-  stbi_write_png(png_file.c_str(), R.rows(), R.cols(), comp, data.data(), stride_in_bytes);
+  igl::stbi_write_png(png_file.c_str(), R.rows(), R.cols(), comp, data.data(), stride_in_bytes);
 
   return true;
 }

+ 1 - 0
include/igl/sortrows.cpp

@@ -107,6 +107,7 @@ IGL_INLINE void igl::sortrows(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template instantiation
+template void igl::sortrows<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::DenseBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 // generated by autoexplicit.sh
 template void igl::sortrows<Eigen::Matrix<float, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::DenseBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 // generated by autoexplicit.sh

+ 1 - 0
include/igl/unique_rows.cpp

@@ -75,6 +75,7 @@ IGL_INLINE void igl::unique_rows(
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template instantiation
 // generated by autoexplicit.sh
+template void igl::unique_rows<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::DenseBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 template void igl::unique_rows<Eigen::Matrix<double,-1,-1,0,-1,-1>,Eigen::Matrix<double,-1,-1,0,-1,-1>,Eigen::Matrix<int,-1,-1,0,-1,-1>,Eigen::Matrix<int,-1,-1,0,-1,-1> >(Eigen::DenseBase<Eigen::Matrix<double,-1,-1,0,-1,-1> > const&,Eigen::PlainObjectBase<Eigen::Matrix<double,-1,-1,0,-1,-1> >&,Eigen::PlainObjectBase<Eigen::Matrix<int,-1,-1,0,-1,-1> >&,Eigen::PlainObjectBase<Eigen::Matrix<int,-1,-1,0,-1,-1> >&);
 template void igl::unique_rows<Eigen::Matrix<double,-1,-1,0,-1,-1>,Eigen::Matrix<double,-1,-1,0,-1,-1>,Eigen::Matrix<int,-1,1,0,-1,1>,Eigen::Matrix<int,-1,1,0,-1,1> >(Eigen::DenseBase<Eigen::Matrix<double,-1,-1,0,-1,-1> > const&,Eigen::PlainObjectBase<Eigen::Matrix<double,-1,-1,0,-1,-1> >&,Eigen::PlainObjectBase<Eigen::Matrix<int,-1,1,0,-1,1> >&,Eigen::PlainObjectBase<Eigen::Matrix<int,-1,1,0,-1,1> >&);
 template void igl::unique_rows<Eigen::Matrix<double,-1,-1,0,-1,-1>,Eigen::Matrix<double,-1,-1,0,-1,-1>,Eigen::Matrix<long,-1,1,0,-1,1>,Eigen::Matrix<long,-1,1,0,-1,1> >(Eigen::DenseBase<Eigen::Matrix<double,-1,-1,0,-1,-1> > const&,Eigen::PlainObjectBase<Eigen::Matrix<double,-1,-1,0,-1,-1> >&,Eigen::PlainObjectBase<Eigen::Matrix<long,-1,1,0,-1,1> >&,Eigen::PlainObjectBase<Eigen::Matrix<long,-1,1,0,-1,1> >&);

+ 40 - 40
include/igl/xml/XMLSerializable.h

@@ -11,7 +11,7 @@
 // Interface for xml-serializable class see serialize_xml.h
 
 // Pretty sure all of these IGL_INLINE should be inline
- 
+
 namespace igl
 {
   namespace xml
@@ -29,83 +29,83 @@ namespace igl
     class XMLSerializable: public XMLSerializableBase
     {
     private:
-  
+
       template <typename T>
       struct XMLSerializationObject: public XMLSerializableBase
       {
         bool Binary;
         std::string Name;
         T* Object;
-  
+
         void Serialize(std::vector<char>& buffer) const {
           serialize(*Object,Name,buffer);
         }
-  
+
         void Deserialize(const std::vector<char>& buffer) {
           deserialize(*Object,Name,buffer);
         }
-  
+
         void Serialize(tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element) const {
           serialize_xml(*Object,Name,doc,element,Binary);
         }
-  
+
         void Deserialize(const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element) {
           deserialize_xml(*Object,Name,doc,element);
         }
       };
-  
+
       mutable bool initialized;
       mutable std::vector<XMLSerializableBase*> objects;
-  
+
     public:
-  
+
       // Override this function to add your member variables which should be serialized
       IGL_INLINE virtual void InitSerialization() = 0;
-  
+
       // Following functions can be overridden to handle the specific events.
       // Return false to prevent the de-/serialization of an object.
       IGL_INLINE virtual bool PreSerialization() const;
       IGL_INLINE virtual void PostSerialization() const;
       IGL_INLINE virtual bool PreDeserialization();
       IGL_INLINE virtual void PostDeserialization();
-  
+
       // Default implementation of XMLSerializableBase interface
       IGL_INLINE void Serialize(std::vector<char>& buffer) const;
       IGL_INLINE void Deserialize(const std::vector<char>& buffer);
       IGL_INLINE void Serialize(tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element) const;
       IGL_INLINE void Deserialize(const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element);
-  
+
       // Default constructor, destructor, assignment and copy constructor
       IGL_INLINE XMLSerializable();
       IGL_INLINE XMLSerializable(const XMLSerializable& obj);
       IGL_INLINE ~XMLSerializable();
       IGL_INLINE XMLSerializable& operator=(const XMLSerializable& obj);
-  
+
       // Use this function to add your variables which should be serialized
       template <typename T>
       IGL_INLINE void Add(T& obj,std::string name,bool binary = false);
     };
- 
+
     // IMPLEMENTATION
 
     IGL_INLINE bool XMLSerializable::PreSerialization() const
-    { 
+    {
       return true;
     }
-    
+
     IGL_INLINE void XMLSerializable::PostSerialization() const
     {
     }
-    
+
     IGL_INLINE bool XMLSerializable::PreDeserialization()
-    { 
+    {
       return true;
     }
-  
-    IGL_INLINE void XMLSerializable::PostDeserialization() 
+
+    IGL_INLINE void XMLSerializable::PostDeserialization()
     {
     }
-  
+
     IGL_INLINE void XMLSerializable::Serialize(std::vector<char>& buffer) const
     {
       if(this->PreSerialization())
@@ -116,14 +116,14 @@ namespace igl
           (const_cast<XMLSerializable*>(this))->InitSerialization();
           initialized = true;
         }
-  
+
         for(unsigned int i=0;i<objects.size();i++)
           objects[i]->Serialize(buffer);
-  
+
         this->PostSerialization();
       }
     }
-  
+
     IGL_INLINE void XMLSerializable::Deserialize(const std::vector<char>& buffer)
     {
       if(this->PreDeserialization())
@@ -134,14 +134,14 @@ namespace igl
           (const_cast<XMLSerializable*>(this))->InitSerialization();
           initialized = true;
         }
-  
+
         for(unsigned int i=0;i<objects.size();i++)
           objects[i]->Deserialize(buffer);
-  
+
         this->PostDeserialization();
       }
     }
-  
+
     IGL_INLINE void XMLSerializable::Serialize(tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element) const
     {
       if(this->PreSerialization())
@@ -152,14 +152,14 @@ namespace igl
           (const_cast<XMLSerializable*>(this))->InitSerialization();
           initialized = true;
         }
-  
+
         for(unsigned int i=0;i<objects.size();i++)
           objects[i]->Serialize(doc,element);
-  
+
         this->PostSerialization();
       }
     }
-  
+
     IGL_INLINE void XMLSerializable::Deserialize(const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element)
     {
       if(this->PreDeserialization())
@@ -170,32 +170,32 @@ namespace igl
           (const_cast<XMLSerializable*>(this))->InitSerialization();
           initialized = true;
         }
-  
+
         for(unsigned int i=0;i<objects.size();i++)
           objects[i]->Deserialize(doc,element);
-  
+
         this->PostDeserialization();
       }
     }
-  
+
     IGL_INLINE XMLSerializable::XMLSerializable()
     {
       initialized = false;
     }
-  
+
     IGL_INLINE XMLSerializable::XMLSerializable(const XMLSerializable& obj)
     {
       initialized = false;
       objects.clear();
     }
-  
+
     IGL_INLINE XMLSerializable::~XMLSerializable()
     {
       initialized = false;
       objects.clear();
     }
-  
-  
+
+
     IGL_INLINE XMLSerializable& XMLSerializable::operator=(const XMLSerializable& obj)
     {
       if(this != &obj)
@@ -208,7 +208,7 @@ namespace igl
       }
       return *this;
     }
-  
+
     template <typename T>
     IGL_INLINE void XMLSerializable::Add(T& obj,std::string name,bool binary)
     {
@@ -216,10 +216,10 @@ namespace igl
       object->Binary = binary;
       object->Name = name;
       object->Object = &obj;
-  
+
       objects.push_back(object);
     }
-    
+
   }
 }
 #endif

+ 18 - 18
include/igl/xml/serialize_xml.h

@@ -58,7 +58,7 @@ namespace igl
     IGL_INLINE void serialize_xml(
       const T& obj,
       const std::string& objectName,
-      const std::string& filename, 
+      const std::string& filename,
       bool binary = false,
       bool overwrite = false);
     template <typename T>
@@ -68,7 +68,7 @@ namespace igl
       tinyxml2::XMLDocument* doc,
       tinyxml2::XMLElement* element,
       bool binary = false);
-  
+
     // deserializes the given data from a xml file or doc data back to the provided object
     //
     // Templates:
@@ -90,7 +90,7 @@ namespace igl
     IGL_INLINE void deserialize_xml(T& obj,const std::string& objectName,const std::string& filename);
     template <typename T>
     IGL_INLINE void deserialize_xml(T& obj,const std::string& objectName,const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element);
-  
+
     // internal functions
     namespace serialization_xml
     {
@@ -99,38 +99,38 @@ namespace igl
       IGL_INLINE typename std::enable_if<std::is_fundamental<T>::value>::type serialize(const T& obj,tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element,const std::string& name);
       template <typename T>
       IGL_INLINE typename std::enable_if<std::is_fundamental<T>::value>::type deserialize(T& obj,const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element,const std::string& name);
-  
+
       // std::string
       IGL_INLINE void serialize(const std::string& obj,tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element,const std::string& name);
       IGL_INLINE void deserialize(std::string& obj,const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element,const std::string& name);
-  
+
       // XMLSerializableBase
       template <typename T>
       IGL_INLINE typename std::enable_if<std::is_base_of<XMLSerializableBase,T>::value>::type serialize(const T& obj,tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element,const std::string& name);
       template <typename T>
       IGL_INLINE typename std::enable_if<std::is_base_of<XMLSerializableBase,T>::value>::type deserialize(T& obj,const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element,const std::string& name);
-  
+
       // STL containers
       template <typename T1, typename T2>
       IGL_INLINE void serialize(const std::pair<T1,T2>& obj,tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element,const std::string& name);
       template <typename T1,typename T2>
       IGL_INLINE void deserialize(std::pair<T1,T2>& obj,const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element,const std::string& name);
-  
+
       template <typename T1,typename T2>
       IGL_INLINE void serialize(const std::vector<T1,T2>& obj,tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element,const std::string& name);
       template <typename T1,typename T2>
       IGL_INLINE void deserialize(std::vector<T1,T2>& obj,const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element,const std::string& name);
-  
+
       template <typename T>
       IGL_INLINE void serialize(const std::set<T>& obj,tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element,const std::string& name);
       template <typename T>
       IGL_INLINE void deserialize(std::set<T>& obj,const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element,const std::string& name);
-  
+
       template <typename T1,typename T2>
       IGL_INLINE void serialize(const std::map<T1,T2>& obj,tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element,const std::string& name);
       template <typename T1,typename T2>
       IGL_INLINE void deserialize(std::map<T1,T2>& obj,const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element,const std::string& name);
-  
+
       // Eigen types
 
       // Serialize a Dense Eigen Matrix to xml (in the matrix= attribute,
@@ -143,7 +143,7 @@ namespace igl
       // Outputs:
       //   doc  pointer to xml document
       //   element  pointer to xml element
-      //   
+      //
       template<typename T,int R,int C,int P,int MR,int MC>
       IGL_INLINE void serialize(
         const Eigen::Matrix<T,R,C,P,MR,MC>& obj,
@@ -168,7 +168,7 @@ namespace igl
         const std::string& name,
         const std::function<void(const std::string &,T &)> & from_string,
         Eigen::Matrix<T,R,C,P,MR,MC>& obj);
-  
+
       // Legacy APIs
       template<typename T,int R,int C,int P,int MR,int MC>
       IGL_INLINE void serialize(
@@ -182,18 +182,18 @@ namespace igl
         const tinyxml2::XMLDocument* doc,
         const tinyxml2::XMLElement* element,
         const std::string& name);
-  
+
       template<typename T,int P,typename I>
       IGL_INLINE void serialize(const Eigen::SparseMatrix<T,P,I>& obj,tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element,const std::string& name);
       template<typename T,int P,typename I>
       IGL_INLINE void deserialize(Eigen::SparseMatrix<T,P,I>& obj,const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element,const std::string& name);
-  
+
       // raw pointers
       template <typename T>
       IGL_INLINE typename std::enable_if<std::is_pointer<T>::value>::type serialize(const T& obj,tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element,const std::string& name);
       template <typename T>
       IGL_INLINE typename std::enable_if<std::is_pointer<T>::value>::type deserialize(T& obj,const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element,const std::string& name);
-  
+
       // helper functions
       tinyxml2::XMLElement* getElement(tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element,const std::string& name);
       IGL_INLINE void getAttribute(const char* src,bool& dest);
@@ -210,7 +210,7 @@ namespace igl
       IGL_INLINE void decodeXMLElementName(std::string& name);
       IGL_INLINE std::string base64_encode(unsigned char const* bytes_to_encode,unsigned int in_len);
       IGL_INLINE std::string base64_decode(std::string const& encoded_string);
-  
+
       // compile time type serializable check
       template <typename T>
       struct is_stl_container { static const bool value = false; };
@@ -222,14 +222,14 @@ namespace igl
       struct is_stl_container<std::set<T> > { static const bool value = true; };
       template <typename T1,typename T2>
       struct is_stl_container<std::map<T1,T2> > { static const bool value = true; };
-  
+
       template <typename T>
       struct is_eigen_type { static const bool value = false; };
       template <typename T,int R,int C,int P,int MR,int MC>
       struct is_eigen_type<Eigen::Matrix<T,R,C,P,MR,MC> > { static const bool value = true; };
       template <typename T,int P,typename I>
       struct is_eigen_type<Eigen::SparseMatrix<T,P,I> > { static const bool value = true; };
-  
+
       template <typename T>
       struct is_serializable {
         using T0 = typename  std::remove_pointer<T>::type;

+ 3 - 3
include/igl/xml/writeDAE.cpp

@@ -25,12 +25,12 @@ IGL_INLINE bool igl::xml::writeDAE(
 
   const auto & ele = [&doc](
     const std::string tag,
-    // Can't just use `{}` as the default arguement because of a clang-bug 
+    // Can't just use `{}` as the default arguement because of a clang-bug
     // http://stackoverflow.com/questions/17264067/
-    const std::map<std::string,std::string> attribs = 
+    const std::map<std::string,std::string> attribs =
       std::map<std::string,std::string>(),
     const std::string text="",
-    const std::list<XMLElement *> children = 
+    const std::list<XMLElement *> children =
        std::list<XMLElement *>()
     )->XMLElement *
   {

+ 72 - 101
python/CMakeLists.txt

@@ -1,55 +1,29 @@
 cmake_minimum_required(VERSION 2.8.12)
-project(pybind)
-
-### Compilation flags: adapt to your needs ###
-if(MSVC)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /bigobj /w") ### Enable parallel compilation
-  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR} )
-  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR} )
-else()
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") #### Libigl requires a modern C++ compiler that supports c++11
-  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../" )
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-unused-parameter -Wno-deprecated-register -Wno-return-type-c-linkage")
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations -Wno-unused-parameter -Wno-deprecated-register -Wno-return-type-c-linkage")
-endif()
+project(pyigl)
 
 # Force a specific python version
-# SET(PYTHON_LIBRARIES "D:/Python34/libs/python34.lib")
-# SET(PYTHON_INCLUDE_DIR "D:/Python34/include")
+# set(PYTHON_LIBRARIES "D:/Python34/libs/python34.lib")
+# set(PYTHON_INCLUDE_DIR "D:/Python34/include")
 
 # Force a specific python version
-# SET(PYTHON_LIBRARIES "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5m.dylib")
-# SET(PYTHON_INCLUDE_DIR "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/include/python3.5m")
+# set(PYTHON_LIBRARIES "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5m.dylib")
+# set(PYTHON_INCLUDE_DIR "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/include/python3.5m")
 
 set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6)
 find_package(PythonLibs REQUIRED)
 find_package(PythonInterp REQUIRED)
 
 string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE)
-if (UNIX)
+if(UNIX)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
-  if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
+  if(NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -flto")
   endif()
 endif()
 
-# Compile with compiler warnings turned on
-# if(MSVC)
-#   if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
-#     string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
-#   else()
-#     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
-#   endif()
-# else()
-#   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
-# endif()
-
-include_directories(${PYTHON_INCLUDE_DIR} include)
-
 ## include pybind
-set(PYBIND11_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/../external/nanogui/ext/pybind11/include CACHE PATH "Path to pybind11/include")
-include_directories(${PYBIND11_INCLUDE_DIR})
+add_subdirectory(${PROJECT_SOURCE_DIR}/../external/nanogui/ext/pybind11 pybind11)
 
 ## include libigl
 option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" OFF)
@@ -71,83 +45,80 @@ option(LIBIGL_WITH_XML              "Use XML"            ON)
 option(LIBIGL_WITH_PYTHON           "Use Python"         ON)
 option(LIBIGL_WITH_COPYLEFT         "Use Copyleft"       ON)
 
-
-if(LIBIGL_WITH_CGAL) # Do not remove or move this block, cgal strange build system fails without it
-  find_package(CGAL REQUIRED)
-  set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE CACHE BOOL "CGAL's CMAKE Setup is super annoying ")
-  include(${CGAL_USE_FILE})
+## libigl
+if(NOT TARGET igl::core)
+  list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../shared/cmake")
+  include(libigl)
 endif()
 
-add_subdirectory("${PROJECT_SOURCE_DIR}/../shared/cmake" "libigl")
-
-
-### Prepare the build environment
-
-include_directories(${LIBIGL_INCLUDE_DIRS})
-add_definitions(${LIBIGL_DEFINITIONS})
-
-## Optional modules
-if (LIBIGL_WITH_VIEWER)
-  add_definitions(-DPY_VIEWER)
-  list(APPEND SHARED_SOURCES "modules/py_igl_viewer.cpp")
-endif ()
-
-if (LIBIGL_WITH_COMISO)
-  add_definitions(-DPY_COMISO)
-  list(APPEND SHARED_SOURCES "modules/copyleft/py_igl_comiso.cpp")
-endif ()
-
-if (LIBIGL_WITH_TETGEN)
-  add_definitions(-DPY_TETGEN)
-  list(APPEND SHARED_SOURCES "modules/copyleft/py_igl_tetgen.cpp")
-endif ()
-
-if (LIBIGL_WITH_EMBREE)
-  add_definitions(-DPY_EMBREE)
-  list(APPEND SHARED_SOURCES "modules/py_igl_embree.cpp")
-endif ()
-
-if (LIBIGL_WITH_TRIANGLE)
-  add_definitions(-DPY_TRIANGLE)
-  list(APPEND SHARED_SOURCES "modules/py_igl_triangle.cpp")
-endif ()
-
-if (LIBIGL_WITH_CGAL)
-  add_definitions(-DPY_CGAL)
-  list(APPEND SHARED_SOURCES "modules/copyleft/py_igl_cgal.cpp")
-endif ()
-
-if (LIBIGL_WITH_COPYLEFT)
-  add_definitions(-DPY_COPYLEFT)
-  list(APPEND SHARED_SOURCES "modules/copyleft/py_igl_copyleft.cpp")
-endif ()
-
-if (LIBIGL_WITH_PNG)
-  add_definitions(-DPY_PNG)
-  list(APPEND SHARED_SOURCES "modules/py_igl_png.cpp")
-endif ()
-
-#----
 ## Prepare the python library
-add_library(pyigl SHARED
+pybind11_add_module(pyigl
   python_shared.cpp
   modules/py_vector.cpp
   py_igl.cpp
   py_doc.cpp
-  ${SHARED_SOURCES}
 )
 
+## Add dependencies
+target_include_directories(pyigl PUBLIC igl::core)
+
+## Optional modules
+if(LIBIGL_WITH_VIEWER)
+  target_sources(pyigl PRIVATE "modules/py_igl_viewer.cpp")
+  target_compile_definitions(pyigl PUBLIC -DPY_VIEWER)
+  target_link_libraries(pyigl PUBLIC igl::viewer)
+endif()
+
+if(LIBIGL_WITH_COMISO)
+  target_sources(pyigl PRIVATE "modules/copyleft/py_igl_comiso.cpp")
+  target_compile_definitions(pyigl PUBLIC -DPY_COMISO)
+  target_link_libraries(pyigl PUBLIC igl::comiso)
+endif()
+
+if(LIBIGL_WITH_TETGEN)
+  target_sources(pyigl PRIVATE "modules/copyleft/py_igl_tetgen.cpp")
+  target_compile_definitions(pyigl PUBLIC -DPY_TETGEN)
+  target_link_libraries(pyigl PUBLIC igl::tetgen)
+endif()
+
+if(LIBIGL_WITH_EMBREE)
+  target_sources(pyigl PRIVATE "modules/py_igl_embree.cpp")
+  target_compile_definitions(pyigl PUBLIC -DPY_EMBREE)
+  target_link_libraries(pyigl PUBLIC igl::embree)
+endif()
+
+if(LIBIGL_WITH_TRIANGLE)
+  target_sources(pyigl PRIVATE "modules/py_igl_triangle.cpp")
+  target_compile_definitions(pyigl PUBLIC -DPY_TRIANGLE)
+  target_link_libraries(pyigl PUBLIC igl::triangle)
+endif()
+
+if(LIBIGL_WITH_CGAL)
+  target_sources(pyigl PRIVATE "modules/copyleft/py_igl_cgal.cpp")
+  target_compile_definitions(pyigl PUBLIC -DPY_CGAL)
+  target_link_libraries(pyigl PUBLIC igl::cgal)
+endif()
+
+if(LIBIGL_WITH_COPYLEFT)
+  target_sources(pyigl PRIVATE "modules/copyleft/py_igl_copyleft.cpp")
+  target_compile_definitions(pyigl PUBLIC -DPY_COPYLEFT)
+endif()
+
+if(LIBIGL_WITH_PNG)
+  target_sources(pyigl PRIVATE "modules/py_igl_png.cpp")
+  target_compile_definitions(pyigl PUBLIC -DPY_PNG)
+  target_link_libraries(pyigl PUBLIC igl::png)
+endif()
+
 set_target_properties(pyigl PROPERTIES PREFIX "")
 set_target_properties(pyigl PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR})
 
-target_link_libraries(pyigl ${LIBIGL_LIBRARIES} ${LIBIGL_EXTRA_LIBRARIES})
-
 # Copy the nanogui bindings
 #get_target_property(NANOGUI_LIB nanogui_python LOCATION)
 #file(COPY ${NANOGUI_LIB} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/../)
 
-if (WIN32)
-  if (MSVC)
+if(WIN32)
+  if(MSVC)
     # Enforce size-based optimization and link time code generation on MSVC (~30% smaller binaries in experiments)
     set_target_properties(pyigl PROPERTIES COMPILE_FLAGS "/Os /GL")
     set_target_properties(pyigl PROPERTIES LINK_FLAGS "/LTCG")
@@ -161,7 +132,7 @@ if (WIN32)
   # target_link_libraries(igl ${PYTHON_LIBRARY})
   target_link_libraries(pyigl ${PYTHON_LIBRARIES})
 
-elseif (UNIX)
+elseif(UNIX)
   # It's quite common to have multiple copies of the same Python version
   # installed on one's system. E.g.: one copy from the OS and another copy
   # that's statically linked into an application like Blender or Maya.
@@ -184,27 +155,27 @@ elseif (UNIX)
   if(APPLE)
     set_target_properties(pyigl PROPERTIES MACOSX_RPATH ".")
 
-    if (NOT CHECK_UNDEFINED)
+    if(NOT CHECK_UNDEFINED)
       set_target_properties(pyigl PROPERTIES LINK_FLAGS "-undefined dynamic_lookup -dead_strip")
     endif()
 
-    if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
+    if(NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
       add_custom_command(TARGET pyigl POST_BUILD COMMAND strip -u -r ${PROJECT_SOURCE_DIR}/pyigl.so)
     endif()
   else()
 
-    if (CHECK_UNDEFINED)
+    if(CHECK_UNDEFINED)
       target_link_libraries(pyigl ${PYTHON_LIBRARIES})
       set_target_properties(pyigl PROPERTIES LINK_FLAGS "-Wl,--no-undefined")
     endif()
 
-    if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
+    if(NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
       add_custom_command(TARGET pyigl POST_BUILD COMMAND strip ${PROJECT_SOURCE_DIR}/pyigl.so)
     endif()
   endif()
 endif()
 
-if (LIBIGL_WITH_PYTHON AND LIBIGL_WITH_NANOGUI)
+if(LIBIGL_WITH_PYTHON AND LIBIGL_WITH_NANOGUI)
   # Copy the nanogui python lib after compilation
   get_target_property(NANOGUI_LIB nanogui-python LOCATION)
   add_custom_target(copy ALL)

+ 2 - 1
shared/cmake/CMakeLists.txt

@@ -427,10 +427,11 @@ if(LIBIGL_WITH_PNG)
   set(STB_IMAGE_DIR "${LIBIGL_EXTERNAL}/stb_image")
   add_subdirectory("${STB_IMAGE_DIR}" "stb_image")
   list(APPEND LIBIGL_INCLUDE_DIRS ${STB_IMAGE_DIR})
-  list(APPEND LIBIGL_PNG_EXTRA_LIBRARIES "stb_image")
+  list(APPEND LIBIGL_PNG_EXTRA_LIBRARIES "igl_stb_image")
   list(APPEND LIBIGL_EXTRA_LIBRARIES ${LIBIGL_PNG_EXTRA_LIBRARIES})
   if(LIBIGL_USE_STATIC_LIBRARY)
     CompileIGL_Module("png" "")
+    target_link_libraries(igl_png PRIVATE igl_stb_image)
     target_include_directories(igl_png PRIVATE ${STB_IMAGE_DIR})
     if(NOT APPLE)
       target_include_directories(igl_png PRIVATE "${NANOGUI_DIR}/ext/glew/include")

+ 85 - 0
shared/cmake/CXXFeatures.cmake

@@ -0,0 +1,85 @@
+################################################################################
+
+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 intialization, 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.

+ 27 - 18
shared/cmake/FindMOSEK.cmake

@@ -7,26 +7,35 @@
 # MOSEK_LIBRARIES       - Link these to use MOSEK
 #
 
-FIND_PATH(MOSEK_INCLUDE_DIR mosek.h
-  PATHS 
-  /usr/local/mosek/7/tools/platform/osx64x86/h/
-  /usr/local/mosek/8/tools/platform/osx64x86/h/
-    )
+# Hardcoded search paths
+set(SEARCH_PATHS
+  /usr/local/mosek/7/tools/platform/osx64x86/
+  /usr/local/mosek/8/tools/platform/osx64x86/
+  /opt/mosek/7/tools/platform/linux64x86/
+)
 
-SET(SEARCH_PATHS "${MOSEK_INCLUDE_DIR}" "${MOSEK_INCLUDE_DIR}/../bin" "${MOSEK_INCLUDE_DIR}/lib")
+find_path(MOSEK_INCLUDE_DIR mosek.h
+  PATHS ${SEARCH_PATHS}
+  PATH_SUFFIXES h
+)
 
 set(MOSEK_LIBRARIES)
-FIND_LIBRARY(MOSEK_LIBRARIES  NAMES mosek64 PATHS ${SEARCH_PATHS} NO_DEFAULT_PATH DPATH_SUFFIXES a lib dylib)
+find_library(MOSEK_LIBRARIES NAMES mosek64
+  HINT
+    "${MOSEK_INCLUDE_DIR}"
+    "${MOSEK_INCLUDE_DIR}/../bin"
+    "${MOSEK_INCLUDE_DIR}/lib"
+  PATHS
+    ${SEARCH_PATHS}
+  NO_DEFAULT_PATH
+  PATH_SUFFIXES a bin lib dylib)
 
-if(MOSEK_LIBRARIES AND MOSEK_INCLUDE_DIR)
-message(STATUS "Found mosek: ${MOSEK_LIBRARIES}")
-set(MOSEK_FOUND TRUE)
-endif(MOSEK_LIBRARIES AND MOSEK_INCLUDE_DIR)
+# Check that Mosek was successfully found
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+  MOSEK DEFAULT_MSG MOSEK_LIBRARIES MOSEK_INCLUDE_DIR
+)
+set(MOSEK_INCLUDE_DIRS ${MOSEK_INCLUDE_DIR})
 
-IF (MOSEK_FOUND)
-   message(STATUS "Found MOSEK: ${MOSEK_INCLUDE_DIR}")
-   SET(MOSEK_INCLUDE_DIRS ${MOSEK_INCLUDE_DIR} )
-ELSE (MOSEK_FOUND)
-    #add_definitions(-DIGL_NO_MOSEK)
-    #message(WARNING "could NOT find MOSEK")
-ENDIF (MOSEK_FOUND)
+# Hide variables from CMake-Gui options
+mark_as_advanced(MOSEK_LIBRARIES MOSEK_INCLUDE_DIRS MOSEK_INCLUDE_DIR)

+ 362 - 0
shared/cmake/libigl.cmake

@@ -0,0 +1,362 @@
+cmake_minimum_required(VERSION 3.1)
+
+### Available options ###
+option(LIBIGL_USE_STATIC_LIBRARY    "Use libigl as static library" OFF)
+option(LIBIGL_WITH_ANTTWEAKBAR      "Use AntTweakBar"    OFF)
+option(LIBIGL_WITH_CGAL             "Use CGAL"           ON)
+option(LIBIGL_WITH_COMISO           "Use CoMiso"         ON)
+option(LIBIGL_WITH_CORK             "Use Cork"           OFF)
+option(LIBIGL_WITH_EMBREE           "Use Embree"         OFF)
+option(LIBIGL_WITH_LIM              "Use LIM"            ON)
+option(LIBIGL_WITH_MATLAB           "Use Matlab"         ON)
+option(LIBIGL_WITH_MOSEK            "Use MOSEK"          ON)
+option(LIBIGL_WITH_NANOGUI          "Use Nanogui menu"   OFF)
+option(LIBIGL_WITH_OPENGL           "Use OpenGL"         ON)
+option(LIBIGL_WITH_OPENGL_GLFW      "Use GLFW"           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_VIEWER           "Use OpenGL viewer"  ON)
+option(LIBIGL_WITH_XML              "Use XML"            ON)
+option(LIBIGL_WITH_PYTHON           "Use Python"         OFF)
+
+if(LIBIGL_WITH_VIEWER AND (NOT LIBIGL_WITH_OPENGL_GLFW OR NOT LIBIGL_WITH_OPENGL) )
+  message(FATAL_ERROR "LIBIGL_WITH_VIEWER=ON requires LIBIGL_WITH_OPENGL_GLFW=ON and LIBIGL_WITH_OPENGL=ON")
+endif()
+
+################################################################################
+
+### Configuration
+set(LIBIGL_ROOT "${CMAKE_CURRENT_LIST_DIR}/../..")
+set(LIBIGL_SOURCE_DIR "${LIBIGL_ROOT}/include")
+set(LIBIGL_EXTERNAL "${LIBIGL_ROOT}/external")
+
+### Multiple dependencies are buried in Nanogui
+set(NANOGUI_DIR "${LIBIGL_EXTERNAL}/nanogui")
+
+# 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()
+
+################################################################################
+### IGL Common
+################################################################################
+
+add_library(igl_common INTERFACE)
+target_include_directories(igl_common SYSTEM INTERFACE ${LIBIGL_SOURCE_DIR})
+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 /MP /bigobj)
+endif()
+
+if(BUILD_SHARED_LIBS)
+  # Generate position independent code
+  set_target_properties(igl_common PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE ON)
+endif()
+
+# Eigen
+if(TARGET Eigen3::Eigen)
+  # If an imported target already exists, use it
+  target_link_libraries(igl_common INTERFACE Eigen3::Eigen)
+else()
+  target_include_directories(igl_common SYSTEM INTERFACE ${NANOGUI_DIR}/ext/eigen)
+endif()
+
+################################################################################
+
+function(compile_igl_module module_dir prefix)
+  string(REPLACE "/" "_" module_name "${module_dir}")
+  if(LIBIGL_USE_STATIC_LIBRARY)
+    file(GLOB SOURCES_IGL_${module_name}
+      "${LIBIGL_SOURCE_DIR}/igl/${prefix}/${module_dir}/*.cpp")
+    add_library(igl_${module_name} STATIC ${SOURCES_IGL_${module_name}} ${ARGN})
+    if(MSVC)
+      target_compile_options(igl_${module_name} PRIVATE /w) # disable all warnings (not ideal but...)
+    else()
+      #target_compile_options(igl_${module_name} PRIVATE -w) # disable all warnings (not ideal but...)
+    endif()
+  else()
+    add_library(igl_${module_name} INTERFACE)
+  endif()
+  
+  target_link_libraries(igl_${module_name} ${IGL_SCOPE} igl_common)
+  if(NOT module_name STREQUAL "core")
+	  target_link_libraries(igl_${module_name} ${IGL_SCOPE} igl_core)
+  endif()
+
+  # Alias target because it looks nicer
+  message(STATUS "Creating target: igl::${module_name}")
+  add_library(igl::${module_name} ALIAS igl_${module_name})
+endfunction()
+
+################################################################################
+### IGL Core
+################################################################################
+
+if(LIBIGL_USE_STATIC_LIBRARY)
+  file(GLOB SOURCES_IGL
+    "${LIBIGL_SOURCE_DIR}/igl/*.cpp"
+    "${LIBIGL_SOURCE_DIR}/igl/copyleft/*.cpp")
+endif()
+compile_igl_module("core" "" ${SOURCES_IGL})
+
+################################################################################
+## Compile the AntTweakBar part ###
+if(LIBIGL_WITH_ANTTWEAKBAR)
+  set(ANTTWEAKBAR_DIR "${LIBIGL_EXTERNAL}/AntTweakBar")
+  if(NOT TARGET AntTweakBar)
+    add_subdirectory("${ANTTWEAKBAR_DIR}" AntTweakBar)
+  endif()
+  compile_igl_module("anttweakbar" "")
+  target_link_libraries(igl_anttweakbar ${IGL_SCOPE} AntTweakBar)
+endif()
+
+################################################################################
+### Compile the cgal parts ###
+if(LIBIGL_WITH_CGAL)
+  # CGAL Core is needed for
+  # `Exact_predicates_exact_constructions_kernel_with_sqrt`
+  find_package(CGAL COMPONENTS Core)
+  if(CGAL_FOUND)
+    compile_igl_module("cgal" "copyleft/")
+    find_package(Boost 1.48 REQUIRED thread system)
+    target_link_libraries(igl_cgal ${IGL_SCOPE} CGAL::CGAL CGAL::CGAL_Core ${Boost_LIBRARIES})
+  else()
+    set(LIBIGL_WITH_CGAL OFF CACHE BOOL "" FORCE)
+  endif()
+endif()
+
+################################################################################
+# Compile CoMISo
+# NOTE: this cmakefile works only with the
+# comiso available here: https://github.com/libigl/CoMISo
+if(LIBIGL_WITH_COMISO)
+  compile_igl_module("comiso" "copyleft/")
+  if(NOT TARGET CoMISo)
+    add_subdirectory("${LIBIGL_EXTERNAL}/CoMISo" CoMISo)
+  endif()
+  target_link_libraries(igl_comiso ${IGL_SCOPE} CoMISo)
+endif()
+
+################################################################################
+### Compile the cork parts ###
+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
+    add_subdirectory("${CORK_DIR}" "lib-cork")
+  endif()
+  compile_igl_module("cork" "copyleft/")
+  target_include_directories(igl_cork ${IGL_SCOPE} cork)
+  target_include_directories(igl_cork ${IGL_SCOPE} "${CORK_DIR}/src")
+endif()
+
+################################################################################
+### Compile the embree part ###
+if(LIBIGL_WITH_EMBREE)
+  set(EMBREE_DIR "${LIBIGL_EXTERNAL}/embree")
+
+  set(EMBREE_ISPC_SUPPORT OFF CACHE BOOL " " FORCE)
+  set(EMBREE_TASKING_SYSTEM "INTERNAL" CACHE BOOL " " FORCE)
+  set(EMBREE_TUTORIALS OFF CACHE BOOL " " FORCE)
+  set(EMBREE_MAX_ISA NONE CACHE STRINGS " " FORCE)
+
+  # set(ENABLE_INSTALLER OFF CACHE BOOL " " FORCE)
+  if(MSVC)
+    # set(EMBREE_STATIC_RUNTIME OFF CACHE BOOL " " FORCE)
+    set(EMBREE_STATIC_LIB OFF CACHE BOOL " " FORCE)
+  else()
+    set(EMBREE_STATIC_LIB ON CACHE BOOL " " FORCE)
+  endif()
+
+  if(NOT TARGET embree)
+    add_subdirectory("${EMBREE_DIR}" "embree")
+  endif()
+
+  if(MSVC)
+    add_custom_target(Copy-Embree-DLL ALL # Adds a post-build event
+        COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E
+        $<TARGET_FILE:embree> # <--this is in-file
+        "${CMAKE_BINARY_DIR}" # <--this is out-file path
+        DEPENDS embree) # Execute after embree target has been built
+  endif()
+
+  compile_igl_module("embree" "")
+  target_link_libraries(igl_embree ${IGL_SCOPE} embree)
+  target_include_directories(igl_embree ${IGL_SCOPE} ${EMBREE_DIR}/include)
+  if(NOT MSVC)
+    target_compile_definitions(igl_embree ${IGL_SCOPE} -DENABLE_STATIC_LIB)
+  endif()
+endif()
+
+################################################################################
+### Compile the lim part ###
+if(LIBIGL_WITH_LIM)
+  set(LIM_DIR "${LIBIGL_EXTERNAL}/lim")
+  if(NOT TARGET lim)
+    add_subdirectory("${LIM_DIR}" "lim")
+  endif()
+  compile_igl_module("lim" "")
+  target_link_libraries(igl_lim ${IGL_SCOPE} lim)
+  target_include_directories(igl_lim ${IGL_SCOPE} ${LIM_DIR})
+endif()
+
+################################################################################
+### Compile the matlab part ###
+if(LIBIGL_WITH_MATLAB)
+  find_package(MATLAB)
+  if(MATLAB_FOUND)
+    compile_igl_module("matlab" "")
+    target_link_libraries(igl_matlab ${IGL_SCOPE} ${MATLAB_LIBRARIES})
+    target_include_directories(igl_matlab ${IGL_SCOPE} ${MATLAB_INCLUDE_DIR})
+  else()
+    set(LIBIGL_WITH_MATLAB OFF CACHE BOOL "" FORCE)
+  endif()
+endif()
+
+################################################################################
+### Compile the mosek part ###
+if(LIBIGL_WITH_MOSEK)
+  find_package(MOSEK)
+  if(MOSEK_FOUND)
+    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)
+  else()
+    set(LIBIGL_WITH_MOSEK OFF CACHE BOOL "" FORCE)
+  endif()
+endif()
+
+################################################################################
+### Compile the opengl parts ###
+
+if(LIBIGL_WITH_OPENGL)
+  # OpenGL modules
+  find_package(OpenGL REQUIRED)
+  compile_igl_module("opengl" "")
+  compile_igl_module("opengl2" "")
+  target_link_libraries(igl_opengl ${IGL_SCOPE} ${OPENGL_gl_LIBRARY})
+  target_link_libraries(igl_opengl2 ${IGL_SCOPE} ${OPENGL_gl_LIBRARY})
+  target_include_directories(igl_opengl SYSTEM ${IGL_SCOPE} ${OPENGL_INCLUDE_DIR})
+  target_include_directories(igl_opengl2 SYSTEM ${IGL_SCOPE} ${OPENGL_INCLUDE_DIR})
+
+  # GLEW for linux and windows
+  if(NOT TARGET glew)
+    add_library(glew STATIC ${NANOGUI_DIR}/ext/glew/src/glew.c)
+    target_include_directories(glew SYSTEM PUBLIC ${NANOGUI_DIR}/ext/glew/include)
+    target_compile_definitions(glew PUBLIC -DGLEW_BUILD -DGLEW_NO_GLU)
+  endif()
+  target_link_libraries(igl_opengl ${IGL_SCOPE} glew)
+  target_link_libraries(igl_opengl2 ${IGL_SCOPE} glew)
+
+  # Nanogui
+  if(LIBIGL_WITH_NANOGUI)
+    if(LIBIGL_WITH_PYTHON)
+      set(NANOGUI_BUILD_PYTHON ON CACHE BOOL " " FORCE)
+    else()
+      set(NANOGUI_BUILD_PYTHON OFF CACHE BOOL " " FORCE)
+    endif()
+    set(NANOGUI_BUILD_EXAMPLE OFF CACHE BOOL " " FORCE)
+    set(NANOGUI_BUILD_SHARED  OFF CACHE BOOL " " FORCE)
+    add_subdirectory(${NANOGUI_DIR} nanogui)
+    target_include_directories(nanogui PUBLIC
+      "${NANOGUI_DIR}/include"
+      "${NANOGUI_DIR}/ext/nanovg/src")
+  endif()
+
+  # GLFW module
+  if(LIBIGL_WITH_OPENGL_GLFW)
+    compile_igl_module("opengl/glfw" "")
+    if(NOT TARGET glfw)
+      set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE)
+      set(GLFW_BUILD_TESTS OFF CACHE BOOL " " FORCE)
+      set(GLFW_BUILD_DOCS OFF CACHE BOOL " " FORCE)
+      set(GLFW_BUILD_INSTALL OFF CACHE BOOL " " FORCE)
+      add_subdirectory(${NANOGUI_DIR}/ext/glfw glfw)
+    endif()
+    target_include_directories(glfw ${IGL_SCOPE} ${NANOGUI_DIR}/ext/glfw/include)
+    target_link_libraries(igl_opengl_glfw ${IGL_SCOPE} igl_opengl glfw)
+  endif()
+
+  # Viewer module
+  if(LIBIGL_WITH_VIEWER)
+    compile_igl_module("viewer" "")
+    target_link_libraries(igl_viewer ${IGL_SCOPE} igl_core glfw glew ${OPENGL_gl_LIBRARY})
+    target_include_directories(igl_viewer SYSTEM ${IGL_SCOPE} ${OPENGL_INCLUDE_DIR})
+    if(TARGET nanogui)
+      target_link_libraries(igl_viewer ${IGL_SCOPE} nanogui)
+      target_compile_definitions(igl_viewer ${IGL_SCOPE} -DIGL_VIEWER_WITH_NANOGUI)
+    endif()
+  endif()
+
+endif()
+
+################################################################################
+### Compile the png parts ###
+if(LIBIGL_WITH_PNG)
+  if(TARGET igl_opengl)
+    set(STB_IMAGE_DIR "${LIBIGL_EXTERNAL}/stb_image")
+    if(NOT TARGET stb_image)
+      add_subdirectory("${STB_IMAGE_DIR}" "stb_image")
+    endif()
+    compile_igl_module("png" "")
+    target_link_libraries(igl_png ${IGL_SCOPE} igl_stb_image igl_opengl)
+  else()
+    set(LIBIGL_WITH_PNG OFF CACHE BOOL "" FORCE)
+  endif()
+endif()
+
+################################################################################
+### Compile the tetgen part ###
+if(LIBIGL_WITH_TETGEN)
+  set(TETGEN_DIR "${LIBIGL_EXTERNAL}/tetgen")
+  if(NOT TARGET tetgen)
+    add_subdirectory("${TETGEN_DIR}" "tetgen")
+  endif()
+  compile_igl_module("tetgen" "copyleft/")
+  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)
+    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 xml part ###
+if(LIBIGL_WITH_XML)
+  set(TINYXML2_DIR "${LIBIGL_EXTERNAL}/tinyxml2")
+  if(NOT TARGET 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)
+endif()
+

+ 2 - 5
tutorial/101_FileIO/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(101_FileIO)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core tutorials)

+ 2 - 5
tutorial/102_DrawMesh/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(102_DrawMesh)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/103_Events/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(103_Events)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/104_Colors/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(104_Colors)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/105_Overlays/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(105_Overlays)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/106_ViewerMenu/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(106_ViewerMenu)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/201_Normals/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(201_Normals)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/202_GaussianCurvature/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(202_GaussianCurvature)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/203_CurvatureDirections/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(203_CurvatureDirections)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/204_Gradient/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(204_Gradient)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/205_Laplacian/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(205_Laplacian)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/301_Slice/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(301_Slice)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/302_Sort/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(302_Sort)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/303_LaplaceEquation/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(303_LaplaceEquation)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/304_LinearEqualityConstraints/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(304_LinearEqualityConstraints)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/305_QuadraticProgramming/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(305_QuadraticProgramming)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/306_EigenDecomposition/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(306_EigenDecomposition)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/401_BiharmonicDeformation/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(401_BiharmonicDeformation)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/402_PolyharmonicDeformation/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(402_PolyharmonicDeformation)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 4 - 7
tutorial/403_BoundedBiharmonicWeights/CMakeLists.txt

@@ -1,11 +1,8 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(403_BoundedBiharmonicWeights)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
-if(LIBIGL_WITH_MOSEK)
-  target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_MOSEK_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)
+if(TARGET igl::mosek)
+  target_link_libraries(${PROJECT_NAME}_bin igl::mosek)
 endif()

+ 7 - 10
tutorial/403_BoundedBiharmonicWeights/main.cpp

@@ -1,13 +1,10 @@
-// If you don't have mosek installed and don't want to install it. Then
-// uncomment the following six lines.  Don't use static library for this
-// example because of Mosek complications
-//
-//#define IGL_NO_MOSEK
-//#ifdef IGL_NO_MOSEK
-//#ifdef IGL_STATIC_LIBRARY
-//#undef IGL_STATIC_LIBRARY
-//#endif
-//#endif
+// Because of Mosek complications, we don't use static library if Mosek is used.
+#ifdef LIBIGL_WITH_MOSEK
+#ifdef IGL_STATIC_LIBRARY
+#undef IGL_STATIC_LIBRARY
+#endif
+#endif
+
 #include <igl/boundary_conditions.h>
 #include <igl/colon.h>
 #include <igl/column_to_quats.h>

+ 2 - 5
tutorial/404_DualQuaternionSkinning/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(404_DualQuaternionSkinning)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/405_AsRigidAsPossible/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(405_AsRigidAsPossible)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/406_FastAutomaticSkinningTransformations/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(406_FastAutomaticSkinningTransformations)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 3 - 5
tutorial/407_BiharmonicCoordinates/CMakeLists.txt

@@ -1,8 +1,6 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(407_BiharmonicCoordinates)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)
+

+ 3 - 5
tutorial/501_HarmonicParam/CMakeLists.txt

@@ -1,8 +1,6 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(501_HarmonicParam)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)
+

+ 2 - 5
tutorial/502_LSCMParam/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(502_LSCMParam)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/503_ARAPParam/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(503_ARAPParam)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/504_NRosyDesign/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(504_NRosyDesign)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES} ${LIBIGL_COMISO_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer igl::comiso tutorials)

+ 2 - 5
tutorial/505_MIQ/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(505_MIQ)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES} ${LIBIGL_COMISO_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer igl::comiso tutorials)

+ 2 - 5
tutorial/506_FrameField/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(506_FrameField)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES} ${LIBIGL_COMISO_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer igl::comiso tutorials)

+ 2 - 5
tutorial/507_PolyVectorField/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(507_PolyVectorField)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/508_ConjugateField/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(508_ConjugateField)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/509_Planarization/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(509_Planarization)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/510_Integrable/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(510_Integrable)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/511_PolyVectorFieldGeneral/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(511_PolyVectorFieldGeneral)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/601_Serialization/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(601_Serialization)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES} ${LIBIGL_XML_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer igl::xml tutorials)

+ 3 - 3
tutorial/601_Serialization/main.cpp

@@ -55,7 +55,7 @@ struct State : public igl::Serializable
 //}
 //
 ////OR:
-// 
+//
 //SERIALIZE_TYPE(State,
 // SERIALIZE_MEMBER(V)
 //  SERIALIZE_MEMBER(F)
@@ -102,9 +102,9 @@ int main(int argc, char *argv[])
   std::cout << "Faces:    " << std::endl << stateOut.F << std::endl;
   std::cout << "ids:      " << std::endl
             << stateOut.ids[0] << " " << stateOut.ids[1] << std::endl;
-			
+
   // XML serialization
-  
+
   // binary = false, overwrite = true
   igl::xml::serialize_xml(vec,"VectorXML",xmlFile,false,true);
   // binary = true, overwrite = false

+ 2 - 5
tutorial/602_Matlab/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(602_Matlab)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES} ${LIBIGL_MATLAB_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer igl::matlab tutorials)

+ 2 - 5
tutorial/604_Triangle/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(604_Triangle)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES} ${LIBIGL_TRIANGLE_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer igl::triangle tutorials)

+ 1 - 3
tutorial/605_Tetgen/CMakeLists.txt

@@ -2,6 +2,4 @@ cmake_minimum_required(VERSION 2.8.12)
 project(605_Tetgen)
 
 add_executable(${PROJECT_NAME}_bin main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES} ${LIBIGL_TETGEN_EXTRA_LIBRARIES})
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer igl::tetgen tutorials)

+ 2 - 5
tutorial/606_AmbientOcclusion/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(606_AmbientOcclusion)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES} ${LIBIGL_EMBREE_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer igl::embree tutorials)

+ 2 - 5
tutorial/607_ScreenCapture/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(607_ScreenCapture)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES} ${LIBIGL_PNG_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer igl::png tutorials)

+ 2 - 5
tutorial/608_LIM/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(608_LIM)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES} ${LIBIGL_LIM_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::lim igl::viewer tutorials)

+ 2 - 5
tutorial/609_Boolean/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(609_Boolean)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES} ${LIBIGL_CGAL_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::cgal igl::viewer tutorials)

+ 0 - 1
tutorial/609_Boolean/main.cpp

@@ -1,5 +1,4 @@
 #include <igl/readOFF.h>
-//#define IGL_NO_CORK
 //#undef IGL_STATIC_LIBRARY
 #include <igl/copyleft/cgal/mesh_boolean.h>
 #include <igl/viewer/Viewer.h>

+ 2 - 5
tutorial/610_CSGTree/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(610_CSGTree)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES} ${LIBIGL_CGAL_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::cgal igl::viewer tutorials)

+ 2 - 5
tutorial/701_Statistics/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(701_Statistics)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 1 - 3
tutorial/702_WindingNumber/CMakeLists.txt

@@ -2,6 +2,4 @@ cmake_minimum_required(VERSION 2.8.12)
 project(702_WindingNumber)
 
 add_executable(${PROJECT_NAME}_bin main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/703_Decimation/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(703_Decimation)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/704_SignedDistance/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(704_SignedDistance)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/705_MarchingCubes/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(705_MarchingCubes)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 1 - 3
tutorial/706_FacetOrientation/CMakeLists.txt

@@ -2,6 +2,4 @@ cmake_minimum_required(VERSION 2.8.12)
 project(706_FacetOrientation)
 
 add_executable(${PROJECT_NAME}_bin main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES} ${LIBIGL_EMBREE_EXTRA_LIBRARIES})
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer igl::embree tutorials)

+ 2 - 5
tutorial/707_SweptVolume/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(707_SweptVolume)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/708_Picking/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(708_Picking)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/709_VectorFieldVisualizer/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(709_VectorFieldVisualizer)
 
-add_executable(${PROJECT_NAME}_bin
-        main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_COMISO_EXTRA_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::comiso igl::viewer tutorials)

+ 2 - 5
tutorial/710_SLIM/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(710_SLIM)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/711_Subdivision/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(711_Subdivision)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 2 - 5
tutorial/712_DataSmoothing/CMakeLists.txt

@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(712_DataSmoothing)
 
-add_executable(${PROJECT_NAME}_bin
-  main.cpp)
-target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
-target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
-target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_VIEWER_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_EXTRA_LIBRARIES} ${LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES})
+add_executable(${PROJECT_NAME}_bin main.cpp)
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 20 - 54
tutorial/CMakeLists.txt

@@ -1,74 +1,39 @@
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.1)
 project(libigl_tutorials)
 message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
 message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
 
+### conditionally compile certain modules depending on libraries found on the system
+list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../shared/cmake)
+find_package(CGAL QUIET COMPONENTS Core)
+find_package(MATLAB QUIET)
+find_package(MOSEK)
+
 ### libIGL options: choose between header only and compiled static library
 option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" ON)
 option(LIBIGL_WITH_VIEWER      "Use OpenGL viewer"  ON)
 option(LIBIGL_WITH_NANOGUI     "Use Nanogui menu"   OFF)
+option(LIBIGL_WITH_EMBREE      "Use Embree"         ON)
 
-### libIGL options: choose your dependencies (by default everything is OFF, in this example we need the viewer) ###
-find_package(CGAL QUIET COMPONENTS Core)
+### libIGL options: choose your dependencies (by default everything is OFF, in this example we need the viewer)
 option(LIBIGL_WITH_CGAL             "Use CGAL"           "${CGAL_FOUND}")
-option(LIBIGL_WITH_COMISO           "Use CoMiso"         ON)
 option(LIBIGL_WITH_CORK             "Use CORK"           OFF)
-option(LIBIGL_WITH_EMBREE           "Use Embree"         ON)
-option(LIBIGL_WITH_LIM              "Use LIM"            ON)
-find_package(MATLAB QUIET)
 option(LIBIGL_WITH_MATLAB           "Use Matlab"         "${MATLAB_FOUND}")
 option(LIBIGL_WITH_MOSEK            "Use MOSEK"          "${MOSEK_FOUND}")
-option(LIBIGL_WITH_OPENGL           "Use OpenGL"         ON)
-option(LIBIGL_WITH_OPENGL_GLFW      "Use OpenGL GLFW"    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_XML              "Use XML"            ON)
-### End   to be tested ----
-
-### libIGL options: decide if you want to use the functionalities that depends on cgal
-if(LIBIGL_WITH_CGAL) # Do not remove or move this block, cgal strange build system fails without it
-  find_package(CGAL REQUIRED COMPONENTS Core)
-  set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE CACHE BOOL "CGAL's CMAKE Setup is super annoying ")
-  include(${CGAL_USE_FILE})
-endif()
-
-### Adding libIGL: choose the path to your local copy libIGL ###
-### This is going to compile everything you requested ###
-add_subdirectory("${PROJECT_SOURCE_DIR}/../shared/cmake" "libigl")
+### End
 
+### Adding libIGL: choose the path to your local copy libIGL
+include(libigl)
 
 ### Output directories
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
-set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
-
-### Compilation flags: adapt to your needs ###
 if(MSVC)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /bigobj") ### Enable parallel compilation
-  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR} )
-  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR} )
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w") # disable all warnings (not ideal but...)
+  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
+  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
 else()
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") #### Libigl requires a modern C++ compiler that supports c++11
-  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../" )
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") # disable all warnings (not ideal but...)
+  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../")
 endif()
 
-# Enable openMP if possible
-#find_package(OpenMP)
-#if (OPENMP_FOUND AND NOT WIN32)
-#  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
-#  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
-#endif()
-
-
-### Prepare the build environment
-
-include_directories(${LIBIGL_INCLUDE_DIRS})
-add_definitions(${LIBIGL_DEFINITIONS})
-
-### Choose which chapters to compile ###
+### Choose which chapters to compile
 option(TUTORIALS_CHAPTER1 "Compile chapter 1" ON)
 option(TUTORIALS_CHAPTER2 "Compile chapter 2" ON)
 option(TUTORIALS_CHAPTER3 "Compile chapter 3" ON)
@@ -79,9 +44,9 @@ option(TUTORIALS_CHAPTER7 "Compile chapter 7" ON)
 
 # Store location of tutorial/shared directory
 set(TUTORIAL_SHARED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/shared CACHE PATH "location of shared tutorial resources")
-add_definitions("-DTUTORIAL_SHARED_PATH=\"${TUTORIAL_SHARED_PATH}\"")
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+add_library(tutorials INTERFACE)
+target_compile_definitions(tutorials INTERFACE "-DTUTORIAL_SHARED_PATH=\"${TUTORIAL_SHARED_PATH}\"")
+target_include_directories(tutorials INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
 
 # Chapter 1
 if(TUTORIALS_CHAPTER1)
@@ -188,3 +153,4 @@ if(TUTORIALS_CHAPTER7)
   add_subdirectory("711_Subdivision")
   add_subdirectory("712_DataSmoothing")
 endif()
+