CMake: remove cache consistency check (#1046)

The attempted consistency check to remove FLTK's obsolete cache
variable OPENGL_GLU_INCLUDE_DIR which is used by CMake 3.29+ could
cause false positives, at least on macOS, as reported on issue #1046.

This modified code removes OPENGL_GLU_INCLUDE_DIR if it is defined
but FLTK_OPENGL_GLU_INCLUDE_DIR is not (yet) defined which indicates
the first configure execution with the new code.
This commit is contained in:
Albrecht Schlosser 2024-08-23 18:00:43 +02:00
parent d6ddc62b33
commit 9e35b0216f

View File

@ -47,38 +47,23 @@ include(FindPkgConfig)
#######################################################################
# GitHub Issue #1001: try to "repair" the CMake Cache
# GitHub Issue #1046: don't try "too hard" (see GitHub Issue)
#######################################################################
#
# 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.
# We remove "our" cache variable if OPENGL_GLU_INCLUDE_DIR is defined
# but FLTK_OPENGL_GLU_INCLUDE_DIR is not yet defined which indicates
# the first execution after the rename.
#
# FIXME: we can remove this code some time after the release of FLTK 1.4.0.
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))
if(DEFINED OPENGL_GLU_INCLUDE_DIR AND NOT DEFINED FLTK_OPENGL_GLU_INCLUDE_DIR)
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)
endif() # (DEFINED OPENGL_GLU_INCLUDE_DIR AND NOT ...)
#######################################################################
# Find header files...