nvpro_core icon indicating copy to clipboard operation
nvpro_core copied to clipboard

FindVulkanSDK not finding glslangValidator/glslc on Linux

Open timo-oster opened this issue 2 years ago • 2 comments

I just tried to compile vk_mini_path_tracer on my Linux machine and ran into an issue with FindVulkanSDK. I specified the location of my VulkanSDK via the VULKAN_SDK environment variable, and it was able to find the vulkan headers, library, shaderc library, but not the glslc and glslangValidator executables. I believe this is due to an incorrect use of the find_file command in line 134/135:

    find_file(GLSLANGVALIDATOR VULKANSDK_ROOT_DIR "glslangValidator" HINTS ${VULKANSDK_ROOT_DIR}"../bin/glslangValidator")
    find_file(GLSLC VULKANSDK_ROOT_DIR "glslc" HINTS ${VULKANSDK_ROOT_DIR}"../bin/glslc")

this does not comply with the documentation of how the find_file command works (you are supposed to pass the target variable first and the file name to search for second), and it also seems to use the VULKANSDK_ROOT_DIR variable in an incorrect way. For me, it is set to the dir above the bin/, lib/, etc. and it does not have a slash at the end. Appending ../bin/glslc to that makes no sense in multiple ways. I managed to get it working by changing the two lines to this, although I'm not sure that we can rely on VULKANSDK_ROOT_DIR not ending with a slash in all situations:

    find_file(GLSLANGVALIDATOR "glslangValidator" HINTS "${VULKANSDK_ROOT_DIR}/bin")
    find_file(GLSLC "glslc" HINTS "${VULKANSDK_ROOT_DIR}/bin")

timo-oster avatar Jun 29 '23 11:06 timo-oster

Hi @timo-oster ! We wound up replacing our FindVulkanSDK.cmake script with CMake's built-in find_package(Vulkan) module in https://github.com/nvpro-samples/nvpro_core/commit/9cf7b4814bd2046d0048c5ed56176ae51c3f5cb5 . Could you clear your CMake cache and try running it again, and let me know if it fixes this issue for you? Thank you!

NBickford-NV avatar Aug 02 '23 17:08 NBickford-NV

Unfortunately the same problem seems to persist. I add the x86_64/ dir of the Vulkan SDK (the one that contains lib/, bin/, include/ etc.) to CMAKE_PREFIX_PATH and it finds the include dir and library, but I get the error:

CMake Warning at /u/nn2nwa/sources/nvpro_samples/nvpro_core/cmake/setup.cmake:987 (MESSAGE):
  could not find Vulkan_GLSLANG_VALIDATOR_EXECUTABLE to compile shaders
Call Stack (most recent call first):
  /u/nn2nwa/sources/nvpro_samples/nvpro_core/cmake/setup.cmake:1001 (_compile_GLSL_flags)
  checkpoints/e11_rt_pipeline_3/CMakeLists.txt:31 (_compile_GLSL)

Both the glslc and glslangValidator executables are there in the bin/ directory though.

timo-oster avatar Aug 10 '23 06:08 timo-oster

I just tried again, and this time it worked. Not sure if the problem was on my end or yours, but it seems to have been resolved.

timo-oster avatar Apr 18 '24 06:04 timo-oster

Thank you Timo!

NBickford-NV avatar Apr 19 '24 20:04 NBickford-NV