diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f3cd9d4..39208961 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,6 +306,8 @@ option(NO_METAL "Disable Metal support" OFF) option(NO_DX "Disable DirectX support") option(NO_TESTS "Disable all tests") option(NO_GLTESTS "Disable GL tests") +option(NO_GLFW "Disable components depending on GLFW" OFF) +option(NO_GLFW_X11 "Disable GLFW components depending on X11" OFF) option(OPENSUBDIV_GREGORY_EVAL_TRUE_DERIVATIVES "Enable true derivative evaluation for Gregory basis patches" OFF) @@ -335,7 +337,7 @@ endif() if(NOT NO_CUDA) find_package(CUDA 4.0) endif() -if(NOT NO_OPENGL AND NOT ANDROID AND NOT IOS) +if(NOT NO_GLFW AND NOT NO_OPENGL AND NOT ANDROID AND NOT IOS) find_package(GLFW 3.0.0) endif() if(NOT NO_PTEX) diff --git a/cmake/FindGLFW.cmake b/cmake/FindGLFW.cmake index 044ff2de..eb21737c 100644 --- a/cmake/FindGLFW.cmake +++ b/cmake/FindGLFW.cmake @@ -30,6 +30,19 @@ # GLFW_LIBRARIES # +if(NOT NO_GLFW_X11) + set(GLFW_X11_INCLUDE_DIRS + "/usr/X11R6/include" + "/usr/include/X11" + ) + set(GLFW_X11_LIB_DIRS + "/usr/X11R6/lib" + ) +else() + set(GLFW_X11_INCLUDE_DIRS "") + set(GLFW_X11_LIB_DIRS "") +endif() + find_path( GLFW_INCLUDE_DIR NAMES GLFW/glfw3.h @@ -41,8 +54,7 @@ find_path( GLFW_INCLUDE_DIR "${OPENGL_INCLUDE_DIR}" /usr/openwin/share/include /usr/openwin/include - /usr/X11R6/include - /usr/include/X11 + "${GLFW_X11_INCLUDE_DIRS}" /opt/graphics/OpenGL/include /opt/graphics/OpenGL/contrib/libglfw /usr/local/include @@ -66,8 +78,7 @@ find_path( GLFW_INCLUDE_DIR "${OPENGL_INCLUDE_DIR}" /usr/openwin/share/include /usr/openwin/include - /usr/X11R6/include - /usr/include/X11 + "${GLFW_X11_INCLUDE_DIRS}" /opt/graphics/OpenGL/include /opt/graphics/OpenGL/contrib/libglfw /usr/local/include @@ -91,7 +102,7 @@ if (WIN32) /usr/lib /usr/lib/w32api /usr/local/lib - /usr/X11R6/lib + "${GLFW_X11_LIB_DIRS}" DOC "The GLFW library" ) @@ -140,29 +151,31 @@ else () find_package(Threads REQUIRED) - find_package(X11 REQUIRED) - - if(NOT X11_Xrandr_FOUND) - message(FATAL_ERROR "Xrandr library not found - required for GLFW") - endif() + if(NOT NO_GLFW_X11) + find_package(X11 REQUIRED) - if(NOT X11_xf86vmode_FOUND) - message(FATAL_ERROR "xf86vmode library not found - required for GLFW") - endif() + if(NOT X11_Xrandr_FOUND) + message(FATAL_ERROR "Xrandr library not found - required for GLFW") + endif() - if(NOT X11_Xcursor_FOUND) - message(FATAL_ERROR "Xcursor library not found - required for GLFW") - endif() + if(NOT X11_xf86vmode_FOUND) + message(FATAL_ERROR "xf86vmode library not found - required for GLFW") + endif() - if(NOT X11_Xinerama_FOUND) - message(FATAL_ERROR "Xinerama library not found - required for GLFW") - endif() + if(NOT X11_Xcursor_FOUND) + message(FATAL_ERROR "Xcursor library not found - required for GLFW") + endif() - if(NOT X11_Xi_FOUND) - message(FATAL_ERROR "Xi library not found - required for GLFW") - endif() + if(NOT X11_Xinerama_FOUND) + message(FATAL_ERROR "Xinerama library not found - required for GLFW") + endif() - list(APPEND GLFW_x11_LIBRARY "${X11_Xrandr_LIB}" "${X11_Xxf86vm_LIB}" "${X11_Xcursor_LIB}" "${X11_Xinerama_LIB}" "${X11_Xi_LIB}" "${X11_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}" -lrt -ldl) + if(NOT X11_Xi_FOUND) + message(FATAL_ERROR "Xi library not found - required for GLFW") + endif() + + list(APPEND GLFW_x11_LIBRARY "${X11_Xrandr_LIB}" "${X11_Xxf86vm_LIB}" "${X11_Xcursor_LIB}" "${X11_Xinerama_LIB}" "${X11_Xi_LIB}" "${X11_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}" -lrt -ldl) + endif (NOT NO_GLFW_X11) find_library( GLFW_glfw_LIBRARY NAMES @@ -181,7 +194,7 @@ else () /usr/local/lib /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} /usr/openwin/lib - /usr/X11R6/lib + "${GLFW_X11_LIB_DIRS}" DOC "The GLFW library" )