Skip to content

Potential variable scope bug in add_slang_shader_target CMake function #294

@moubread233

Description

@moubread233

Hello, I'm a Vulkan learner studying the project's build system by reading the CMakeLists.txt to understand how a small Vulkan project is organized. I've identified a potential inconsistency in the add_slang_shader_target function related to variable scope.

In the add_chapter function, a variable CHAPTER_SHADER is defined. However, inside the called add_slang_shader_target function, the code references ${CHAPTER_SHADER} on the following line:

file(GLOB HAS_COMPUTE ${CHAPTER_SHADER}.comp)

Since add_slang_shader_target is a CMake function (which creates a new scope), and it does not receive CHAPTER_SHADER as an argument, this variable is likely undefined in that context. This would cause the file(GLOB ...) command to search for a file literally named .comp instead of the intended <chapter_name>.comp.

Consequently, the conditional check if(HAS_COMPUTE) would likely not work as intended, preventing the -entry compMain argument from being added to the Slang compiler command for chapters that use compute shaders.

This might be a latent issue if the current tutorial chapters do not utilize Slang compute shaders.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions