Browse Source

Working on a modernized CMake build.

Former-commit-id: 6240d09272bdc846cf2135ebb6556ef14abcd8e5
Jérémie Dumas 7 years ago
parent
commit
d07b7ef470

+ 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 - 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,

+ 79 - 0
shared/cmake/CXXFeatures.cmake

@@ -0,0 +1,79 @@
+if(NOT (${CMAKE_VERSION} VERSION_LESS "3.8.0"))
+    set(CXX11_FEATURES cxx_std_11)
+    set(CXX14_FEATURES cxx_std_14)
+    set(CXX17_FEATURES cxx_std_17)
+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.

+ 470 - 0
shared/cmake/libigl.cmake

@@ -0,0 +1,470 @@
+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"           OFF)
+option(LIBIGL_WITH_COMISO           "Use CoMiso"         OFF)
+option(LIBIGL_WITH_CORK             "Use Cork"           OFF)
+option(LIBIGL_WITH_EMBREE           "Use Embree"         OFF)
+option(LIBIGL_WITH_LIM              "Use LIM"            OFF)
+option(LIBIGL_WITH_MATLAB           "Use Matlab"         OFF)
+option(LIBIGL_WITH_MOSEK            "Use MOSEK"          OFF)
+option(LIBIGL_WITH_NANOGUI          "Use Nanogui menu"   OFF)
+option(LIBIGL_WITH_OPENGL           "Use OpenGL"         OFF)
+option(LIBIGL_WITH_OPENGL_GLFW      "Use GLFW"           OFF)
+option(LIBIGL_WITH_PNG              "Use PNG"            OFF)
+option(LIBIGL_WITH_TETGEN           "Use Tetgen"         OFF)
+option(LIBIGL_WITH_TRIANGLE         "Use Triangle"       OFF)
+option(LIBIGL_WITH_VIEWER           "Use OpenGL viewer"  OFF)
+option(LIBIGL_WITH_XML              "Use XML"            OFF)
+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()
+
+### Compilation configuration ###
+function(set_compilation_flags target_name)
+  if(MSVC)
+    ### Enable parallel compilation for Visual Studio
+    target_compile_options(${target_name} PRIVATE /MP /bigobj)
+    #target_compile_options(${target_name} PRIVATE /w) # disable all warnings (not ideal but...)
+  else()
+    #target_compile_options(${target_name} PRIVATE -w) # disable all warnings (not ideal but...)
+  endif()
+endfunction()
+
+################################################################################
+
+### 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(LINK_TYPE PUBLIC)
+else()
+  set(LINK_TYPE 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})
+
+if(BUILD_SHARED_LIBS)
+  # Generate position independent code
+  set_target_properties(igl_${module_name} 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})
+    target_link_libraries(igl_${module_name} PUBLIC igl_common)
+    set_compilation_flags(igl_${module_name})
+
+  else()
+    add_library(igl_${module_name} INTERFACE)
+    target_link_libraries(igl_${module_name} INTERFACE igl_common)
+  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")
+#   set(ANTTWEAKBAR_INCLUDE_DIR "${ANTTWEAKBAR_DIR}/include")
+#   set(ANTTWEAKBAR_C_SRC_FILES
+#     "${ANTTWEAKBAR_DIR}/src/TwEventGLFW.c"
+#     "${ANTTWEAKBAR_DIR}/src/TwEventGLUT.c"
+#     "${ANTTWEAKBAR_DIR}/src/TwEventSDL.c"
+#     "${ANTTWEAKBAR_DIR}/src/TwEventSDL12.c"
+#     "${ANTTWEAKBAR_DIR}/src/TwEventSDL13.c"
+#     )
+#   set(ANTTWEAKBAR_CPP_SRC_FILES
+#     "${ANTTWEAKBAR_DIR}/src/LoadOGL.cpp"
+#     "${ANTTWEAKBAR_DIR}/src/LoadOGLCore.cpp"
+#     "${ANTTWEAKBAR_DIR}/src/TwBar.cpp"
+#     "${ANTTWEAKBAR_DIR}/src/TwColors.cpp"
+#     "${ANTTWEAKBAR_DIR}/src/TwEventSFML.cpp"
+#     "${ANTTWEAKBAR_DIR}/src/TwFonts.cpp"
+#     "${ANTTWEAKBAR_DIR}/src/TwMgr.cpp"
+#     "${ANTTWEAKBAR_DIR}/src/TwOpenGL.cpp"
+#     "${ANTTWEAKBAR_DIR}/src/TwOpenGLCore.cpp"
+#     "${ANTTWEAKBAR_DIR}/src/TwPrecomp.cpp"
+#     )
+#     # These are probably needed for windows/Linux, should append if
+#     # windows/Linux
+#     #"${ANTTWEAKBAR_DIR}/src/TwEventWin.c"
+#     #"${ANTTWEAKBAR_DIR}/src/TwEventX11.c"
+#     #"${ANTTWEAKBAR_DIR}/src/TwDirect3D10.cpp"
+#     #"${ANTTWEAKBAR_DIR}/src/TwDirect3D11.cpp"
+#     #"${ANTTWEAKBAR_DIR}/src/TwDirect3D9.cpp"
+#   list(
+#     APPEND
+#     ANTTWEAKBAR_SRC_FILES
+#     "${ANTTWEAKBAR_C_SRC_FILES}"
+#     "${ANTTWEAKBAR_CPP_SRC_FILES}")
+#   add_library(AntTweakBar STATIC "${ANTTWEAKBAR_SRC_FILES}")
+#   target_include_directories(AntTweakBar PUBLIC "${ANTTWEAKBAR_INCLUDE_DIR}")
+#   if(APPLE)
+#     set_target_properties(
+#       AntTweakBar
+#       PROPERTIES
+#       COMPILE_FLAGS
+#       "-fPIC -fno-strict-aliasing -x objective-c++")
+#     target_compile_definitions(
+#       AntTweakBar PUBLIC _MACOSX __PLACEMENT_NEW_INLINE)
+#   endif()
+#   list(APPEND LIBIGL_INCLUDE_DIRS "${ANTTWEAKBAR_INCLUDE_DIR}")
+#   set(LIBIGL_ANTTWEAKBAR_EXTRA_LIBRARIES "AntTweakBar")
+#   list(APPEND LIBIGL_EXTRA_LIBRARIES ${LIBIGL_ANTTWEAKBAR_EXTRA_LIBRARIES})
+#   if(LIBIGL_USE_STATIC_LIBRARY)
+#     compile_igl_module("anttweakbar" "")
+#     target_include_directories(igl_anttweakbar PRIVATE ${ANTTWEAKBAR_INCLUDE_DIR})
+#   endif()
+# endif()
+
+################################################################################
+### Compile the cgal parts ###
+if(LIBIGL_WITH_CGAL)
+  # CGAL Core is needed for
+  # `Exact_predicates_exact_constructions_kernel_with_sqrt`
+  compile_igl_module("cgal" "copyleft/")
+  find_package(CGAL REQUIRED COMPONENTS Core)
+  find_package(Boost 1.48 REQUIRED thread system)
+  target_link_libraries(igl_cgal ${LINK_TYPE} CGAL::CGAL ${Boost_LIBRARIES})
+endif()
+
+################################################################################
+# Compile CoMISo
+# NOTE: this cmakefile works only with the
+# comiso available here: https://github.com/libigl/CoMISo
+# if(LIBIGL_WITH_COMISO)
+#   set(COMISO_DIR "${LIBIGL_EXTERNAL}/CoMISo")
+#   set(COMISO_INCLUDE_DIRS
+#     "${COMISO_DIR}/ext/gmm-4.2/include"
+#     "${COMISO_DIR}/../")
+#   list(APPEND LIBIGL_INCLUDE_DIRS ${COMISO_INCLUDE_DIRS})
+#   #add_definitions(-DINCLUDE_TEMPLATES) (what need this?)
+#   list(APPEND LIBIGL_DEFINITIONS "-DINCLUDE_TEMPLATES")
+#   if(APPLE)
+#     find_library(accelerate_library Accelerate)
+#     list(APPEND LIBIGL_COMISO_EXTRA_LIBRARIES "CoMISo" ${accelerate_library})
+#   elseif(UNIX)
+#     find_package(BLAS REQUIRED)
+#     list(APPEND LIBIGL_COMISO_EXTRA_LIBRARIES "CoMISo" ${BLAS_LIBRARIES})
+#   endif(APPLE)
+#   if(MSVC)
+#     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_SCL_SECURE_NO_DEPRECATE")
+#     #link_directories("${COMISO_ROOT}/CoMISo/ext/OpenBLAS-v0.2.14-Win64-int64/lib/")
+#     list(APPEND LIBIGL_COMISO_EXTRA_LIBRARIES "CoMISo" "${COMISO_DIR}/ext/OpenBLAS-v0.2.14-Win64-int64/lib/libopenblas.dll.a.lib")
+#   endif()
+#   list(APPEND LIBIGL_EXTRA_LIBRARIES ${LIBIGL_COMISO_EXTRA_LIBRARIES})
+#   add_subdirectory("${COMISO_DIR}" "CoMISo")
+#   if(MSVC)
+#     # Copy the dll
+#     add_custom_target(Copy-CoMISo-DLL ALL       # Adds a post-build event to MyTest
+#     COMMAND ${CMAKE_COMMAND} -E copy_if_different
+#         "${COMISO_DIR}/ext/OpenBLAS-v0.2.14-Win64-int64/bin/libopenblas.dll"
+#         "${CMAKE_CURRENT_BINARY_DIR}/../libopenblas.dll"
+#     COMMAND ${CMAKE_COMMAND} -E copy_if_different
+#         "${COMISO_DIR}/ext/OpenBLAS-v0.2.14-Win64-int64/bin/libgcc_s_seh-1.dll"
+#         "${CMAKE_CURRENT_BINARY_DIR}/../libgcc_s_seh-1.dll"
+#     COMMAND ${CMAKE_COMMAND} -E copy_if_different
+#         "${COMISO_DIR}/ext/OpenBLAS-v0.2.14-Win64-int64/bin/libgfortran-3.dll"
+#         "${CMAKE_CURRENT_BINARY_DIR}/../libgfortran-3.dll"
+#     COMMAND ${CMAKE_COMMAND} -E copy_if_different
+#         "${COMISO_DIR}/ext/OpenBLAS-v0.2.14-Win64-int64/bin/libquadmath-0.dll"
+#         "${CMAKE_CURRENT_BINARY_DIR}/../libquadmath-0.dll")
+#   endif()
+#   if(LIBIGL_USE_STATIC_LIBRARY)
+#     compile_igl_module("comiso" "copyleft/")
+#     target_include_directories(igl_comiso PRIVATE ${COMISO_INCLUDE_DIRS})
+#     target_compile_definitions(igl_comiso PRIVATE -DINCLUDE_TEMPLATES)
+#   endif()
+# endif()
+
+################################################################################
+### Compile the cork parts ###
+# if(LIBIGL_WITH_CORK)
+#   set(CORK_DIR "${LIBIGL_EXTERNAL}/cork")
+#   set(CORK_INCLUDE_DIR "${CORK_DIR}/src")
+#   # call this "lib-cork" instead of "cork", otherwise cmake gets confused about
+#   # "cork" executable
+#   add_subdirectory("${CORK_DIR}" "lib-cork")
+#   list(APPEND LIBIGL_INCLUDE_DIRS "${CORK_INCLUDE_DIR}")
+#   list(APPEND LIBIGL_CORK_EXTRA_LIBRARIES "cork")
+#   list(APPEND LIBIGL_EXTRA_LIBRARIES ${LIBIGL_CORK_EXTRA_LIBRARIES})
+#   if(LIBIGL_USE_STATIC_LIBRARY)
+#     compile_igl_module("cork" "copyleft/")
+#     target_include_directories(igl_cork PRIVATE ${CORK_INCLUDE_DIR})
+#   endif()
+# 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()
+
+#   add_subdirectory("${EMBREE_DIR}" "embree")
+#   list(APPEND LIBIGL_INCLUDE_DIRS "${EMBREE_DIR}/include")
+#   list(APPEND LIBIGL_EMBREE_EXTRA_LIBRARIES "embree")
+#   list(APPEND LIBIGL_EXTRA_LIBRARIES ${LIBIGL_EMBREE_EXTRA_LIBRARIES})
+
+#   if(NOT MSVC)
+#     list(APPEND LIBIGL_DEFINITIONS "-DENABLE_STATIC_LIB")
+#   endif()
+
+#   if(MSVC)
+#     add_custom_target(Copy-Embree-DLL ALL        # Adds a post-build event to MyTest
+#         COMMAND ${CMAKE_COMMAND} -E copy_if_different  # which executes "cmake - E copy_if_different..."
+#             "${CMAKE_BINARY_DIR}/libigl/embree/$<CONFIGURATION>/embree.dll"      # <--this is in-file
+#           "${CMAKE_BINARY_DIR}/embree.dll")                 # <--this is out-file path  endif()
+#   endif()
+
+#   if(LIBIGL_USE_STATIC_LIBRARY)
+#     compile_igl_module("embree" "")
+#     target_include_directories(igl_embree PRIVATE ${EMBREE_DIR}/include)
+#   if(NOT MSVC)
+#     target_compile_definitions(igl_embree PRIVATE -DENABLE_STATIC_LIB)
+#   endif()
+#   endif()
+# endif()
+
+################################################################################
+### Compile the lim part ###
+# if(LIBIGL_WITH_LIM)
+#   set(LIM_DIR "${LIBIGL_EXTERNAL}/lim")
+#   add_subdirectory("${LIM_DIR}" "lim")
+#   list(APPEND LIBIGL_INCLUDE_DIRS ${LIM_DIR})
+#   ## it depends on ligigl, so placing it here solve linking problems
+#   #list(APPEND LIBIGL_LIBRARIES "lim")
+#   # ^--- Alec: I don't understand this comment. Does lim need to come before
+#   # libigl libraries? Why can't lim be placed where it belongs in
+#   # LIBIGL_EXTRA_LIBRARIES?
+#   set(LIBIGL_LIM_EXTRA_LIBRARIES "lim")
+#   list(APPEND LIBIGL_EXTRA_LIBRARIES "${LIBIGL_LIM_EXTRA_LIBRARIES}")
+
+#   if(LIBIGL_USE_STATIC_LIBRARY)
+#     compile_igl_module("lim" "")
+#     target_include_directories(igl_lim PRIVATE ${LIM_DIR})
+#   endif()
+# endif()
+
+################################################################################
+### Compile the matlab part ###
+# if(LIBIGL_WITH_MATLAB)
+#   find_package(MATLAB REQUIRED)
+#   list(APPEND LIBIGL_INCLUDE_DIRS ${MATLAB_INCLUDE_DIR})
+#   list(APPEND LIBIGL_MATLAB_EXTRA_LIBRARIES ${MATLAB_LIBRARIES})
+#   list(APPEND LIBIGL_EXTRA_LIBRARIES ${LIBIGL_MATLAB_EXTRA_LIBRARIES})
+
+#   if(LIBIGL_USE_STATIC_LIBRARY)
+#     compile_igl_module("matlab" "")
+#     target_include_directories(igl_matlab PRIVATE ${MATLAB_INCLUDE_DIR})
+#   endif()
+# endif()
+
+################################################################################
+### Compile the mosek part ###
+# if(LIBIGL_WITH_MOSEK)
+#   find_package(MOSEK REQUIRED)
+#   list(APPEND LIBIGL_INCLUDE_DIRS ${MOSEK_INCLUDE_DIR})
+#   list(APPEND LIBIGL_MOSEK_EXTRA_LIBRARIES ${MOSEK_LIBRARIES})
+#   list(APPEND LIBIGL_EXTRA_LIBRARIES ${LIBIGL_MOSEK_EXTRA_LIBRARIES})
+#   if(LIBIGL_USE_STATIC_LIBRARY)
+#     compile_igl_module("mosek" "")
+#     target_include_directories(igl_mosek PRIVATE ${MOSEK_INCLUDE_DIR})
+#   endif()
+# else()
+#   list(APPEND LIBIGL_DEFINITIONS "-DIGL_NO_MOSEK")
+# endif()
+
+################################################################################
+### Compile the opengl parts ###
+
+if(LIBIGL_WITH_OPENGL)
+  compile_igl_module("opengl" "")
+  compile_igl_module("opengl2" "")
+
+  find_package(OpenGL REQUIRED)
+  target_link_libraries(igl_opengl ${LINK_TYPE} ${OPENGL_gl_LIBRARY})
+  target_link_libraries(igl_opengl2 ${LINK_TYPE} ${OPENGL_gl_LIBRARY})
+  target_include_directories(igl_opengl SYSTEM ${LINK_TYPE} ${OPENGL_INCLUDE_DIR})
+  target_include_directories(igl_opengl2 SYSTEM ${LINK_TYPE} ${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 ${LINK_TYPE} glew)
+  target_link_libraries(igl_opengl2 ${LINK_TYPE} glew)
+
+  if(LIBIGL_WITH_OPENGL_GLFW)
+    # 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_link_libraries(igl_opengl_glfw ${LINK_TYPE} igl_opengl glfw)
+
+    ### Compile the viewer
+    if(LIBIGL_WITH_VIEWER)
+      compile_igl_module("viewer" "")
+      target_link_libraries(igl_viewer ${LINK_TYPE} igl_core glfw glew OpenGL::GL)
+
+      if(LIBIGL_WITH_NANOGUI)
+        target_compile_definitions(igl_viewer PUBLIC -DIGL_VIEWER_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_link_libraries(igl_viewer ${LINK_TYPE} nanogui)
+      endif()
+    endif()
+
+  endif()
+
+endif()
+
+################################################################################
+### Compile the png parts ###
+# if(LIBIGL_WITH_PNG)
+#   if(LIBIGL_WITH_NANOGUI)
+#     set(STBI_LOAD OFF CACHE BOOL " " FORCE)
+#   endif()
+#   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_EXTRA_LIBRARIES ${LIBIGL_PNG_EXTRA_LIBRARIES})
+#   if(LIBIGL_USE_STATIC_LIBRARY)
+#     compile_igl_module("png" "")
+#     target_include_directories(igl_png PRIVATE ${STB_IMAGE_DIR})
+#     if(NOT APPLE)
+#       target_include_directories(igl_png PRIVATE "${NANOGUI_DIR}/ext/glew/include")
+#     endif()
+#   endif()
+# endif()
+
+################################################################################
+### Compile the tetgen part ###
+# if(LIBIGL_WITH_TETGEN)
+#   set(TETGEN_DIR "${LIBIGL_EXTERNAL}/tetgen")
+#   add_subdirectory("${TETGEN_DIR}" "tetgen")
+#   list(APPEND LIBIGL_INCLUDE_DIRS ${TETGEN_DIR})
+#   list(APPEND LIBIGL_TETGEN_EXTRA_LIBRARIES "tetgen")
+#   list(APPEND LIBIGL_EXTRA_LIBRARIES ${LIBIGL_TETGEN_EXTRA_LIBRARIES})
+
+#   if(LIBIGL_USE_STATIC_LIBRARY)
+#     compile_igl_module("tetgen" "copyleft/")
+#     target_include_directories(igl_tetgen PRIVATE ${TETGEN_DIR})
+#   endif()
+# endif()
+
+################################################################################
+### Compile the triangle part ###
+# if(LIBIGL_WITH_TRIANGLE)
+#   set(TRIANGLE_DIR "${LIBIGL_EXTERNAL}/triangle")
+#   add_subdirectory("${TRIANGLE_DIR}" "triangle")
+#   list(APPEND LIBIGL_INCLUDE_DIRS ${TRIANGLE_DIR})
+#   list(APPEND LIBIGL_TRIANGLE_EXTRA_LIBRARIES "triangle")
+#   list(APPEND LIBIGL_EXTRA_LIBRARIES ${LIBIGL_TRIANGLE_EXTRA_LIBRARIES})
+
+#   if(LIBIGL_USE_STATIC_LIBRARY)
+#     compile_igl_module("triangle" "")
+#     target_include_directories(igl_triangle PRIVATE ${TRIANGLE_DIR})
+#   endif()
+# endif()
+
+################################################################################
+### Compile the xml part ###
+# if(LIBIGL_WITH_XML)
+#   set(TINYXML2_DIR "${LIBIGL_EXTERNAL}/tinyxml2")
+#   add_library(tinyxml2 STATIC ${TINYXML2_DIR}/tinyxml2.cpp ${TINYXML2_DIR}/tinyxml2.h)
+#   set_target_properties(tinyxml2 PROPERTIES
+#           COMPILE_DEFINITIONS "TINYXML2_EXPORT"
+#           VERSION "3.0.0"
+#           SOVERSION "3")
+#   list(APPEND LIBIGL_INCLUDE_DIRS ${TINYXML2_DIR})
+#   list(APPEND LIBIGL_XML_EXTRA_LIBRARIES "tinyxml2")
+#   list(APPEND LIBIGL_EXTRA_LIBRARIES ${LIBIGL_XML_EXTRA_LIBRARIES})
+#   if(LIBIGL_USE_STATIC_LIBRARY)
+#     compile_igl_module("xml" "")
+#     target_include_directories(igl_xml PRIVATE ${TINYXML2_DIR})
+#   endif()
+# endif()
+
+# Function to print list nicely
+# function(print_list title list)
+#   message("-- ${title}:")
+#   foreach(elt ${list})
+#     message("\t ${elt}")
+#   endforeach()
+# endfunction()

+ 1 - 3
tutorial/101_FileIO/CMakeLists.txt

@@ -3,6 +3,4 @@ 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})
+target_link_libraries(${PROJECT_NAME}_bin igl::core tutorials)

+ 1 - 3
tutorial/102_DrawMesh/CMakeLists.txt

@@ -3,6 +3,4 @@ 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})
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 1 - 3
tutorial/103_Events/CMakeLists.txt

@@ -3,6 +3,4 @@ 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})
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 1 - 3
tutorial/104_Colors/CMakeLists.txt

@@ -3,6 +3,4 @@ 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})
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 1 - 3
tutorial/105_Overlays/CMakeLists.txt

@@ -3,6 +3,4 @@ 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})
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 1 - 3
tutorial/106_ViewerMenu/CMakeLists.txt

@@ -3,6 +3,4 @@ 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})
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::viewer tutorials)

+ 1 - 3
tutorial/609_Boolean/CMakeLists.txt

@@ -3,6 +3,4 @@ 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})
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::cgal igl::viewer tutorials)

+ 1 - 3
tutorial/610_CSGTree/CMakeLists.txt

@@ -3,6 +3,4 @@ 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})
+target_link_libraries(${PROJECT_NAME}_bin igl::core igl::cgal igl::viewer tutorials)

+ 16 - 46
tutorial/CMakeLists.txt

@@ -1,10 +1,10 @@
-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}")
 
 ### libIGL options: choose between header only and compiled static library
-option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" ON)
+option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" OFF)
 option(LIBIGL_WITH_VIEWER      "Use OpenGL viewer"  ON)
 option(LIBIGL_WITH_NANOGUI     "Use Nanogui menu"   OFF)
 
@@ -26,62 +26,32 @@ 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")
-
+list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../shared/cmake)
+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 ###
 option(TUTORIALS_CHAPTER1 "Compile chapter 1" ON)
-option(TUTORIALS_CHAPTER2 "Compile chapter 2" ON)
-option(TUTORIALS_CHAPTER3 "Compile chapter 3" ON)
-option(TUTORIALS_CHAPTER4 "Compile chapter 4" ON)
-option(TUTORIALS_CHAPTER5 "Compile chapter 5" ON)
-option(TUTORIALS_CHAPTER6 "Compile chapter 6" ON)
-option(TUTORIALS_CHAPTER7 "Compile chapter 7" ON)
+option(TUTORIALS_CHAPTER2 "Compile chapter 2" OFF)
+option(TUTORIALS_CHAPTER3 "Compile chapter 3" OFF)
+option(TUTORIALS_CHAPTER4 "Compile chapter 4" OFF)
+option(TUTORIALS_CHAPTER5 "Compile chapter 5" OFF)
+option(TUTORIALS_CHAPTER6 "Compile chapter 6" OFF)
+option(TUTORIALS_CHAPTER7 "Compile chapter 7" OFF)
 
 # Store location of tutorial/shared directory
+add_library(tutorials INTERFACE)
 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})
+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)