diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2017-03-17 17:42:50 +0000 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2017-03-17 17:42:50 +0000 |
| commit | 54596de1c33e45fe8bcc217e110a27d755152bdc (patch) | |
| tree | 9406e7ecb432be21dae27a619779b3f70c4f75b7 /CMake/resources.cmake | |
| parent | 298692f55ee56144fde887efd5d5cac2703faa75 (diff) | |
[CMake] Fix Visual Studio header detection.
This commit fixes a CMake issue if CMake is invoked from a desktop icon
or the Windows menu, i.e. not within the correct environment to find all
required header files.
We recommend to run CMake from a "Developer Command Prompt for Visual Studio X",
but sometimes users click on their desktop icon and run CMake without the
correct context. In this case some header files in the Windows SDK's are not
found by CMake.
The solution is to issue a warning and "fix" the header detection by faking
that the headers were found, because they are always available in Visual
Studio. The affected headers <locale.h> and <GL/glu.h> were set to "found"
in the bundles IDE's in FLTK 1.3 as well, so there should be no issue with
this fix.
It is also recommended by the CMake folks, i.e. they suggest not to search
for these special header files that are known to exist always.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12209 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'CMake/resources.cmake')
| -rw-r--r-- | CMake/resources.cmake | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/CMake/resources.cmake b/CMake/resources.cmake index 2fd4bb0a2..259afabb6 100644 --- a/CMake/resources.cmake +++ b/CMake/resources.cmake @@ -43,12 +43,49 @@ else () find_file(HAVE_PTHREAD_H pthread.h) endif (WIN32 AND NOT CYGWIN) +# Special case for Microsoft Visual Studio generator (MSVC): +# +# The header files <GL/glu.h> and <locale.h> are located in the SDK's +# for Visual Studio. If CMake is invoked from a desktop icon or the Windows +# menu it doesn't have the correct paths to find these header files. +# The CMake folks recommend not to search for these files at all, because +# they must always be there, but we do anyway. +# If we don't find them we issue a warning and suggest to rerun CMake from +# a "Developer Command Prompt for Visual Studio xxxx", but we fix the issue +# by setting the *local* instance (not the cache variable) of the corresponding +# CMake variable to '1' since we "know" the header file is available. +# +# If the user builds the solution, everything should run smoothly despite +# the fact that the header files were not found. +# +# If the configuration is changed somehow (e.g. by editing CMakeLists.txt) +# CMake will be rerun from within Visual Studio, find the header file, and +# set the cache variable for the header file to its correct path. The latter is +# only informational so you can see that (and where) the headers were found. +# +# Note: these cache variables can only be seen in "advanced" mode. + if (MSVC) - message(STATUS "Note: The following two headers should be found!") - message(STATUS "HAVE_GL_GLU_H = '${HAVE_GL_GLU_H}'") - message(STATUS "HAVE_LOCALE_H = '${HAVE_LOCALE_H}'") - message(STATUS "If one of these headers was not found, run cmake-gui ...") - message(STATUS "... again from a Visual Studio developer command prompt!") + set (MSVC_RERUN_MESSAGE FALSE) + + if (NOT HAVE_GL_GLU_H) + message(STATUS "Warning: Header file GL/glu.h was not found.") + set (HAVE_GL_GLU_H 1) + set (MSVC_RERUN_MESSAGE TRUE) + endif (NOT HAVE_GL_GLU_H) + + if (NOT HAVE_LOCALE_H) + message(STATUS "Warning: Header file locale.h was not found.") + set (HAVE_LOCALE_H 1) + set (MSVC_RERUN_MESSAGE TRUE) + endif (NOT HAVE_LOCALE_H) + + if (MSVC_RERUN_MESSAGE) + message(STATUS "The FLTK team recommends to rerun CMake from a") + message(STATUS "\"Developer Command Prompt for Visual Studio xxxx\"") + endif (MSVC_RERUN_MESSAGE) + + unset (MSVC_RERUN_MESSAGE) endif (MSVC) # Simulate the behavior of autoconf macro AC_HEADER_DIRENT, see: |
