Fix GLSLANG_IS_SHARED_LIBRARY define
authorBen Clayton <bclayton@google.com>
Thu, 2 Jul 2020 14:54:40 +0000 (15:54 +0100)
committerBen Clayton <bclayton@google.com>
Thu, 2 Jul 2020 15:10:20 +0000 (16:10 +0100)
It was incorrectly always being set, causing linker warnings for MSVC builds.
Also simplify the preprocessor nesting in `glslang\Public\ShaderLang.h`

CMakeLists.txt
glslang/Public/ShaderLang.h

index 9c2f861..baf8ff4 100644 (file)
@@ -210,8 +210,8 @@ endif()
 # GLSLANG_IS_SHARED_LIBRARY define, and GLSLANG_EXPORTING to 1 when specifically
 # building <target>.
 function(glslang_only_export_explicit_symbols target)
-    target_compile_definitions(${target} PUBLIC "GLSLANG_IS_SHARED_LIBRARY=1")
     if(BUILD_SHARED_LIBS)
+        target_compile_definitions(${target} PUBLIC "GLSLANG_IS_SHARED_LIBRARY=1")
         if(WIN32)
             target_compile_definitions(${target} PRIVATE "GLSLANG_EXPORTING=1")
         else()
index 5b30474..4322e18 100644 (file)
         #endif
     #elif __GNUC__ >= 4
         #define GLSLANG_EXPORT __attribute__((visibility("default")))
-    #else
-        #define GLSLANG_EXPORT
     #endif
-#else // GLSLANG_IS_SHARED_LIBRARY
-    #define GLSLANG_EXPORT
 #endif // GLSLANG_IS_SHARED_LIBRARY
 
+#ifndef GLSLANG_EXPORT
+#define GLSLANG_EXPORT
+#endif
+
 //
 // This is the platform independent interface between an OGL driver
 // and the shading language compiler/linker.