From 302414b7a485cc6cbcfbd5e857849e432f8abf3e Mon Sep 17 00:00:00 2001 From: Meoweg Date: Mon, 16 Nov 2015 15:55:16 +0000 Subject: [PATCH] Add STB library as submodule "vendor/stb" --- .gitmodules | 3 ++ CMakeLists.txt | 5 ++- cmake/Modules/FindSTB.cmake | 64 +++++++++++++++++++++++++++++++++++++ configure | 4 ++- vendor/stb | 1 + 5 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 cmake/Modules/FindSTB.cmake create mode 160000 vendor/stb diff --git a/.gitmodules b/.gitmodules index 59e90e0..46c64fb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,3 +5,6 @@ [submodule "vendor/glm"] path = vendor/glm url = https://github.com/g-truc/glm.git +[submodule "vendor/stb"] + path = vendor/stb + url = https://github.com/nothings/stb.git diff --git a/CMakeLists.txt b/CMakeLists.txt index de519a9..0a75084 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "build") project (Matabstrix) add_definitions ("-std=c++14 -Wall -Wextra") -set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "--embed-file data -s STB_IMAGE=1 -s TOTAL_MEMORY=67108864") +set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "--embed-file data -s TOTAL_MEMORY=67108864") file (GLOB_RECURSE sources "src/**.cpp" "examples/**.cpp") @@ -16,3 +16,6 @@ set_target_properties (matabstrix PROPERTIES OUTPUT_NAME "index") find_package (GLM REQUIRED) include_directories (${GLM_INCLUDE_DIRS}) + +find_package (STB REQUIRED) +include_directories (${STB_INCLUDE_DIRS}) diff --git a/cmake/Modules/FindSTB.cmake b/cmake/Modules/FindSTB.cmake new file mode 100644 index 0000000..d41122a --- /dev/null +++ b/cmake/Modules/FindSTB.cmake @@ -0,0 +1,64 @@ +# FindSTB - attempts to locate the stb single-file public domain +# libraries for C/C++ +# +# This module defines the following variables (on success): +# STB_INCLUDE_DIRS - where to find stb_image.h +# STB_FOUND - if the library was successfully located +# +# It is trying a few standard installation locations, but can be customized +# with the following variables: +# STB_ROOT_DIR - root directory of a stb installation +# Headers are expected to be found in either: +# /stb_image.h OR +# /include/stb_image.h +# 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(_stb_HEADER_SEARCH_DIRS + "/usr/include" + "/usr/local/include") + +# check environment variable +SET(_stb_ENV_ROOT_DIR "$ENV{STB_ROOT_DIR}") + +IF(NOT STB_ROOT_DIR AND _stb_ENV_ROOT_DIR) + SET(STB_ROOT_DIR "${_stb_ENV_ROOT_DIR}") +ENDIF(NOT STB_ROOT_DIR AND _stb_ENV_ROOT_DIR) + +# put user specified location at beginning of search +IF(STB_ROOT_DIR) + SET(_stb_HEADER_SEARCH_DIRS "${STB_ROOT_DIR}" + "${STB_ROOT_DIR}/include" + ${_stb_HEADER_SEARCH_DIRS}) +ENDIF(STB_ROOT_DIR) + +# locate header +FIND_PATH(STB_INCLUDE_DIR "stb_image.h" + PATHS ${_stb_HEADER_SEARCH_DIRS}) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(STB DEFAULT_MSG + STB_INCLUDE_DIR) + +IF(STB_FOUND) + SET(STB_INCLUDE_DIRS "${STB_INCLUDE_DIR}") + + MESSAGE(STATUS "STB_INCLUDE_DIR = ${STB_INCLUDE_DIR}") +ENDIF(STB_FOUND) diff --git a/configure b/configure index f6cc1c1..a60d4c2 100755 --- a/configure +++ b/configure @@ -3,7 +3,9 @@ VENDOR="vendor" GLM="$VENDOR/glm" +STB="$VENDOR/stb" cmake \ -DCMAKE_TOOLCHAIN_FILE="$EMSCRIPTEN/cmake/Modules/Platform/Emscripten.cmake" \ --DGLM_INCLUDE_DIR="$GLM" +-DGLM_INCLUDE_DIR="$GLM" \ +-DSTB_INCLUDE_DIR="$STB" diff --git a/vendor/stb b/vendor/stb new file mode 160000 index 0000000..5809508 --- /dev/null +++ b/vendor/stb @@ -0,0 +1 @@ +Subproject commit 5809508de3329c992d4d8dea03a8be7e1a0d0f35