Merge pull request #2317 from ShabbyX/glslang_angle

gn: Optionally disable optimizations and HLSL
diff --git a/Android.mk b/Android.mk
index f37ea49..48dfd1f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -14,7 +14,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #
diff --git a/BUILD.bazel b/BUILD.bazel
index ef1ef6a..7c97646 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -14,7 +14,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a4f6253..c9041d8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,7 +14,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #
@@ -107,6 +107,14 @@
     endif(CCACHE_FOUND)
 endif()
 
+# If projects are statically importing glslang targets into a shared library
+# then they'll likely need to build with -fPIC. This can be enabled by setting
+# GLSLANG_BUILD_PIC to 1 before calling add_subdirectory() to import glslang.
+# Note: -fPIC is automatically used when BUILD_SHARED_LIBS is enabled.
+if(NOT DEFINED GLSLANG_BUILD_PIC)
+    option(GLSLANG_BUILD_PIC "Compile glslang with -fPIC" OFF)
+endif()
+
 # Precompiled header macro. Parameters are source file list and filename for pch cpp file.
 macro(glslang_pch SRCS PCHCPP)
   if(MSVC AND CMAKE_GENERATOR MATCHES "^Visual Studio" AND NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND ENABLE_PCH)
@@ -152,7 +160,7 @@
     add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs
                         -Wunused-parameter -Wunused-value  -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable -fno-exceptions)
     add_compile_options(-Wno-reorder)  # disable this from -Wall, since it happens all over.
-    if(BUILD_SHARED_LIBS)
+    if(BUILD_SHARED_LIBS OR GLSLANG_BUILD_PIC)
         add_compile_options(-fPIC)
     endif()
     if(NOT ENABLE_RTTI)
@@ -165,13 +173,17 @@
         add_compile_options(-Werror=deprecated-copy)
     endif()
 
-    # Error if there's symbols that are not found at link time.
-    add_link_options("-Wl,--no-undefined")
+    if(NOT CMAKE_VERSION VERSION_LESS "3.13")
+        # Error if there's symbols that are not found at link time.
+        # add_link_options() was added in CMake 3.13 - if using an earlier
+        # version don't set this - it should be caught by presubmits anyway.
+        add_link_options("-Wl,--no-undefined")
+    endif()
 elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT MSVC)
     add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
                         -Wunused-parameter -Wunused-value  -Wunused-variable)
     add_compile_options(-Wno-reorder)  # disable this from -Wall, since it happens all over.
-    if(BUILD_SHARED_LIBS)
+    if(BUILD_SHARED_LIBS OR GLSLANG_BUILD_PIC)
         add_compile_options(-fPIC)
     endif()
     if(NOT ENABLE_RTTI)
@@ -181,8 +193,12 @@
         add_compile_options(-fno-exceptions)
     endif()
 
-    # Error if there's symbols that are not found at link time.
-    add_link_options("-Wl,-undefined,error")
+    if(NOT CMAKE_VERSION VERSION_LESS "3.13")
+        # Error if there's symbols that are not found at link time.
+        # add_link_options() was added in CMake 3.13 - if using an earlier
+        # version don't set this - it should be caught by presubmits anyway.
+        add_link_options("-Wl,-undefined,error")
+    endif()
 elseif(MSVC)
     if(NOT ENABLE_RTTI)
         string(FIND "${CMAKE_CXX_FLAGS}" "/GR" MSVC_HAS_GR)
