Skip to content

Commit

Permalink
update modern glslang (#5910)
Browse files Browse the repository at this point in the history
* update modern glslang

* fix build with cpp14
  • Loading branch information
nihui authored Feb 19, 2025
1 parent 9afeb17 commit f5269b6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "glslang"]
path = glslang
url = https://github.com/KhronosGroup/glslang
url = https://github.com/nihui/glslang
[submodule "python/pybind11"]
path = python/pybind11
url = https://github.com/pybind/pybind11.git
18 changes: 7 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,8 @@ endif()
if(NCNN_VULKAN)
if(NCNN_SYSTEM_GLSLANG)
find_package(Threads)
find_package(SPIRV-Tools QUIET)
find_package(SPIRV-Tools-opt QUIET)
find_package(glslang QUIET)
if(glslang_FOUND)
add_library(glslang ALIAS glslang::glslang)
Expand All @@ -777,7 +779,7 @@ if(NCNN_VULKAN)
endif()
endif()

if (TARGET glslang AND TARGET SPIRV)
if(TARGET glslang AND TARGET SPIRV)
get_property(glslang_location TARGET glslang PROPERTY LOCATION)
get_property(SPIRV_location TARGET SPIRV PROPERTY LOCATION)
message(STATUS "Found glslang: ${glslang_location} (found version \"${glslang_VERSION}\")")
Expand All @@ -803,23 +805,17 @@ if(NCNN_VULKAN)
option(ENABLE_EXCEPTIONS "" OFF)
option(ENABLE_OPT "" OFF)
option(ENABLE_PCH "" OFF)
option(ENABLE_CTEST "" OFF)
if(NCNN_SHARED_LIB)
option(SKIP_GLSLANG_INSTALL "" ON)
endif()
option(GLSLANG_TESTS "" OFF)
option(GLSLANG_ENABLE_INSTALL "" ON)
add_subdirectory(glslang)
if(NCNN_SHARED_LIB)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC"))
target_compile_options(glslang PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
target_compile_options(OGLCompiler PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
target_compile_options(OSDependent PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
target_compile_options(SPIRV PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
target_compile_options(glslang-default-resource-limits PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
endif()
if(NCNN_ENABLE_LTO)
set_target_properties(glslang PROPERTIES INTERPROCEDURAL_OPTIMIZATION ON)
set_target_properties(OGLCompiler PROPERTIES INTERPROCEDURAL_OPTIMIZATION ON)
set_target_properties(OSDependent PROPERTIES INTERPROCEDURAL_OPTIMIZATION ON)
set_target_properties(SPIRV PROPERTIES INTERPROCEDURAL_OPTIMIZATION ON)
set_target_properties(glslang-default-resource-limits PROPERTIES INTERPROCEDURAL_OPTIMIZATION ON)
endif()
endif()
endif()
Expand Down
2 changes: 2 additions & 0 deletions cmake/ncnnConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ if(NCNN_VULKAN)

if(NOT NCNN_SHARED_LIB)
if(NCNN_SYSTEM_GLSLANG)
find_package(SPIRV-Tools QUIET)
find_package(SPIRV-Tools-opt QUIET)
find_package(glslang QUIET)
if(NOT glslang_FOUND)
set(GLSLANG_TARGET_DIR "@GLSLANG_TARGET_DIR@")
Expand Down
2 changes: 1 addition & 1 deletion glslang
Submodule glslang updated 963 files

0 comments on commit f5269b6

Please sign in to comment.