Sfoglia il codice sorgente

Work-around for GLFW+GLEW+NANOGUI CMake conflict

Former-commit-id: c7b023dbacbf46b70d3025cf3fb86fd3ffd37807
Julian Panetta 8 anni fa
parent
commit
0a47cbf143
1 ha cambiato i file con 13 aggiunte e 2 eliminazioni
  1. 13 2
      shared/cmake/CMakeLists.txt

+ 13 - 2
shared/cmake/CMakeLists.txt

@@ -328,7 +328,13 @@ if(LIBIGL_WITH_OPENGL)
   ### GLEW for linux and windows
   if((UNIX AND NOT APPLE) OR WIN32) ### Compile glew if needed
     set(GLEW_INSTALL OFF CACHE BOOL " " FORCE)
-    add_subdirectory("${NANOGUI_DIR}/ext/glew" "glew")
+
+    # Note: if add_subdirectory("${NANOGUI_DIR}" "nanogui") runs below it will
+    # add GLEW as a side-effect; in this case, CMake will complain about
+    # duplicates if we add them here.
+    if (NOT (LIBIGL_WITH_OPENGL_GLFW AND LIBIGL_WITH_VIEWER AND LIBIGL_WITH_NANOGUI))
+        add_subdirectory("${NANOGUI_DIR}/ext/glew" "glew")
+    endif()
   endif()
   if(NOT APPLE)
     list(APPEND LIBIGL_INCLUDE_DIRS "${NANOGUI_DIR}/ext/glew/include")
@@ -343,7 +349,12 @@ if(LIBIGL_WITH_OPENGL)
       list(APPEND GLFW_INCLUDE_DIRS "${NANOGUI_DIR}/ext/glew/include")
     endif()
 
-    add_subdirectory("${NANOGUI_DIR}/ext/glfw" "glfw")
+    # Note: if add_subdirectory("${NANOGUI_DIR}" "nanogui") runs below it will
+    # add GLFW as a side-effect; in this case, CMake will complain about
+    # duplicates if we add them here.
+    if (NOT (LIBIGL_WITH_VIEWER AND LIBIGL_WITH_NANOGUI))
+        add_subdirectory("${NANOGUI_DIR}/ext/glfw" "glfw")
+    endif()
     set(LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES "glfw" ${GLFW_LIBRARIES})
     if(LIBIGL_USE_STATIC_LIBRARY)
       CompileIGL_Module("opengl/glfw" "")