Fetch stb header libraries with CMake's FetchContent
This commit is contained in:
parent
ec1d6aebe7
commit
96ac056a5d
|
@ -1,28 +0,0 @@
|
|||
# Find SOIL2
|
||||
# Find the SOIL2 includes and library
|
||||
#
|
||||
# SOIL2_INCLUDE_DIRS - where to find SOIL2.h, etc.
|
||||
# SOIL2_LIBRARIES - List of libraries when using SOIL2.
|
||||
# SOIL2_FOUND - True if SOIL2 found.
|
||||
#
|
||||
# Based on the FindZLIB.cmake module.
|
||||
|
||||
IF (SOIL2_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
SET(SOIL2_FIND_QUIETLY TRUE)
|
||||
ENDIF (SOIL2_INCLUDE_DIR)
|
||||
|
||||
FIND_PATH(SOIL2_INCLUDE_DIR SOIL2.h PATH_SUFFIXES include/SOIL2 include)
|
||||
|
||||
SET(SOIL2_NAMES SOIL2 SOIL2 soil2)
|
||||
FIND_LIBRARY(SOIL2_LIBRARY NAMES ${SOIL2_NAMES} )
|
||||
MARK_AS_ADVANCED( SOIL2_LIBRARY SOIL2_INCLUDE_DIR )
|
||||
|
||||
# Per-recommendation
|
||||
SET(SOIL2_INCLUDE_DIRS "${SOIL2_INCLUDE_DIR}")
|
||||
SET(SOIL2_LIBRARIES "${SOIL2_LIBRARY}")
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set SOIL2_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(soil2 DEFAULT_MSG SOIL2_LIBRARIES SOIL2_INCLUDE_DIRS)
|
|
@ -0,0 +1,10 @@
|
|||
# Get the stb header libraries.
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
stb
|
||||
GIT_REPOSITORY https://github.com/nothings/stb.git
|
||||
GIT_TAG 8b5f1f37b5b75829fc72d38e7b5d4bcbf8a26d55
|
||||
)
|
||||
FetchContent_MakeAvailable(stb)
|
||||
message("Downloaded stb library to: ${stb_SOURCE_DIR}")
|
||||
set(STB_INCLUDE_DIR ${stb_SOURCE_DIR})
|
|
@ -3,7 +3,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}")
|
|||
project(SimpleEngine)
|
||||
|
||||
include(cmrc/CMakeRC.cmake)
|
||||
#include(CMake/Findsoil2.cmake)
|
||||
include (CMake/GetStbLibraries.cmake)
|
||||
|
||||
# Add some CMake options:
|
||||
option(SIMPLE_ENGINE_BUILD_EXAMPLES "Build example projects" ON)
|
||||
|
@ -19,29 +19,17 @@ endif()
|
|||
find_package(GLEW REQUIRED)
|
||||
find_package(glfw3 CONFIG REQUIRED)
|
||||
find_package(glm CONFIG REQUIRED)
|
||||
|
||||
#if (WIN32)
|
||||
# find_package(soil2 CONFIG REQUIRED)
|
||||
#else()
|
||||
# find_package(soil2 REQUIRED)
|
||||
#endif()
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
# Get the stb header libraries.
|
||||
#include(FetchContent)
|
||||
#FetchContent_Declare(
|
||||
# stbImage
|
||||
# URL https://raw.githubusercontent.com/nothings/stb/5ba0baaa269b3fd681828e0e3b3ac0f1472eaf40/stb_image.h
|
||||
# DOWNLOAD_NO_EXTRACT
|
||||
#)
|
||||
#FetchContent_MakeAvailable(stbImage)
|
||||
|
||||
#include(ExternalProject)
|
||||
#ExternalProject_Add(stbImage
|
||||
# URL https://raw.githubusercontent.com/nothings/stb/5ba0baaa269b3fd681828e0e3b3ac0f1472eaf40/stb_image.h
|
||||
# URL_HASH MD5=d41d8cd98f00b204e9800998ecf8427e
|
||||
# DOWNLOAD_NO_EXTRACT ON
|
||||
# stb
|
||||
# GIT_REPOSITORY https://github.com/nothings/stb.git
|
||||
# GIT_TAG 8b5f1f37b5b75829fc72d38e7b5d4bcbf8a26d55
|
||||
#)
|
||||
#FetchContent_MakeAvailable(stb)
|
||||
#message("Downloaded stb library to: ${stb_SOURCE_DIR}")
|
||||
|
||||
# Link sources
|
||||
file(GLOB_RECURSE source_list src/*.cpp)
|
||||
|
@ -64,9 +52,9 @@ cmrc_add_resource_library(
|
|||
target_link_libraries(simpleengine PUBLIC GLEW::GLEW)
|
||||
target_link_libraries(simpleengine PUBLIC glfw)
|
||||
target_link_libraries(simpleengine PUBLIC ${GLM_LIBRARIES})
|
||||
#target_link_libraries(simpleengine PUBLIC soil2)
|
||||
target_link_libraries(simpleengine PUBLIC ${OPENGL_LIBRARIES})
|
||||
target_link_libraries(simpleengine PRIVATE simpleengine_resources)
|
||||
target_include_directories(simpleengine PUBLIC ${STB_INCLUDE_DIR})
|
||||
|
||||
# Include some dependencies' include directories
|
||||
include_directories(${OPENGL_INCLUDE_DIR})
|
||||
|
|
2
cmrc
2
cmrc
|
@ -1 +1 @@
|
|||
Subproject commit a64bea50c05594c8e7cf1f08e441bb9507742e2e
|
||||
Subproject commit e386a629eb537d384811e598a3c96b9ca928f65e
|
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,7 @@
|
|||
#include "gfx/texture.h"
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
#include <stb_image.h>
|
||||
|
||||
namespace simpleengine::gfx {
|
||||
Texture::Texture(const char* path, bool img_2d, bool mipmap) {
|
||||
|
@ -30,7 +30,7 @@ namespace simpleengine::gfx {
|
|||
glGenerateMipmap(image_type);
|
||||
}
|
||||
|
||||
glBindTexture(image_type, 0);
|
||||
unbind();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,7 +67,7 @@ namespace simpleengine::gfx {
|
|||
glGenerateMipmap(image_type);
|
||||
}
|
||||
|
||||
glBindTexture(image_type, 0);
|
||||
unbind();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue