SkeletonMinRes allows you to easily embed resources into your C++ project using CMake. Resources can be any file; ranging from textures, GLSL sources, LUA scripts, etc.
The main requirement for usage is CMake.
First clone the repo down. Here I like to use submodules with a thirdparty/<library_name>/repo
type structure to keep things consistent.
git submodule add https://github.com/WiggleWizard/SkeletonMinRes.git thirdparty/SkeletonMinRes/repo
Then add the repo to your CMake file:
add_submodule(thirdparty/SkeletonMinRes/repo)
Now you can add your resources, by calling the provided embed_resources()
function in your CMakeLists.txt file:
embed_resources(PROJECT_RESOURCES
shaders/vertex.glsl
shaders/frag.glsl
scripts/main.lua
config/engine.ini)
Then to add sources and allow the loader to be accessed:
add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${PROJECT_RESOURCES})
include_directories(${INCLUDE_DIRS} ${PROJECT_RESOURCES_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} SkeletonMinRes)
#include <iostream>
using namespace std;
#include <SkeletonMinRes/Loader.h>
int main()
{
SkeletonMinRes::Resource text = LOAD_RESOURCE(config_engine_ini);
cout << text.toString() << endl;
return EXIT_SUCCESS;
}
Base taken from CodeFinder2/embed-resource.