Browse Source

Temporary fix for the compiling problem with Xcode

In macOS/ Xcode, libigl failed to build with glfw3 enabled. The root cause of this problem is unknown yet (Maybe something wrong with nano-gui). This patch allows the user to use pre-installed glfw3 in the system to compile, using Xcode 8 or later.
[Issue 383](https://github.com/libigl/libigl/issues/383)


Former-commit-id: 9e7b58bd22bed80f79374b37102ee1f4b7eb350d
Wesley Ranger 7 years ago
parent
commit
9aa9fbe2bf
1 changed files with 15 additions and 7 deletions
  1. 15 7
      shared/cmake/libigl.cmake

+ 15 - 7
shared/cmake/libigl.cmake

@@ -315,14 +315,22 @@ if(LIBIGL_WITH_OPENGL)
   # GLFW module
   # GLFW module
   if(LIBIGL_WITH_OPENGL_GLFW)
   if(LIBIGL_WITH_OPENGL_GLFW)
     compile_igl_module("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_INSTALL OFF CACHE BOOL " " FORCE)
-      add_subdirectory(${NANOGUI_DIR}/ext/glfw glfw)
+    if(CMAKE_GENERATOR STREQUAL Xcode)
+      message(STATUS "Using MacOS & XCode, you have to build/install glfw3 mannually.")
+      message(STATUS "e.g. \'brew install glfw\'")
+      find_package(glfw3 3.2 REQUIRED)
+      message(STATUS "Using the GLFW installation at ${glfw3_DIR}")
+    else()
+      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_INSTALL OFF CACHE BOOL " " FORCE)
+        add_subdirectory(${NANOGUI_DIR}/ext/glfw glfw)
+      endif()
+      target_include_directories(glfw ${IGL_SCOPE} ${NANOGUI_DIR}/ext/glfw/include)
     endif()
     endif()
-    target_include_directories(glfw ${IGL_SCOPE} ${NANOGUI_DIR}/ext/glfw/include)
+    
     target_link_libraries(igl_opengl_glfw ${IGL_SCOPE} igl_opengl glfw)
     target_link_libraries(igl_opengl_glfw ${IGL_SCOPE} igl_opengl glfw)
   endif()
   endif()