A CMake addon that avoids you writing boilerplate code for resource management.

Overview

SHader INJ(I)ector

SHINJI (originally SHader INJector) is a CMake addon that avoids you writing boilerplate code for resource management and exposes simple and easy to use functions.

It's mainly designed for OpenGL or Vulkan applications as most of its functions work with GLSL shaders. Its objective is to hide the verbosity of CMake behind a set of useful functions that handle output files creation and dependency management for validation, compilation and integration within the application.

Briefly it can:

  • Validate GLSL code (using glslangValidator)
  • Compile GLSL code to SPIR-V (using glslc)
  • Embed resources in the application binary (internally using CMRC's code)

Requirements:

  • CMake 3.19
  • C++17
  • Vulkan SDK (required only if using shader-related functions)

Usage

Using SHINJI is pretty straight-forward as you can dynamically download and depend on it in configuration time:

include(FetchContent)
message(STATUS "Fetching shinji...")
FetchContent_Declare(
    shinji
    GIT_REPOSITORY "https://github.com/loryruta/shinji"
)
FetchContent_MakeAvailable(shinji)
include("${shinji_SOURCE_DIR}/shinji.cmake")

You may now want to use the following functions:

OPTIONS ) # shinji_compile_glsl_to_spirv(shinji_test "shaders/my_shader.vert" ".spv/my_shader.vert.spv") shinji_embed( [ ...]) # shinji_embed(shinji_test "shaders/my_shader.vert" "shaders/my_shader.frag") # IMPORTANT: # THIS LINE MUST BE PRESENT AFTER *ALL* shinji_* CALLS! shinji_finalize( ) # shinji_finalize( ) ">
shinji_validate_glsl(<TARGET>  
           OPTIONS 
           
            )

            # shinji_validate_glsl(shinji_test "shaders/my_shader.vert")

shinji_compile_glsl_to_spirv(<
            TARGET> 
             
              
              OPTIONS 
              
               )

               # shinji_compile_glsl_to_spirv(shinji_test "shaders/my_shader.vert" ".spv/my_shader.vert.spv")

shinji_embed(<
               TARGET> 
               
                 [
                
                  ...]) 
                 # shinji_embed(shinji_test "shaders/my_shader.vert" "shaders/my_shader.frag") 
                 # IMPORTANT: 
                 # THIS LINE MUST BE PRESENT AFTER *ALL* shinji_* CALLS! shinji_finalize(<
                 TARGET>) 
                 # shinji_finalize(
                  
                   )
                  
                
               
              
             
            
           
          

GLSL shader validation and compilation, and resource integration will take place in build time.

In order to access the resources (embedded or not):

buf; shinji::load_resource_from_file("shaders/my_shader.vert", buf); // (...) } ">
#include <shinji.hpp>

void something()
{
    // Bundled resource:
    auto [buf, buf_len] = shinji::load_resource_from_bundle("shaders/my_shader.vert");
    // (...)
    
    // Physical file resource:
    std::vector<char> buf;
    shinji::load_resource_from_file("shaders/my_shader.vert", buf);
    // (...)
}
Owner
Lorenzo Rutayisire
Computer engineering student
Lorenzo Rutayisire
CMake module to enable code coverage easily and generate coverage reports with CMake targets.

CMake-codecov CMake module to enable code coverage easily and generate coverage reports with CMake targets. Include into your project To use Findcodec

HPC 77 Jul 3, 2022
Non-intrusive CMake dependency management

cmodule Non-intrusive CMake dependency management. Normally CMake's find_package() looks for packages installed on host system (and compiled for host

scapix.com 13 Jun 16, 2022
CMake checks cache helper modules – for fast CI CMake builds!

cmake-checks-cache Cross platform CMake projects do platform introspection by the means of "Check" macros. Have a look at CMake's How To Write Platfor