diff --git a/ChooseMSVCCRT.cmake b/ChooseMSVCCRT.cmake
index e0329e5..b156126 100644
--- a/ChooseMSVCCRT.cmake
+++ b/ChooseMSVCCRT.cmake
@@ -14,7 +14,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #
diff --git a/External/CMakeLists.txt b/External/CMakeLists.txt
index 2a83ac1..cbabd2e 100644
--- a/External/CMakeLists.txt
+++ b/External/CMakeLists.txt
@@ -14,7 +14,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #
diff --git a/OGLCompilersDLL/CMakeLists.txt b/OGLCompilersDLL/CMakeLists.txt
index 14ab89b..0b007d4 100644
--- a/OGLCompilersDLL/CMakeLists.txt
+++ b/OGLCompilersDLL/CMakeLists.txt
@@ -14,7 +14,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #
diff --git a/SPIRV/CMakeLists.txt b/SPIRV/CMakeLists.txt
index c4436e0..0f26bcc 100644
--- a/SPIRV/CMakeLists.txt
+++ b/SPIRV/CMakeLists.txt
@@ -14,7 +14,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #
diff --git a/StandAlone/CMakeLists.txt b/StandAlone/CMakeLists.txt
index c266fc4..8038c04 100644
--- a/StandAlone/CMakeLists.txt
+++ b/StandAlone/CMakeLists.txt
@@ -14,7 +14,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #
diff --git a/glslang/CMakeLists.txt b/glslang/CMakeLists.txt
index cfd9c6f..98c8145 100644
--- a/glslang/CMakeLists.txt
+++ b/glslang/CMakeLists.txt
@@ -14,7 +14,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #
diff --git a/glslang/OSDependent/Unix/CMakeLists.txt b/glslang/OSDependent/Unix/CMakeLists.txt
index 71d0821..354a3e9 100644
--- a/glslang/OSDependent/Unix/CMakeLists.txt
+++ b/glslang/OSDependent/Unix/CMakeLists.txt
@@ -14,7 +14,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #
diff --git a/glslang/OSDependent/Web/CMakeLists.txt b/glslang/OSDependent/Web/CMakeLists.txt
index 75f8afa..0f60dbc 100644
--- a/glslang/OSDependent/Web/CMakeLists.txt
+++ b/glslang/OSDependent/Web/CMakeLists.txt
@@ -14,7 +14,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #
diff --git a/glslang/OSDependent/Windows/CMakeLists.txt b/glslang/OSDependent/Windows/CMakeLists.txt
index b5aa0e9..9cf1b7f 100644
--- a/glslang/OSDependent/Windows/CMakeLists.txt
+++ b/glslang/OSDependent/Windows/CMakeLists.txt
@@ -14,7 +14,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #
diff --git a/glslang/updateGrammar b/glslang/updateGrammar
index 667cdd7..9209493 100755
--- a/glslang/updateGrammar
+++ b/glslang/updateGrammar
@@ -16,7 +16,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #
diff --git a/gtests/CMakeLists.txt b/gtests/CMakeLists.txt
index bc9fd2d..34da2ce 100644
--- a/gtests/CMakeLists.txt
+++ b/gtests/CMakeLists.txt
@@ -14,7 +14,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #
diff --git a/hlsl/CMakeLists.txt b/hlsl/CMakeLists.txt
index a597d35..62faa19 100644
--- a/hlsl/CMakeLists.txt
+++ b/hlsl/CMakeLists.txt
@@ -14,7 +14,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #
diff --git a/kokoro/license-check/continuous.cfg b/kokoro/license-check/continuous.cfg
index 53496f2..1f36031 100644
--- a/kokoro/license-check/continuous.cfg
+++ b/kokoro/license-check/continuous.cfg
@@ -32,4 +32,4 @@
 # POSSIBILITY OF SUCH DAMAGE.
 
 # Continuous build configuration.
-build_file: "glslang/kokoro/license-check.sh"
+build_file: "glslang/kokoro/license-check/build.sh"
diff --git a/kokoro/license-check/presubmit.cfg b/kokoro/license-check/presubmit.cfg
index c24ea23..4cf9238 100644
--- a/kokoro/license-check/presubmit.cfg
+++ b/kokoro/license-check/presubmit.cfg
@@ -32,4 +32,4 @@
 # POSSIBILITY OF SUCH DAMAGE.
 
 # Presubmit build configuration.
-build_file: "glslang/kokoro/license-check.sh"
+build_file: "glslang/kokoro/license-check/build.sh"
diff --git a/ndk_test/Android.mk b/ndk_test/Android.mk
index c656e7a..b1b2207 100644
--- a/ndk_test/Android.mk
+++ b/ndk_test/Android.mk
@@ -14,7 +14,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #
diff --git a/ndk_test/jni/Application.mk b/ndk_test/jni/Application.mk
index 5ff32f7..07b7615 100644
--- a/ndk_test/jni/Application.mk
+++ b/ndk_test/jni/Application.mk
@@ -14,7 +14,7 @@
 #    disclaimer in the documentation and/or other materials provided
 #    with the distribution.
 #
-#    Neither the name of Google Inc. nor the names of its
+#    Neither the name of The Khronos Group Inc. nor the names of its
 #    contributors may be used to endorse or promote products derived
 #    from this software without specific prior written permission.
 #