Commit 4a6e38a4 authored by Sadman Kazi's avatar Sadman Kazi 🎸

Add GLEW to cmake and add build instructions

parent 3c128632
......@@ -194,3 +194,6 @@ FakesAssemblies/
# Visual Studio 6 workspace options file
*.opt
# vim/vi temp files
*.swp
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project (GameEngine)
# add compiler flags
......@@ -30,7 +30,7 @@ SET(GameEngine_CMAKE_DIR "${GameEngine_SOURCE_DIR}/cmake")
find_package(OpenGL REQUIRED)
# GLEW
#INCLUDE(${GameEngine_CMAKE_DIR}/FindGLEW.cmake)
INCLUDE(${GameEngine_CMAKE_DIR}/FindGLEW.cmake)
# SDL2
INCLUDE(${GameEngine_CMAKE_DIR}/FindSDL2.cmake)
......@@ -38,12 +38,15 @@ INCLUDE(${GameEngine_CMAKE_DIR}/FindSDL2.cmake)
# ASSIMP
INCLUDE(${GameEngine_CMAKE_DIR}/FindASSIMP.cmake)
# GLM
INCLUDE(${GameEngine_CMAKE_DIR}/FindGLM.cmake)
# Define the include DIRs
include_directories(
${GameEngine_SOURCE_DIR}/headers
${GameEngine_SOURCE_DIR}/sources
${OPENGL_INCLUDE_DIRS}
#${GLEW_INCLUDE_DIRS}
${GLEW_INCLUDE_DIRS}
${SDL2_INCLUDE_DIRS}
${ASSIMP_INCLUDE_DIRS}
)
......@@ -51,7 +54,7 @@ include_directories(
# Define the link libraries
target_link_libraries( GameEngine
${OPENGL_LIBRARIES}
#${GLEW_LIBRARIES}
${GLEW_LIBRARIES}
${SDL2_LIBRARIES}
${ASSIMP_LIBRARIES}
)
......@@ -2,7 +2,26 @@
A test game engine with C++ and OpenGL.
### Documentation:
Refer to the [wiki](https://github.com/sadmansk/GameEngine/wiki) for more information. Also if you are interested in contributing, follow these [guidelines](https://github.com/sadmansk/GameEngine/wiki/Contributing-to-the-Wiki).
Refer to the [wiki](https://github.com/sadmansk/GameEngine/wiki) for more information.
Also if you are interested in contributing, follow these [guidelines](https://github.com/sadmansk/GameEngine/wiki/Contributing-to-the-Wiki).
### Quick Start
You need the following libraries:
* `cmake`
* `SDL2`
* `GLEW`
* `ASSIMP`
* `GLM`
CMake recommends out of directory builds, so it's a smart idea to make a new directory
(I'm calling it `build`) and run the following command from there:
```
cmake ..
make
```
> Note: These instructions are for Mac and Linux, Windows/Visual Studio details
coming soon.
### License:
```
......@@ -19,4 +38,5 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
```
See [LICENSE](https://raw.githubusercontent.com/sadmansk/GameEngine/master/LICENSE) for more details.
See [LICENSE](https://raw.githubusercontent.com/sadmansk/GameEngine/master/LICENSE)
for more details.
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#.rst:
# FindGLEW
# --------
#
# Find the OpenGL Extension Wrangler Library (GLEW)
#
# IMPORTED Targets
# ^^^^^^^^^^^^^^^^
#
# This module defines the :prop_tgt:`IMPORTED` target ``GLEW::GLEW``,
# if GLEW has been found.
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module defines the following variables:
# Try to find GLEW library and include path.
# Once done this will define
#
# ::
# GLEW_FOUND
# GLEW_INCLUDE_DIR
# GLEW_LIBRARY
# GLEW_SOURCE
#
# 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
find_path(GLEW_INCLUDE_DIR GL/glew.h)
if(NOT GLEW_LIBRARY)
find_library(GLEW_LIBRARY_RELEASE NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64)
find_library(GLEW_LIBRARY_DEBUG NAMES GLEWd glew32d glewd PATH_SUFFIXES lib64)
include(FindPackageHandleStandardArgs)
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
select_library_configurations(GLEW)
if (WIN32)
find_path( GLEW_INCLUDE_DIR
NAMES
GL/glew.h
PATHS
${GLEW_LOCATION}/include
$ENV{GLEW_LOCATION}/include
$ENV{PROGRAMFILES}/GLEW/include
${PROJECT_SOURCE_DIR}/extern/glew/include
${GLEW_LOCATION}
$ENV{GLEW_LOCATION}
DOC "The directory where GL/glew.h resides" )
find_file( GLEW_SOURCE
NAMES
glew.c
PATHS
${GLEW_LOCATION}/src
$ENV{GLEW_LOCATION}/src
$ENV{PROGRAMFILES}/GLEW/src
${PROJECT_SOURCE_DIR}/extern/glew/src
${GLEW_LOCATION}
$ENV{GLEW_LOCATION}
DOC "The directory where GL/glew.c resides" )
if(ARCH STREQUAL "x86")
find_library( GLEW_LIBRARY
NAMES
glew GLEW glew32s glew32
PATHS
${GLEW_LOCATION}/lib
${GLEW_LOCATION}/lib/x86
${GLEW_LOCATION}/lib/win32
${GLEW_LOCATION}/lib/Release/win32
${GLEW_LOCATION}/lib/Release MX/win32
$ENV{GLEW_LOCATION}/lib
$ENV{GLEW_LOCATION}/lib/Release/win32
$ENV{GLEW_LOCATION}/lib/Release MX/win32
$ENV{GLEW_LOCATION}/lib/x86
$ENV{GLEW_LOCATION}/lib/win32
$ENV{PROGRAMFILES}/GLEW/lib
$ENV{PROGRAMFILES}/GLEW/lib/x86
$ENV{PROGRAMFILES}/GLEW/lib/win32
${PROJECT_SOURCE_DIR}/extern/glew/bin
${PROJECT_SOURCE_DIR}/extern/glew/lib
${PROJECT_SOURCE_DIR}/extern/glew/lib/x86
${PROJECT_SOURCE_DIR}/extern/glew/lib/win32
${GLEW_LOCATION}
$ENV{GLEW_LOCATION}
DOC "The GLEW library")
else()
find_library( GLEW_LIBRARY
NAMES
glew GLEW glew32s glew32
PATHS
${GLEW_LOCATION}/lib/x64
${GLEW_LOCATION}/lib/Release/x64
${GLEW_LOCATION}/lib/Release MX/x64
$ENV{GLEW_LOCATION}/lib/x64
$ENV{GLEW_LOCATION}/lib/Release/x64
$ENV{GLEW_LOCATION}/lib/Release MX/x64
$ENV{PROGRAMFILES}/GLEW/lib/x64
${PROJECT_SOURCE_DIR}/extern/glew/bin
${PROJECT_SOURCE_DIR}/extern/glew/lib/x64
${GLEW_LOCATION}/lib
$ENV{GLEW_LOCATION}/lib
$ENV{PROGRAMFILES}/GLEW/lib
${PROJECT_SOURCE_DIR}/extern/glew/lib
${GLEW_LOCATION}
$ENV{GLEW_LOCATION}
DOC "The GLEW library")
endif()
endif ()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(GLEW
REQUIRED_VARS GLEW_INCLUDE_DIR GLEW_LIBRARY)
if(GLEW_FOUND)
set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR})
if (${CMAKE_HOST_UNIX})
find_path( GLEW_INCLUDE_DIR
NAMES
GL/glew.h
PATHS
${GLEW_LOCATION}/include
$ENV{GLEW_LOCATION}/include
/usr/include
/usr/local/include
/sw/include
/opt/local/include
NO_DEFAULT_PATH
DOC "The directory where GL/glew.h resides"
)
find_library( GLEW_LIBRARY
NAMES
GLEW glew
PATHS
${GLEW_LOCATION}/lib
$ENV{GLEW_LOCATION}/lib
/usr/lib64
/usr/lib
/usr/local/lib64
/usr/local/lib
/sw/lib
/opt/local/lib
NO_DEFAULT_PATH
DOC "The GLEW library")
endif ()
if(NOT GLEW_LIBRARIES)
set(GLEW_LIBRARIES ${GLEW_LIBRARY})
endif()
if (GLEW_INCLUDE_DIR AND EXISTS "${GLEW_INCLUDE_DIR}/GL/glew.h")
if (NOT TARGET GLEW::GLEW)
add_library(GLEW::GLEW UNKNOWN IMPORTED)
set_target_properties(GLEW::GLEW PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}")
file(STRINGS "${GLEW_INCLUDE_DIR}/GL/glew.h" GLEW_4_2 REGEX "^#define GL_VERSION_4_2.*$")
if (GLEW_4_2)
SET(OPENGL_4_2_FOUND TRUE)
else ()
message(WARNING
"glew-1.7.0 or newer needed for supporting OpenGL 4.2 dependent features"
)
endif ()
if(GLEW_LIBRARY_RELEASE)
set_property(TARGET GLEW::GLEW APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(GLEW::GLEW PROPERTIES IMPORTED_LOCATION_RELEASE "${GLEW_LIBRARY_RELEASE}")
endif()
file(STRINGS "${GLEW_INCLUDE_DIR}/GL/glew.h" GLEW_4_3 REGEX "^#define GL_VERSION_4_3.*$")
if (GLEW_4_3)
SET(OPENGL_4_3_FOUND TRUE)
else ()
message(WARNING
"glew-1.9.0 or newer needed for supporting OpenGL 4.3 dependent features"
)
endif ()
if(GLEW_LIBRARY_DEBUG)
set_property(TARGET GLEW::GLEW APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(GLEW::GLEW PROPERTIES IMPORTED_LOCATION_DEBUG "${GLEW_LIBRARY_DEBUG}")
endif()
endif ()
if(NOT GLEW_LIBRARY_RELEASE AND NOT GLEW_LIBRARY_DEBUG)
set_property(TARGET GLEW::GLEW APPEND PROPERTY IMPORTED_LOCATION "${GLEW_LIBRARY}")
endif()
endif()
if(GLEW_SOURCE)
find_package_handle_standard_args(GLEW DEFAULT_MSG
GLEW_INCLUDE_DIR
GLEW_SOURCE
)
else()
find_package_handle_standard_args(GLEW DEFAULT_MSG
GLEW_INCLUDE_DIR
GLEW_LIBRARY
)
endif()
mark_as_advanced(GLEW_INCLUDE_DIR)
mark_as_advanced( GLEW_FOUND )
# 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_ROOT_DIR>/glm/glm.hpp OR
# <GLM_ROOT_DIR>/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")
# 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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment