Skip to content

Commit

Permalink
Added build options: NO_GLFW NO_GLFW_X11
Browse files Browse the repository at this point in the history
  • Loading branch information
githubhackerdavid committed Jul 28, 2017
1 parent c6a527b commit 0f462e9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 25 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
61 changes: 37 additions & 24 deletions cmake/FindGLFW.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"
)
Expand Down Expand Up @@ -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_Xrandr_FOUND)
message(FATAL_ERROR "Xrandr 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_xf86vmode_FOUND)
message(FATAL_ERROR "xf86vmode 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_Xcursor_FOUND)
message(FATAL_ERROR "Xcursor 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_Xinerama_FOUND)
message(FATAL_ERROR "Xinerama 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_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)
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
Expand All @@ -181,7 +194,7 @@ else ()
/usr/local/lib
/usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/openwin/lib
/usr/X11R6/lib
"${GLFW_X!!_LIB_DIRS}"
DOC
"The GLFW library"
)
Expand Down

0 comments on commit 0f462e9

Please sign in to comment.