From 0b093c53653cd75cc0b2d9b032b59aabd4d95b46 Mon Sep 17 00:00:00 2001 From: zmertens Date: Tue, 31 Mar 2015 18:11:48 -0700 Subject: [PATCH] added Find*.cmake files and cmake/modules directory --- cmake/modules/FindASSIMP.cmake | 30 +++++++++++++++++ cmake/modules/FindGLEW.cmake | 59 ++++++++++++++++++++++++++++++++++ cmake/modules/FindGLFW3.cmake | 47 +++++++++++++++++++++++++++ cmake/modules/FindGLM.cmake | 56 ++++++++++++++++++++++++++++++++ cmake/modules/FindSOIL.cmake | 33 +++++++++++++++++++ 5 files changed, 225 insertions(+) create mode 100644 cmake/modules/FindASSIMP.cmake create mode 100644 cmake/modules/FindGLEW.cmake create mode 100644 cmake/modules/FindGLFW3.cmake create mode 100644 cmake/modules/FindGLM.cmake create mode 100644 cmake/modules/FindSOIL.cmake diff --git a/cmake/modules/FindASSIMP.cmake b/cmake/modules/FindASSIMP.cmake new file mode 100644 index 0000000..571085f --- /dev/null +++ b/cmake/modules/FindASSIMP.cmake @@ -0,0 +1,30 @@ +# - Try to find Assimp +# Once done, this will define +# +# ASSIMP_FOUND - system has Assimp +# ASSIMP_INCLUDE_DIR - the Assimp include directories +# ASSIMP_LIBRARIES - link these to use Assimp +FIND_PATH( ASSIMP_INCLUDE_DIR assimp/mesh.h + /usr/include + /usr/local/include + /opt/local/include +) +FIND_LIBRARY( ASSIMP_LIBRARY assimp + /usr/lib64 + /usr/lib + /usr/local/lib + /opt/local/lib +) +IF(ASSIMP_INCLUDE_DIR AND ASSIMP_LIBRARY) + SET( ASSIMP_FOUND TRUE ) + SET( ASSIMP_LIBRARIES ${ASSIMP_LIBRARY} ) +ENDIF(ASSIMP_INCLUDE_DIR AND ASSIMP_LIBRARY) +IF(ASSIMP_FOUND) + IF(NOT ASSIMP_FIND_QUIETLY) + MESSAGE(STATUS "Found ASSIMP: ${ASSIMP_LIBRARY}") + ENDIF(NOT ASSIMP_FIND_QUIETLY) +ELSE(ASSIMP_FOUND) + IF(ASSIMP_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find libASSIMP") + ENDIF(ASSIMP_FIND_REQUIRED) +ENDIF(ASSIMP_FOUND) diff --git a/cmake/modules/FindGLEW.cmake b/cmake/modules/FindGLEW.cmake new file mode 100644 index 0000000..68c87f8 --- /dev/null +++ b/cmake/modules/FindGLEW.cmake @@ -0,0 +1,59 @@ +# +# Try to find GLEW library and include path. +# Once done this will define +# +# GLEW_FOUND +# GLEW_INCLUDE_PATH +# GLEW_LIBRARY +# +IF (WIN32) + FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h + $ENV{PROGRAMFILES}/GLEW/include + ${GLEW_ROOT_DIR}/include + DOC "The directory where GL/glew.h resides") + IF (NV_SYSTEM_PROCESSOR STREQUAL "AMD64") + FIND_LIBRARY( GLEW_LIBRARY + NAMES glew64 glew64s + PATHS + $ENV{PROGRAMFILES}/GLEW/lib + ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin + ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib + DOC "The GLEW library (64-bit)" + ) + ELSE(NV_SYSTEM_PROCESSOR STREQUAL "AMD64") + FIND_LIBRARY( GLEW_LIBRARY + NAMES glew GLEW glew32 glew32s + PATHS + $ENV{PROGRAMFILES}/GLEW/lib + ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin + ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib + DOC "The GLEW library" + ) + ENDIF(NV_SYSTEM_PROCESSOR STREQUAL "AMD64") +ELSE (WIN32) + FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h + /usr/include + /usr/local/include + /sw/include + /opt/local/include + ${GLEW_ROOT_DIR}/include + DOC "The directory where GL/glew.h resides") + FIND_LIBRARY( GLEW_LIBRARY + NAMES GLEW glew + PATHS + /usr/lib64 + /usr/lib + /usr/local/lib64 + /usr/local/lib + /sw/lib + /opt/local/lib + ${GLEW_ROOT_DIR}/lib + DOC "The GLEW library") +ENDIF (WIN32) +SET(GLEW_FOUND "NO") +IF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY) + SET(GLEW_LIBRARIES ${GLEW_LIBRARY}) + SET(GLEW_FOUND "YES") +ENDIF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_LIBRARY GLEW_INCLUDE_PATH) diff --git a/cmake/modules/FindGLFW3.cmake b/cmake/modules/FindGLFW3.cmake new file mode 100644 index 0000000..b50e684 --- /dev/null +++ b/cmake/modules/FindGLFW3.cmake @@ -0,0 +1,47 @@ +# Locate the glfw3 library +# +# This module defines the following variables: +# +# GLFW3_LIBRARY the name of the library; +# GLFW3_INCLUDE_DIR where to find glfw include files. +# GLFW3_FOUND true if both the GLFW3_LIBRARY and GLFW3_INCLUDE_DIR have been found. +# +# To help locate the library and include file, you can define a +# variable called GLFW3_ROOT which points to the root of the glfw library +# installation. +# +# default search dirs +# +# Cmake file from: https://github.com/daw42/glslcookbook + +set( _glfw3_HEADER_SEARCH_DIRS +"/usr/include" +"/usr/local/include" +"C:/Program Files (x86)/glfw/include" ) +set( _glfw3_LIB_SEARCH_DIRS +"/usr/lib" +"/usr/local/lib" +"C:/Program Files (x86)/glfw/lib-msvc110" ) + +# Check environment for root search directory +set( _glfw3_ENV_ROOT $ENV{GLFW3_ROOT} ) +if( NOT GLFW3_ROOT AND _glfw3_ENV_ROOT ) + set(GLFW3_ROOT ${_glfw3_ENV_ROOT} ) +endif() + +# Put user specified location at beginning of search +if( GLFW3_ROOT ) + list( INSERT _glfw3_HEADER_SEARCH_DIRS 0 "${GLFW3_ROOT}/include" ) + list( INSERT _glfw3_LIB_SEARCH_DIRS 0 "${GLFW3_ROOT}/lib" ) +endif() + +# Search for the header +FIND_PATH(GLFW3_INCLUDE_DIR "GLFW/glfw3.h" +PATHS ${_glfw3_HEADER_SEARCH_DIRS} ) + +# Search for the library +FIND_LIBRARY(GLFW3_LIBRARY NAMES glfw3 glfw +PATHS ${_glfw3_LIB_SEARCH_DIRS} ) +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLFW3 DEFAULT_MSG +GLFW3_LIBRARY GLFW3_INCLUDE_DIR) diff --git a/cmake/modules/FindGLM.cmake b/cmake/modules/FindGLM.cmake new file mode 100644 index 0000000..430049e --- /dev/null +++ b/cmake/modules/FindGLM.cmake @@ -0,0 +1,56 @@ +# FindGLM - attempts to locate the glm matrix/vector library. +# +# This module defines the following variables (on success): +# GLM_INCLUDE_DIRS - where to find glm/glm.hpp +# GLM_FOUND - if the library was successfully located +# +# It is trying a few standard installation locations, but can be customized +# with the following variables: +# GLM_ROOT_DIR - root directory of a glm installation +# Headers are expected to be found in either: +# /glm/glm.hpp OR +# /include/glm/glm.hpp +# This variable can either be a cmake or environment +# variable. Note however that changing the value +# of the environment varible will NOT result in +# re-running the header search and therefore NOT +# adjust the variables set by this module. +#============================================================================= +# Copyright 2012 Carsten Neumann +# +# 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.) +# default search dirs + +SET(_glm_HEADER_SEARCH_DIRS +"/usr/include" +"/usr/local/include" +"C:/Program Files (x86)/glm" ) +# check environment variable +SET(_glm_ENV_ROOT_DIR "$ENV{GLM_ROOT_DIR}") +IF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR) + SET(GLM_ROOT_DIR "${_glm_ENV_ROOT_DIR}") +ENDIF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR) +# put user specified location at beginning of search +IF(GLM_ROOT_DIR) + SET(_glm_HEADER_SEARCH_DIRS "${GLM_ROOT_DIR}" + "${GLM_ROOT_DIR}/include" + ${_glm_HEADER_SEARCH_DIRS}) +ENDIF(GLM_ROOT_DIR) +# locate header +FIND_PATH(GLM_INCLUDE_DIR "glm/glm.hpp" +PATHS ${_glm_HEADER_SEARCH_DIRS}) +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLM DEFAULT_MSG +GLM_INCLUDE_DIR) +IF(GLM_FOUND) + SET(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") + MESSAGE(STATUS "GLM_INCLUDE_DIR = ${GLM_INCLUDE_DIR}") +ENDIF(GLM_FOUND) diff --git a/cmake/modules/FindSOIL.cmake b/cmake/modules/FindSOIL.cmake new file mode 100644 index 0000000..36c10e3 --- /dev/null +++ b/cmake/modules/FindSOIL.cmake @@ -0,0 +1,33 @@ +# - Locate SOIL library +# This module defines +# SOIL_LIBRARY, the name of the library to link against +# SOIL_FOUND +# SOIL_INCLUDE_DIR, where to find SOIL.h +# To Adding search path, set SOIL_ROOT_DIR as follows +# set(SOIL_ROOT_DIR "path/to/soil") +# or launch cmake with -DSOIL_ROOT_DIR="/path/to/SOIL_ROOT_DIR". +# +# author: Kazunori Kimura +# email : kazunori.abu@gmail.com +find_path(SOIL_INCLUDE_DIR_TMP SOIL.h + HINTS ${SOIL_ROOT_DIR} + PATH_SUFFIXES include/SOIL SOIL include +) +if(${SOIL_INCLUDE_DIR_TMP} STREQUAL "SOIL_INCLUDE_DIR_TMP-NOTFOUND") + set(SOIL_INCLUDE_DIR ${SOIL_INCLUDE_DIR_TMP}) +else() + string(REGEX REPLACE "(.*)/SOIL" "\\1" SOIL_INCLUDE_DIR ${SOIL_INCLUDE_DIR_TMP}) +endif() + +find_library(SOIL_LIBRARY + NAMES SOIL + HINTS ${SOIL_ROOT_DIR} + PATH_SUFFIXES lib +) + +unset(INCLUDE_SEARCH_PATH) +unset(LIB_SEARCH_PATH) +unset(SOIL_INCLUDE_DIR_TMP) +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SOIL +REQUIRED_VARS SOIL_LIBRARY SOIL_INCLUDE_DIR)