Cristian Adam 59 Jul 7, 2022
CMake scripts for painless usage of SuiteSparse+METIS from Visual Studio and the rest of Windows/Linux/OSX IDEs supported by CMake

CMake scripts for painless usage of Tim Davis' SuiteSparse (CHOLMOD,UMFPACK,AMD,LDL,SPQR,...) and METIS from Visual Studio and the rest of Windows/Lin

Jose Luis Blanco-Claraco 385 Aug 2, 2022
cmake-font-lock - Advanced, type aware, highlight support for CMake

cmake-font-lock - Advanced, type aware, highlight support for CMake

Anders Lindgren 37 Dec 30, 2021
cmake-avr - a cmake toolchain for AVR projects

cmake-avr - a cmake toolchain for AVR projects Testing the example provided The toolchain was created and tested within the following environment: Lin

Matthias Kleemann 156 Jun 20, 2022
Make CMake less painful when trying to write Modern Flexible CMake

Izzy's eXtension Modules IXM is a CMake library for writing Modern flexible CMake. This means: Reducing the amount of CMake written Selecting reasonab

IXM 105 Jul 18, 2022
unmaintained - CMake module to activate certain C++ standard, feature checks and appropriate automated workarounds - basically an improved version of cmake-compile-features

Compatibility This library provides an advanced target_compile_features() and write_compiler_detection_header(). The problem with those is that they a

Jonathan Müller 72 Apr 14, 2022
[CMake] [BSD-2] CMake module to find ICU

FindICU.cmake A CMake module to find International Components for Unicode (ICU) Library Note that CMake, since its version 3.7.0, includes a FindICU m

julp 29 Apr 26, 2022
CMake integration for include-what-you-use

Include-What-You-Use CMake Targets CMake macro to add per-source level checks on individual targets for include-what-you-use violations Status Travis

ポリ平方 POLYSQUARE 8 Apr 10, 2021
A set of cmake modules to assist in building code

CMake 3 Tools Warning: These tools are being replaced by the Modern CMake. Some of the tools are still being maintained for now, but new projects shou

null 188 Aug 9, 2022
Source code formatter for cmake listfiles.

cmake lang The cmakelang project provides Quality Assurance (QA) tools for cmake: cmake-annotate can generate pretty HTML from your listfiles cmake-fo

null 691 Aug 8, 2022
nabs is a single-header library for writing build recipes in C++

nabs is a single-header library for writing build recipes in C++. It is directly inspired by nobuild, but with more feature (bloat) and built-in support for makefile-like dependency resolution.

zhiayang 6 May 8, 2021
CMake project for BL602 RISC-V processor

bl602_cmake_base CMake project for BL602 RISC-V processor How to build NOTE : This project uses a pre-compiled version of the Buffalo SDK (bl_iot_sdk)

null 9 Jan 6, 2022
A CMake toolchain file for iOS, macOS, watchOS & tvOS C/C++/Obj-C++ development

A CMake toolchain file for iOS, macOS, watchOS & tvOS C/C++/Obj-C++ development

Alexander Widerberg 1.3k Aug 13, 2022
curl cmake module libcurl build with msvc x86

curl-msvc Infomation curl cmake module libcurl build with MSVC10.0 arch (x86 | i386) source from https://github.com/curl/curl tags: curl-7_79_1 Usage

Jason Payne 0 May 16, 2022
NeoWorld is a resampler using the CMake build system

NeoWorld is a resampler using the CMake build system. It's designed for utsu, OpenUTAU, and UTAU.

null 4 Jun 24, 2022
A CMake starter template using CPM

Cmake Starter About A lightweight Cmake project meant for a binary application (not a shared library), tests with catch2 are configured, CPM is the pa

Matt Williams 1 Jul 14, 2022
Simple library for embedding static resources into C++ binaries using CMake

libromfs libromfs is an easy way to bundle resources directly into any C++ application and access them through a simple interface. The main advantage

WerWolv 27 Aug 11, 2022