diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2024-08-08 14:49:34 +0200 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2024-08-08 14:49:34 +0200 |
| commit | e65681c9ac51dda850162a89397b3eec6ee8123a (patch) | |
| tree | 81beb9b681209bc77c9fd77284915874924c283c /CMake/resources.cmake | |
| parent | 713f0b0f64992de8eace6f97d95f4d582f31d9ad (diff) | |
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.
Diffstat (limited to 'CMake/resources.cmake')
| -rw-r--r-- | CMake/resources.cmake | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/CMake/resources.cmake b/CMake/resources.cmake index eaea18c07..c75dfc3f3 100644 --- a/CMake/resources.cmake +++ b/CMake/resources.cmake @@ -46,6 +46,61 @@ include(FindPkgConfig) # 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... ####################################################################### |
