Skip to content

Commit

Permalink
Get rid of all warnings with MSVC and clang-cl (#2177)
Browse files Browse the repository at this point in the history
  • Loading branch information
Malacath-92 authored Apr 10, 2020
1 parent 75de196 commit fd593d5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ 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 ENABLE_PCH)
if(MSVC AND CMAKE_GENERATOR MATCHES "^Visual Studio" AND NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND ENABLE_PCH)
set(PCH_NAME "$(IntDir)\\pch.pch")
# make source files use/depend on PCH_NAME
set_source_files_properties(${${SRCS}} PROPERTIES COMPILE_FLAGS "/Yupch.h /FIpch.h /Fp${PCH_NAME} /Zm300" OBJECT_DEPENDS "${PCH_NAME}")
Expand Down Expand Up @@ -124,14 +124,14 @@ if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0.0")
add_compile_options(-Werror=deprecated-copy)
endif()
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
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(NOT ENABLE_RTTI)
add_compile_options(-fno-rtti)
endif()
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC")
elseif(MSVC)
if(NOT ENABLE_RTTI)
add_compile_options(/GR-) # Disable RTTI
endif()
Expand All @@ -142,7 +142,7 @@ if(ENABLE_GLSLANG_JS)
add_compile_options(/Os /GR-)
else()
add_compile_options(-Os -fno-exceptions)
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT MSVC)
add_compile_options(-Wno-unused-parameter)
add_compile_options(-Wno-unused-variable -Wno-unused-const-variable)
endif()
Expand Down
14 changes: 14 additions & 0 deletions StandAlone/resource_limits_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ const glslang_resource_t* glslang_default_resource(void)
return reinterpret_cast<const glslang_resource_t*>(&glslang::DefaultTBuiltInResource);
}

#if defined(__clang__) || defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable : 4996)
#endif

const char* glslang_default_resource_string()
{
std::string cpp_str = glslang::GetDefaultTBuiltInResourceString();
Expand All @@ -45,6 +53,12 @@ const char* glslang_default_resource_string()
return c_str;
}

#if defined(__clang__) || defined(__GNUC__)
#pragma GCC diagnostic pop
#elif defined(_MSC_VER)
#pragma warning(pop)
#endif

void glslang_decode_resource_limits(glslang_resource_t* resources, char* config)
{
glslang::DecodeResourceLimits(reinterpret_cast<TBuiltInResource*>(resources), config);
Expand Down

0 comments on commit fd593d5

Please sign in to comment.