widberg / bgfx.cmake

https://github.com/bkaradzic/bgfx.cmake. Independently maintained CMake build scripts for bgfx. Released under public domain.
https://github.com/bkaradzic/bgfx.cmake
Creative Commons Zero v1.0 Universal
286 stars 254 forks source link

shaderc_parse usage #44

Closed NukeBird closed 5 years ago

NukeBird commented 5 years ago

Good day! First of all, I want to say thank you. I really do enjoy cmake-based bgfx ^^

Okay, now lets go ahead to the question...

I have an project which uses bgfx.cmake:

cmake_minimum_required(VERSION 3.7)
project(SomeProject)

set(CMAKE_CXX_STANDARD 14)

file(GLOB JULIVI_SOURCE_FILES
    "src/*.h"
    "src/*.cpp"
)

add_subdirectory("deps/bgfx") 
add_executable(${PROJECT_NAME} ${JULIVI_SOURCE_FILES})
target_compile_definitions(${PROJECT_NAME} PRIVATE ENTRY_CONFIG_IMPLEMENT_MAIN=1 _CRT_SECURE_NO_WARNINGS=1)

target_link_libraries(${PROJECT_NAME} bgfx example-common)

bgfx.cmake located in deps/bgfx

my question is: how to compile every shader from directory X and put binaries into directory Y? Preferably before every build, because the number of shaders can vary

P.S. I tired something like shaderc_parse("shaders/vs_test.sc" "asset/vs_test.bin" VERTEX WINDOWS), but it feels like nothing is happening (no cmake errors here)

JoshuaBrookover commented 5 years ago

shaderc_parse is a utility function that allows you to construct a CLI command for shaderc, it doesn't actually create the custom command. For that you want to use shaderc() which takes all the same arguments.

Also the way that CMake arguments work, you need to specify the argument name (FILE, OUTPUT): shaderc(FILE "shaders/vs_test.sc" OUTPUT "asset/vs_test.bin" VERTEX WINDOWS)

Let me know if you need more help. It's been a little while since I've used this bit of the code.

NukeBird commented 5 years ago

@JoshuaBrookover yes, thank you my friend! Now I clearly understand how these things work :з