From 4f01996c9df0e2edb8823a8260066467c828a341 Mon Sep 17 00:00:00 2001 From: Daniel Story Date: Wed, 24 Jul 2024 17:37:47 -0700 Subject: [PATCH] Merge ancillary libraries into main glslang library and stub originals --- Android.mk | 43 +++++++------- CMakeLists.txt | 9 ++- README.md | 8 ++- SPIRV/CMakeLists.txt | 66 +++++++++++----------- StandAlone/CMakeLists.txt | 22 ++++---- StandAlone/StandAlone.cpp | 18 +++++- glslang/CMakeLists.txt | 37 ++++++++---- glslang/OSDependent/Unix/CMakeLists.txt | 15 +++-- glslang/OSDependent/Web/CMakeLists.txt | 2 +- glslang/OSDependent/Windows/CMakeLists.txt | 14 +++-- glslang/stub.cpp | 37 ++++++++++++ gtests/CMakeLists.txt | 3 +- ndk_test/Android.mk | 2 +- 13 files changed, 181 insertions(+), 95 deletions(-) create mode 100644 glslang/stub.cpp diff --git a/Android.mk b/Android.mk index dcb995844..7adce09cf 100644 --- a/Android.mk +++ b/Android.mk @@ -59,9 +59,8 @@ include $(CLEAR_VARS) LOCAL_MODULE:=OSDependent LOCAL_CXXFLAGS:=-std=c++17 -fno-exceptions -fno-rtti $(GLSLANG_DEFINES) LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH) -LOCAL_SRC_FILES:=glslang/OSDependent/Unix/ossource.cpp -LOCAL_C_INCLUDES:=$(LOCAL_PATH) $(LOCAL_PATH)/glslang/OSDependent/Unix/ -LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH)/glslang/OSDependent/Unix/ +LOCAL_SRC_FILES:=glslang/stub.cpp +LOCAL_C_INCLUDES:=$(LOCAL_PATH) include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) @@ -73,7 +72,8 @@ $(LOCAL_PATH)/glslang/MachineIndependent/ShaderLang.cpp: \ LOCAL_MODULE:=glslang LOCAL_CXXFLAGS:=-std=c++17 -fno-exceptions -fno-rtti $(GLSLANG_DEFINES) -LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH) +LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH) \ + $(LOCAL_PATH)/glslang/OSDependent/Unix LOCAL_SRC_FILES:= \ glslang/CInterface/glslang_c_interface.cpp \ glslang/GenericCodeGen/CodeGen.cpp \ @@ -112,12 +112,24 @@ LOCAL_SRC_FILES:= \ glslang/MachineIndependent/preprocessor/PpContext.cpp \ glslang/MachineIndependent/preprocessor/Pp.cpp \ glslang/MachineIndependent/preprocessor/PpScanner.cpp \ - glslang/MachineIndependent/preprocessor/PpTokens.cpp + glslang/MachineIndependent/preprocessor/PpTokens.cpp \ + glslang/OSDependent/Unix/ossource.cpp + SPIRV/CInterface/spirv_c_interface.cpp \ + SPIRV/GlslangToSpv.cpp \ + SPIRV/InReadableOrder.cpp \ + SPIRV/Logger.cpp \ + SPIRV/SPVRemapper.cpp \ + SPIRV/SpvBuilder.cpp \ + SPIRV/SpvPostProcess.cpp \ + SPIRV/SpvTools.cpp \ + SPIRV/disassemble.cpp \ + SPIRV/doc.cpp LOCAL_C_INCLUDES:=$(LOCAL_PATH) \ $(LOCAL_PATH)/glslang/MachineIndependent \ + $(LOCAL_PATH)/glslang/OSDependent/Unix \ + $(LOCAL_PATH)/SPIRV \ $(GLSLANG_GENERATED_INCLUDEDIR) \ $(GLSLANG_OUT_PATH) -LOCAL_STATIC_LIBRARIES:=OSDependent include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) @@ -128,20 +140,7 @@ $(LOCAL_PATH)/SPIRV/GlslangToSpv.cpp: \ LOCAL_MODULE:=SPIRV LOCAL_CXXFLAGS:=-std=c++17 -fno-exceptions -fno-rtti -Werror $(GLSLANG_DEFINES) -LOCAL_SRC_FILES:= \ - SPIRV/CInterface/spirv_c_interface.cpp \ - SPIRV/GlslangToSpv.cpp \ - SPIRV/InReadableOrder.cpp \ - SPIRV/Logger.cpp \ - SPIRV/SPVRemapper.cpp \ - SPIRV/SpvBuilder.cpp \ - SPIRV/SpvPostProcess.cpp \ - SPIRV/SpvTools.cpp \ - SPIRV/disassemble.cpp \ - SPIRV/doc.cpp -LOCAL_C_INCLUDES:=$(LOCAL_PATH) \ - $(LOCAL_PATH)/glslang/SPIRV \ - $(GLSLANG_GENERATED_INCLUDEDIR) -LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH)/glslang/SPIRV -LOCAL_STATIC_LIBRARIES:=glslang +LOCAL_SRC_FILES:=glslang/stub.cpp +LOCAL_C_INCLUDES:=$(LOCAL_PATH) +LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH) include $(BUILD_STATIC_LIBRARY) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f1680cf0..e82162058 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,6 +97,7 @@ option(GLSLANG_TESTS "Enable glslang testing" ${GLSLANG_TESTS_DEFAULT}) # Always expose this as an option, so the defaults can be overridden. option(GLSLANG_ENABLE_INSTALL "Enable glslang installation" ${GLSLANG_ENABLE_INSTALL_DEFAULT}) +option(ENABLE_SPIRV "Enables SPIRV output support" ON) option(ENABLE_SPVREMAPPER "Enables building of SPVRemapper" ON) option(ENABLE_GLSLANG_BINARIES "Builds glslang and spirv-remap" ON) @@ -125,6 +126,10 @@ endif() option(ENABLE_PCH "Enables Precompiled header" ON) +if(ENABLE_SPIRV) + add_compile_definitions(ENABLE_SPIRV) +endif() + if(ENABLE_HLSL) add_compile_definitions(ENABLE_HLSL) endif() @@ -313,11 +318,13 @@ else() add_definitions(-DENABLE_OPT=0) endif() +if(ENABLE_SPIRV) + add_subdirectory(SPIRV) +endif() add_subdirectory(glslang) if(ENABLE_GLSLANG_BINARIES) add_subdirectory(StandAlone) endif() -add_subdirectory(SPIRV) if(GLSLANG_TESTS) enable_testing() diff --git a/README.md b/README.md index cac2352b2..e7a84fe15 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,13 @@ # News -1. `OGLCompiler` and `HLSL` stub libraries have been fully removed from the build. +1. The `GenericCodeGen`, `MachineIndependent`, `OSDependent`, and `SPIRV` libraries have been integrated into the main `glslang` library. The old separate libraries have replaced with empty stubs for a temporary compatibility period, and they will be removed entirely in the future. -2. `OVERRIDE_MSVCCRT` has been removed in favor of `CMAKE_MSVC_RUNTIME_LIBRARY` +2. A new CMake `ENABLE_SPIRV` option has been added to control whether glslang is built with SPIR-V support. Its default value is `ON`. + +3. `OGLCompiler` and `HLSL` stub libraries have been fully removed from the build. + +4. `OVERRIDE_MSVCCRT` has been removed in favor of `CMAKE_MSVC_RUNTIME_LIBRARY` Users are encouraged to utilize the standard approach via [CMAKE_MSVC_RUNTIME_LIBRARY](https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html). diff --git a/SPIRV/CMakeLists.txt b/SPIRV/CMakeLists.txt index 5e52b38d9..fe1d07bec 100644 --- a/SPIRV/CMakeLists.txt +++ b/SPIRV/CMakeLists.txt @@ -31,41 +31,43 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -set(SOURCES - GlslangToSpv.cpp - InReadableOrder.cpp - Logger.cpp - SpvBuilder.cpp - SpvPostProcess.cpp - doc.cpp - SpvTools.cpp - disassemble.cpp - CInterface/spirv_c_interface.cpp) +set(SPIRV_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/GlslangToSpv.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/InReadableOrder.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Logger.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/SpvBuilder.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/SpvPostProcess.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/doc.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/SpvTools.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/disassemble.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/CInterface/spirv_c_interface.cpp + PARENT_SCOPE) set(SPVREMAP_SOURCES SPVRemapper.cpp doc.cpp) -set(HEADERS - bitutils.h - spirv.hpp - GLSL.std.450.h - GLSL.ext.EXT.h - GLSL.ext.KHR.h - GlslangToSpv.h - hex_float.h - Logger.h - SpvBuilder.h - spvIR.h - doc.h - SpvTools.h - disassemble.h - GLSL.ext.AMD.h - GLSL.ext.NV.h - GLSL.ext.ARM.h - GLSL.ext.QCOM.h - NonSemanticDebugPrintf.h - NonSemanticShaderDebugInfo100.h) +set(SPIRV_HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/bitutils.h + ${CMAKE_CURRENT_SOURCE_DIR}/spirv.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/GLSL.std.450.h + ${CMAKE_CURRENT_SOURCE_DIR}/GLSL.ext.EXT.h + ${CMAKE_CURRENT_SOURCE_DIR}/GLSL.ext.KHR.h + ${CMAKE_CURRENT_SOURCE_DIR}/GlslangToSpv.h + ${CMAKE_CURRENT_SOURCE_DIR}/hex_float.h + ${CMAKE_CURRENT_SOURCE_DIR}/Logger.h + ${CMAKE_CURRENT_SOURCE_DIR}/SpvBuilder.h + ${CMAKE_CURRENT_SOURCE_DIR}/spvIR.h + ${CMAKE_CURRENT_SOURCE_DIR}/doc.h + ${CMAKE_CURRENT_SOURCE_DIR}/SpvTools.h + ${CMAKE_CURRENT_SOURCE_DIR}/disassemble.h + ${CMAKE_CURRENT_SOURCE_DIR}/GLSL.ext.AMD.h + ${CMAKE_CURRENT_SOURCE_DIR}/GLSL.ext.NV.h + ${CMAKE_CURRENT_SOURCE_DIR}/GLSL.ext.ARM.h + ${CMAKE_CURRENT_SOURCE_DIR}/GLSL.ext.QCOM.h + ${CMAKE_CURRENT_SOURCE_DIR}/NonSemanticDebugPrintf.h + ${CMAKE_CURRENT_SOURCE_DIR}/NonSemanticShaderDebugInfo100.h + PARENT_SCOPE) set(SPVREMAP_HEADERS SPVRemapper.h @@ -79,7 +81,7 @@ set(PUBLIC_HEADERS SPVRemapper.h SpvTools.h) -add_library(SPIRV ${LIB_TYPE} ${SOURCES} ${HEADERS}) +add_library(SPIRV ${LIB_TYPE} ${CMAKE_CURRENT_SOURCE_DIR}/../glslang/stub.cpp) add_library(glslang::SPIRV ALIAS SPIRV) set_target_properties(SPIRV PROPERTIES FOLDER glslang @@ -90,8 +92,6 @@ target_include_directories(SPIRV PUBLIC $ $) -glslang_add_build_info_dependency(SPIRV) - if (ENABLE_SPVREMAPPER) add_library(SPVRemapper ${LIB_TYPE} ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS}) add_library(glslang::SPVRemapper ALIAS SPVRemapper) diff --git a/StandAlone/CMakeLists.txt b/StandAlone/CMakeLists.txt index 9ecdcd235..30e8d0302 100644 --- a/StandAlone/CMakeLists.txt +++ b/StandAlone/CMakeLists.txt @@ -59,8 +59,6 @@ glslang_set_link_args(glslang-standalone) set(LIBRARIES glslang - OSDependent - SPIRV glslang-default-resource-limits) if(WIN32) @@ -75,12 +73,14 @@ target_link_libraries(glslang-standalone ${LIBRARIES}) target_include_directories(glslang-standalone PUBLIC $) -if(ENABLE_SPVREMAPPER) - set(REMAPPER_SOURCES spirv-remap.cpp) - add_executable(spirv-remap ${REMAPPER_SOURCES}) - set_property(TARGET spirv-remap PROPERTY FOLDER tools) - glslang_set_link_args(spirv-remap) - target_link_libraries(spirv-remap SPVRemapper ${LIBRARIES}) +if(ENABLE_SPIRV) + if(ENABLE_SPVREMAPPER) + set(REMAPPER_SOURCES spirv-remap.cpp) + add_executable(spirv-remap ${REMAPPER_SOURCES}) + set_property(TARGET spirv-remap PROPERTY FOLDER tools) + glslang_set_link_args(spirv-remap) + target_link_libraries(spirv-remap SPVRemapper ${LIBRARIES}) + endif() endif() if(WIN32) @@ -113,7 +113,9 @@ if(GLSLANG_ENABLE_INSTALL) ) ") - if(ENABLE_SPVREMAPPER) - install(TARGETS spirv-remap EXPORT glslang-targets) + if(ENABLE_SPIRV) + if(ENABLE_SPVREMAPPER) + install(TARGETS spirv-remap EXPORT glslang-targets) + endif() endif() endif(GLSLANG_ENABLE_INSTALL) diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index 94851ba35..bd1800110 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -1509,6 +1509,7 @@ void CompileAndLinkShaderUnits(std::vector compUnits) std::vector outputFiles; +#ifdef ENABLE_SPIRV // Dump SPIR-V if (Options & EOptionSpv) { CompileOrLinkFailed.fetch_or(CompileFailed); @@ -1571,6 +1572,7 @@ void CompileAndLinkShaderUnits(std::vector compUnits) } } } +#endif CompileOrLinkFailed.fetch_or(CompileFailed); CompileOrLinkFailed.fetch_or(LinkFailed); @@ -1669,21 +1671,31 @@ int singleMain() } if (Options & EOptionDumpBareVersion) { - printf("%d:%d.%d.%d%s\n", glslang::GetSpirvGeneratorVersion(), GLSLANG_VERSION_MAJOR, GLSLANG_VERSION_MINOR, + int spirvGeneratorVersion = 0; +#ifdef ENABLE_SPIRV + spirvGeneratorVersion = glslang::GetSpirvGeneratorVersion(); +#endif + printf("%d:%d.%d.%d%s\n", spirvGeneratorVersion, GLSLANG_VERSION_MAJOR, GLSLANG_VERSION_MINOR, GLSLANG_VERSION_PATCH, GLSLANG_VERSION_FLAVOR); if (workList.empty()) return ESuccess; } else if (Options & EOptionDumpVersions) { - printf("Glslang Version: %d:%d.%d.%d%s\n", glslang::GetSpirvGeneratorVersion(), GLSLANG_VERSION_MAJOR, + int spirvGeneratorVersion = 0; +#ifdef ENABLE_SPIRV + spirvGeneratorVersion = glslang::GetSpirvGeneratorVersion(); +#endif + printf("Glslang Version: %d:%d.%d.%d%s\n", spirvGeneratorVersion, GLSLANG_VERSION_MAJOR, GLSLANG_VERSION_MINOR, GLSLANG_VERSION_PATCH, GLSLANG_VERSION_FLAVOR); printf("ESSL Version: %s\n", glslang::GetEsslVersionString()); printf("GLSL Version: %s\n", glslang::GetGlslVersionString()); std::string spirvVersion; +#if ENABLE_SPIRV glslang::GetSpirvVersion(spirvVersion); +#endif printf("SPIR-V Version %s\n", spirvVersion.c_str()); printf("GLSL.std.450 Version %d, Revision %d\n", GLSLstd450Version, GLSLstd450Revision); printf("Khronos Tool ID %d\n", glslang::GetKhronosToolId()); - printf("SPIR-V Generator Version %d\n", glslang::GetSpirvGeneratorVersion()); + printf("SPIR-V Generator Version %d\n", spirvGeneratorVersion); printf("GL_KHR_vulkan_glsl version %d\n", 100); printf("ARB_GL_gl_spirv version %d\n", 100); if (workList.empty()) diff --git a/glslang/CMakeLists.txt b/glslang/CMakeLists.txt index 0385ce8ef..7fc0d87a4 100644 --- a/glslang/CMakeLists.txt +++ b/glslang/CMakeLists.txt @@ -47,9 +47,12 @@ endif() ################################################################################ # GenericCodeGen ################################################################################ -add_library(GenericCodeGen STATIC +set(GENERICCODEGEN_SOURCES GenericCodeGen/CodeGen.cpp GenericCodeGen/Link.cpp) + +add_library(GenericCodeGen STATIC + stub.cpp) set_property(TARGET GenericCodeGen PROPERTY POSITION_INDEPENDENT_CODE ON) set_property(TARGET GenericCodeGen PROPERTY FOLDER glslang) @@ -130,7 +133,7 @@ if(ENABLE_HLSL) HLSL/hlslParseables.h) endif() -add_library(MachineIndependent STATIC ${MACHINEINDEPENDENT_SOURCES} ${MACHINEINDEPENDENT_HEADERS}) +add_library(MachineIndependent STATIC stub.cpp) set_property(TARGET MachineIndependent PROPERTY POSITION_INDEPENDENT_CODE ON) set_property(TARGET MachineIndependent PROPERTY FOLDER glslang) @@ -139,12 +142,6 @@ if (NOT MSVC) set_source_files_properties(MachineIndependent/glslang_tab.cpp PROPERTIES COMPILE_FLAGS -Wno-unused-but-set-variable) endif() -glslang_add_build_info_dependency(MachineIndependent) - -glslang_pch(MachineIndependent MachineIndependent/pch.h) - -target_link_libraries(MachineIndependent PRIVATE OSDependent GenericCodeGen) - ################################################################################ # glslang ################################################################################ @@ -168,26 +165,42 @@ set(GLSLANG_HEADERS Include/SpirvIntrinsics.h Include/Types.h) -add_library(glslang ${LIB_TYPE} ${GLSLANG_SOURCES} ${GLSLANG_HEADERS}) +add_library(glslang ${LIB_TYPE} ${GLSLANG_SOURCES} ${GLSLANG_HEADERS} ${GENERICCODEGEN_SOURCES} ${GENERICCODEGEN_HEADERS} ${OSDEPENDENT_SOURCES} ${OSDEPENDENT_HEADERS} ${MACHINEINDEPENDENT_SOURCES} ${MACHINEINDEPENDENT_HEADERS} ${SPIRV_SOURCES} ${SPIRV_HEADERS}) add_library(glslang::glslang ALIAS glslang) set_target_properties(glslang PROPERTIES FOLDER glslang POSITION_INDEPENDENT_CODE ON VERSION "${GLSLANG_VERSION}" SOVERSION "${GLSLANG_VERSION_MAJOR}") -target_link_libraries(glslang PRIVATE OSDependent MachineIndependent) target_include_directories(glslang PUBLIC $ $) glslang_add_build_info_dependency(glslang) +glslang_pch(glslang MachineIndependent/pch.h) + glslang_only_export_explicit_symbols(glslang) if(WIN32 AND BUILD_SHARED_LIBS) set_target_properties(glslang PROPERTIES PREFIX "") endif() +if(ENABLE_SPIRV) + if(ENABLE_OPT) + target_include_directories(glslang PUBLIC + $) + target_link_libraries(glslang SPIRV-Tools-opt) + endif() +endif() + +# Link pthread +if(UNIX OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia" OR ANDROID) + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) + target_link_libraries(glslang Threads::Threads) +endif() + ################################################################################ # ResourceLimits ################################################################################ @@ -217,6 +230,8 @@ target_include_directories(glslang-default-resource-limits PUBLIC # source_groups ################################################################################ if(WIN32) + source_group("OSDependent" REGULAR_EXPRESSION "OSDependent/[^/]*") + source_group("OSDependent\\Windows" REGULAR_EXPRESSION "OSDependent/Windows/*") source_group("Public" REGULAR_EXPRESSION "Public/*") source_group("MachineIndependent" REGULAR_EXPRESSION "MachineIndependent/[^/]*") source_group("Include" REGULAR_EXPRESSION "Include/[^/]*") @@ -224,6 +239,8 @@ if(WIN32) source_group("MachineIndependent\\Preprocessor" REGULAR_EXPRESSION "MachineIndependent/preprocessor/*") source_group("HLSL" REGULAR_EXPRESSION "HLSL/*") source_group("CInterface" REGULAR_EXPRESSION "CInterface/*") + source_group("SPIRV" REGULAR_EXPRESSION "SPIRV/[^/]*") + source_group("SPIRV\\CInterface" REGULAR_EXPRESSION "SPIRV/CInterface/*") endif() ################################################################################ diff --git a/glslang/OSDependent/Unix/CMakeLists.txt b/glslang/OSDependent/Unix/CMakeLists.txt index 0c5497568..53d9ad384 100644 --- a/glslang/OSDependent/Unix/CMakeLists.txt +++ b/glslang/OSDependent/Unix/CMakeLists.txt @@ -31,15 +31,18 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -add_library(OSDependent STATIC ossource.cpp ../osinclude.h) +set(OSDEPENDENT_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/ossource.cpp + PARENT_SCOPE) + +set(OSDEPENDENT_HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/../osinclude.h + PARENT_SCOPE) + +add_library(OSDependent STATIC ${CMAKE_CURRENT_SOURCE_DIR}/../../stub.cpp) set_property(TARGET OSDependent PROPERTY FOLDER glslang) set_property(TARGET OSDependent PROPERTY POSITION_INDEPENDENT_CODE ON) -# Link pthread -set(THREADS_PREFER_PTHREAD_FLAG ON) -find_package(Threads REQUIRED) -target_link_libraries(OSDependent Threads::Threads) - if(GLSLANG_ENABLE_INSTALL AND NOT BUILD_SHARED_LIBS) install(TARGETS OSDependent EXPORT glslang-targets) endif() diff --git a/glslang/OSDependent/Web/CMakeLists.txt b/glslang/OSDependent/Web/CMakeLists.txt index 5d1749608..2cfe7aae6 100644 --- a/glslang/OSDependent/Web/CMakeLists.txt +++ b/glslang/OSDependent/Web/CMakeLists.txt @@ -34,7 +34,7 @@ if(ENABLE_GLSLANG_JS) add_executable(glslang.js "glslang.js.cpp") glslang_set_link_args(glslang.js) - target_link_libraries(glslang.js glslang SPIRV) + target_link_libraries(glslang.js glslang) # Link library names that start with "-" are treated as link flags. # "-Os" should be OK in MSVC; don't use /Os because CMake won't diff --git a/glslang/OSDependent/Windows/CMakeLists.txt b/glslang/OSDependent/Windows/CMakeLists.txt index 8a9a8c42c..040f4348f 100644 --- a/glslang/OSDependent/Windows/CMakeLists.txt +++ b/glslang/OSDependent/Windows/CMakeLists.txt @@ -31,12 +31,18 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. +set(OSDEPENDENT_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/ossource.cpp + PARENT_SCOPE) + +set(OSDEPENDENT_HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/../osinclude.h + PARENT_SCOPE) + add_library(OSDependent STATIC) target_sources(OSDependent PRIVATE - ../osinclude.h - ossource.cpp -) + ${CMAKE_CURRENT_SOURCE_DIR}/../../stub.cpp) set_property(TARGET OSDependent PROPERTY FOLDER glslang) set_property(TARGET OSDependent PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -44,7 +50,7 @@ set_property(TARGET OSDependent PROPERTY POSITION_INDEPENDENT_CODE ON) # MinGW GCC complains about function pointer casts to void*. # Turn that off with -fpermissive. if(MINGW AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") - target_compile_options(OSDependent PRIVATE -fpermissive) + set_source_files_properties(${OSDEPENDENT_SOURCES} PROPERTIES COMPILE_FLAGS -fpermissive) endif() if(WIN32) diff --git a/glslang/stub.cpp b/glslang/stub.cpp new file mode 100644 index 000000000..b9aec6d15 --- /dev/null +++ b/glslang/stub.cpp @@ -0,0 +1,37 @@ +// +// Copyright (C) 2024 The Khronos Group Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// +// Neither the name of 3Dlabs Inc. Ltd. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +// This empty source file exists to support building stubbed versions of +// deprecated libraries which have been integrated into the main glslang +// library. It should be deleted once the stub libraries are fully removed. diff --git a/gtests/CMakeLists.txt b/gtests/CMakeLists.txt index 8e0edd4d7..1987a6d6b 100644 --- a/gtests/CMakeLists.txt +++ b/gtests/CMakeLists.txt @@ -88,8 +88,7 @@ if(GLSLANG_TESTS) endif() set(LIBRARIES - glslang OSDependent glslang - SPIRV glslang-default-resource-limits) + glslang glslang-default-resource-limits) if(ENABLE_SPVREMAPPER) set(LIBRARIES ${LIBRARIES} SPVRemapper) diff --git a/ndk_test/Android.mk b/ndk_test/Android.mk index 112700c90..897ace006 100644 --- a/ndk_test/Android.mk +++ b/ndk_test/Android.mk @@ -39,7 +39,7 @@ LOCAL_SRC_FILES:=test.cpp LOCAL_MODULE:=glslang_ndk_test LOCAL_LDLIBS:=-landroid LOCAL_CXXFLAGS:=-std=c++17 -fno-exceptions -fno-rtti -Werror -LOCAL_STATIC_LIBRARIES:=glslang SPIRV +LOCAL_STATIC_LIBRARIES:=glslang include $(BUILD_SHARED_LIBRARY) include $(LOCAL_PATH)/../Android.mk