mirror of https://github.com/fltk/fltk
CMake: fix usage of OPENGL_GLU_INCLUDE_DIR (#1001)
This commit consists of two parts: 1. CMake/resources.cmake: remove the old variable OPENGL_GLU_INCLUDE_DIR from the CMake cache if possible, otherwise enforce a clean build. 2. src/CMakeLists.txt, CMake/options.cmake: use the new variable name FLTK_OPENGL_GLU_INCLUDE_DIR. For details please see GitHub Issue #1001.
This commit is contained in:
parent
713f0b0f64
commit
e65681c9ac
|
@ -611,7 +611,7 @@ endif(FLTK_OPTION_SVG)
|
|||
|
||||
#######################################################################
|
||||
|
||||
# FIXME: GL libs have already been searched in resources.cmake
|
||||
# FIXME: GLU libs have already been searched in resources.cmake
|
||||
|
||||
set(HAVE_GL LIB_GL OR LIB_MesaGL)
|
||||
set(FLTK_USE_GL FALSE)
|
||||
|
@ -681,8 +681,8 @@ set(FLTK_GL_FOUND FALSE)
|
|||
|
||||
if(OPENGL_FOUND)
|
||||
set(FLTK_GL_FOUND TRUE)
|
||||
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})
|
||||
find_path(FLTK_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 ${FLTK_OPENGL_GLU_INCLUDE_DIR})
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND GLLIBS -lglu32 -lopengl32)
|
||||
|
|
|
@ -45,6 +45,61 @@ include(FindPkgConfig)
|
|||
# fl_debug_var(PKG_CONFIG_EXECUTABLE)
|
||||
# fl_debug_var(PKG_CONFIG_VERSION_STRING)
|
||||
|
||||
#######################################################################
|
||||
# GitHub Issue #1001: try to "repair" the CMake Cache
|
||||
#######################################################################
|
||||
#
|
||||
# Note: we renamed "our" CMake cache variable OPENGL_GLU_INCLUDE_DIR
|
||||
# to FLTK_OPENGL_GLU_INCLUDE_DIR because the former is now defined
|
||||
# in find_package(OpenGL) (FindOpenGL.cmake) since CMake 3.29.0.
|
||||
#
|
||||
# We can remove "our" cache variable if any of these conditions is true:
|
||||
#
|
||||
# - CMAKE_VERSION < 3.29
|
||||
# - FLTK_OPENGL_GLU_INCLUDE_DIR is undefined (first run after rename)
|
||||
# - OPENGL_GLU_INCLUDE_DIR is FALSE, i.e. OPENGL_GLU_INCLUDE_DIR-NOTFOUND.
|
||||
#
|
||||
# Otherwise we can't be sure to remove the *correct* definition of
|
||||
# OPENGL_GLU_INCLUDE_DIR and we force the user to rebuild in a clean
|
||||
# CMake build directory. This should rarely happen.
|
||||
#
|
||||
# FIXME: we can remove this code some time after the release of FLTK 1.4.0.
|
||||
|
||||
### DEBUG:
|
||||
if(DEFINED OPENGL_GLU_INCLUDE_DIR)
|
||||
set(OPENGL_GLU_INCLUDE_DIR_DEFINED TRUE)
|
||||
endif()
|
||||
|
||||
if(DEFINED FLTK_OPENGL_GLU_INCLUDE_DIR)
|
||||
set(FLTK_OPENGL_GLU_INCLUDE_DIR_DEFINED TRUE)
|
||||
endif()
|
||||
|
||||
fl_debug_var(OPENGL_FOUND)
|
||||
fl_debug_var(OPENGL_INCLUDE_DIR)
|
||||
|
||||
fl_debug_var(OPENGL_GLU_INCLUDE_DIR_DEFINED)
|
||||
fl_debug_var(OPENGL_GLU_INCLUDE_DIR)
|
||||
|
||||
fl_debug_var(FLTK_OPENGL_GLU_INCLUDE_DIR_DEFINED)
|
||||
fl_debug_var(FLTK_OPENGL_GLU_INCLUDE_DIR)
|
||||
### /DEBUG
|
||||
|
||||
if(DEFINED OPENGL_GLU_INCLUDE_DIR)
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS 3.29 OR
|
||||
(NOT DEFINED FLTK_OPENGL_GLU_INCLUDE_DIR) OR
|
||||
(NOT OPENGL_GLU_INCLUDE_DIR))
|
||||
# message(STATUS "**** Removing OPENGL_GLU_INCLUDE_DIR from CMake cache ****")
|
||||
unset(OPENGL_GLU_INCLUDE_DIR)
|
||||
unset(OPENGL_GLU_INCLUDE_DIR CACHE)
|
||||
else()
|
||||
message(STATUS "")
|
||||
message(NOTICE "FLTK configure: CMake cache inconsistency detected")
|
||||
message(FATAL_ERROR "Please rebuild FLTK in a clean CMake build directory")
|
||||
endif()
|
||||
|
||||
endif() # (DEFINED OPENGL_GLU_INCLUDE_DIR)
|
||||
|
||||
#######################################################################
|
||||
# Find header files...
|
||||
#######################################################################
|
||||
|
|
|
@ -849,8 +849,8 @@ if(FLTK_USE_GL)
|
|||
target_link_libraries(fltk_gl PRIVATE ${OPTIONAL_LIBS})
|
||||
target_include_directories(fltk_gl PRIVATE ${OPTIONAL_INCLUDES})
|
||||
|
||||
if(OPENGL_GLU_INCLUDE_DIR)
|
||||
target_include_directories(fltk_gl PUBLIC ${OPENGL_GLU_INCLUDE_DIR})
|
||||
if(FLTK_OPENGL_GLU_INCLUDE_DIR)
|
||||
target_include_directories(fltk_gl PUBLIC ${FLTK_OPENGL_GLU_INCLUDE_DIR})
|
||||
endif()
|
||||
endif(FLTK_USE_GL)
|
||||
|
||||
|
@ -912,8 +912,8 @@ if(FLTK_BUILD_SHARED_LIBS AND NOT MSVC)
|
|||
target_link_libraries(fltk_gl-shared PRIVATE ${OPTIONAL_LIBS})
|
||||
target_include_directories(fltk_gl-shared PRIVATE ${OPTIONAL_INCLUDES})
|
||||
|
||||
if(OPENGL_GLU_INCLUDE_DIR)
|
||||
target_include_directories(fltk_gl-shared PUBLIC ${OPENGL_GLU_INCLUDE_DIR})
|
||||
if(FLTK_OPENGL_GLU_INCLUDE_DIR)
|
||||
target_include_directories(fltk_gl-shared PUBLIC ${FLTK_OPENGL_GLU_INCLUDE_DIR})
|
||||
endif()
|
||||
endif(FLTK_USE_GL)
|
||||
|
||||
|
@ -956,8 +956,8 @@ if(FLTK_BUILD_SHARED_LIBS AND MSVC)
|
|||
if(OPENGL_FOUND)
|
||||
target_link_libraries(fltk-shared PUBLIC ${OPENGL_LIBRARIES})
|
||||
target_include_directories(fltk-shared PUBLIC ${OPENGL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIRS})
|
||||
if(OPENGL_GLU_INCLUDE_DIR)
|
||||
target_include_directories(fltk-shared PUBLIC ${OPENGL_GLU_INCLUDE_DIR})
|
||||
if(FLTK_OPENGL_GLU_INCLUDE_DIR)
|
||||
target_include_directories(fltk-shared PUBLIC ${FLTK_OPENGL_GLU_INCLUDE_DIR})
|
||||
endif()
|
||||
endif(OPENGL_FOUND)
|
||||
|
||||
|
|
Loading…
Reference in New Issue