|
|
commit a6651e10ffc1753945faf8de0192cf74effc80d8
Author: Jordan Williams <jordan@jwillikers.com>
AuthorDate: Fri Apr 12 08:58:57 2024 -0500
Commit: GitHub <noreply@github.com>
CommitDate: Fri Apr 12 15:58:57 2024 +0200
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.
CMake/options.cmake | 8 ++++++--
src/CMakeLists.txt | 12 ++++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git CMake/options.cmake CMake/options.cmake
index d04431b..fb7ce56 100644
--- CMake/options.cmake
+++ CMake/options.cmake
@@ -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
diff --git src/CMakeLists.txt src/CMakeLists.txt
index 58954c2..b12880c 100644
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -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)
[ Direct Link to Message ] | |
|
| |