[tsc-devel] What is the preferred way on a local machine to configure FindXXXX.cmake files?

Chris Jacobsen | Mon, 08 Jun 2015 05:16:44 UTC

I was doing a little work on building TSC in Visual Studio in Windows (issue #421).
I then received an error about Glew not being found (I pasted it further below for completeness).
I know that I should have Glew installed in a special directory.

This is the FindGLEW.cmake file in C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules.  What is the "preferred" way to tell it where to find GLEW so that any time I run cmake on TSC it instantly knows where GLEW is?  I know that I can add set commands for the three variables listed at the top of the cmake file (which is what I will probably do for now).  However, I'd really like to know the best practice, since I've been wondering if this is a hack.  This shows up frequently in school projects I do, too.
# - Find the OpenGL Extension Wrangler Library (GLEW)
# This module defines the following variables:
#  GLEW_INCLUDE_DIRS - include directories for GLEW
#  GLEW_LIBRARIES - libraries to link against GLEW
#  GLEW_FOUND - true if GLEW has been found and can be used

#=============================================================================
# Copyright 2012 Benjamin Eikel
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
#  License text for the above reference.)

find_path(GLEW_INCLUDE_DIR GL/glew.h)
find_library(GLEW_LIBRARY NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64)

set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR})
set(GLEW_LIBRARIES ${GLEW_LIBRARY})

include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(GLEW
                                  REQUIRED_VARS GLEW_INCLUDE_DIR GLEW_LIBRARY)


mark_as_advanced(GLEW_INCLUDE_DIR GLEW_LIBRARY)

---------------------
Here is the error from cmake while building TSC in Windows, for completeness:
Found rake: C:/Ruby22-x64/bin/rake
Found gperf: C:/Program Files (x86)/GnuWin32/bin/gperf.exe
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find GLEW (missing: GLEW_INCLUDE_DIR GLEW_LIBRARY)
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindGLEW.cmake:27 (find_package_handle_standard_args)
CMakeLists.txt:168 (find_package)


Configuring incomplete, errors occurred!
See also "C:/TSC/TSC/tsc/build/CMakeFiles/CMakeOutput.log".

-datahead