mirror of https://github.com/fltk/fltk
CMake: Improve detection of the GLU library and GL/glu.h header file (#953)
* CMake: Improve detection of the GLU library and GL/glu.h header file Locate the GLU library and header independent of the GL library and header locations. Add the GLU header location to necessary target_include_directory calls. * CMake: Locate and use the GL include directory Find the GL include directory and use it in target_include_directories calls.
This commit is contained in:
parent
5de880ae81
commit
a6651e10ff
|
@ -613,9 +613,12 @@ if(FLTK_BUILD_GL)
|
|||
set(OPENGL_FOUND TRUE)
|
||||
find_library(OPENGL_LIB GL)
|
||||
get_filename_component(PATH_TO_GLLIB ${OPENGL_LIB} DIRECTORY)
|
||||
find_library(GLU_LIB GLU)
|
||||
get_filename_component(PATH_TO_GLULIB ${GLU_LIB} DIRECTORY)
|
||||
# FIXME: we should find a better way to resolve this issue:
|
||||
# with GL, must use XQuartz libX11 else "Insufficient GL support"
|
||||
set(OPENGL_LIBRARIES -L${PATH_TO_GLLIB} -lX11 -lGLU -lGL)
|
||||
set(OPENGL_LIBRARIES -L${PATH_TO_GLULIB} -L${PATH_TO_GLLIB} -lX11 -lGLU -lGL)
|
||||
find_path(OPENGL_INCLUDE_DIR NAMES GL/gl.h OpenGL/gl.h HINTS ${X11_INCLUDE_DIR})
|
||||
unset(HAVE_GL_GLU_H CACHE)
|
||||
find_file(HAVE_GL_GLU_H GL/glu.h PATHS ${X11_INCLUDE_DIR})
|
||||
else()
|
||||
|
@ -638,7 +641,8 @@ mark_as_advanced(OPENGL_LIB) # internal cache variable, not relevant for users
|
|||
mark_as_advanced(HAVE_GL_GLU_H)
|
||||
|
||||
if(OPENGL_FOUND)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${OPENGL_INCLUDE_DIR}/GL)
|
||||
find_path(OPENGL_GLU_INCLUDE_DIR NAMES GL/glu.h OpenGL/glu.h HINTS ${OPENGL_INCLUDE_DIR} ${X11_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_INCLUDES ${OPENGL_INCLUDE_DIR}/GL ${OPENGL_GLU_INCLUDE_DIR})
|
||||
|
||||
# Set GLLIBS (used in fltk-config).
|
||||
# We should probably deduct this from OPENGL_LIBRARIES but it turned
|
||||
|
|
|
@ -813,6 +813,10 @@ endif()
|
|||
if(FLTK_USE_GL)
|
||||
fl_add_library(fltk_gl STATIC "${GLCPPFILES};${GL_HEADER_FILES};${GL_DRIVER_HEADER_FILES}")
|
||||
target_link_libraries(fltk_gl PUBLIC ${OPENGL_LIBRARIES} fltk::fltk)
|
||||
target_include_directories(fltk_gl PUBLIC ${OPENGL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIRS})
|
||||
if(OPENGL_GLU_INCLUDE_DIR)
|
||||
target_include_directories(fltk_gl PUBLIC ${OPENGL_GLU_INCLUDE_DIR})
|
||||
endif()
|
||||
endif(FLTK_USE_GL)
|
||||
|
||||
#######################################################################
|
||||
|
@ -879,6 +883,10 @@ if(FLTK_BUILD_SHARED_LIBS AND NOT MSVC)
|
|||
if(FLTK_USE_GL)
|
||||
fl_add_library(fltk_gl SHARED "${GLCPPFILES};${GL_HEADER_FILES};${GL_DRIVER_HEADER_FILES}")
|
||||
target_link_libraries(fltk_gl-shared PUBLIC ${OPENGL_LIBRARIES} fltk::fltk-shared)
|
||||
target_include_directories(fltk_gl-shared PUBLIC ${OPENGL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIRS})
|
||||
if(OPENGL_GLU_INCLUDE_DIR)
|
||||
target_include_directories(fltk_gl-shared PUBLIC ${OPENGL_GLU_INCLUDE_DIR})
|
||||
endif()
|
||||
endif(FLTK_USE_GL)
|
||||
|
||||
endif(FLTK_BUILD_SHARED_LIBS AND NOT MSVC)
|
||||
|
@ -918,6 +926,10 @@ if(FLTK_BUILD_SHARED_LIBS AND MSVC)
|
|||
|
||||
if(OPENGL_FOUND)
|
||||
target_link_libraries(fltk-shared PUBLIC ${OPENGL_LIBRARIES})
|
||||
target_include_directories(fltk_gl-shared PUBLIC ${OPENGL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIRS})
|
||||
if(OPENGL_GLU_INCLUDE_DIR)
|
||||
target_include_directories(fltk-shared PUBLIC ${OPENGL_GLU_INCLUDE_DIR})
|
||||
endif()
|
||||
endif(OPENGL_FOUND)
|
||||
|
||||
endif(FLTK_BUILD_SHARED_LIBS AND MSVC)
|
||||
|
|
Loading…
Reference in New Issue