Skip to content

Commit

Permalink
fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Dec 4, 2022
1 parent 2cf7ca9 commit 6b7a4bf
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 23 deletions.
22 changes: 15 additions & 7 deletions cmake/cage_build_configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ macro(cage_build_configuration)
message(FATAL_ERROR "CMAKE_BUILD_TYPE needs to be set")
endif()

message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "CMAKE_CXX_COMPILER_VERSION: ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "CMAKE_CXX_SIMULATE_ID: ${CMAKE_CXX_SIMULATE_ID}")

cmake_policy(SET CMP0063 NEW)

# language standard
Expand All @@ -19,10 +23,6 @@ macro(cage_build_configuration)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)

if(MSVC)
# multi-process compilation
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")

# enable UTF-8
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
Expand All @@ -38,23 +38,31 @@ macro(cage_build_configuration)
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")

# disable compiler warnings:
# disable some compiler warnings:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_ENABLE_EXTENDED_ALIGNED_STORAGE")

# optionally improve runtime performance in debug builds
option(CAGE_FASTER_DEBUG "enable some optimizations to improve performance in debug builds" ON)
if(CAGE_FASTER_DEBUG)
string(REGEX REPLACE "/Ob[0-9]" "" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
string(REGEX REPLACE "/Ob[0-9]" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Ob1")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Ob1 /D_ITERATOR_DEBUG_LEVEL=0")
endif()

# multi-process compilation
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()
else()
# link time optimizations
# fails with clang - generates empty archive in zlib-ng
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
#if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
endif()
#endif()

# disable warnings about attributes
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-attributes")
Expand Down
2 changes: 2 additions & 0 deletions sources/asset-processor/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ void processModel()
case MeshImportTextureType::Normal:
dsm.textureNames[CAGE_SHADER_TEXTURE_NORMAL] = n;
break;
default:
break;
}
}

Expand Down
30 changes: 14 additions & 16 deletions sources/libcore/image/ktx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,26 @@ namespace cage
case ImageKtxTranscodeFormatEnum::Bc4: return basist::transcoder_texture_format::cTFBC4_R;
case ImageKtxTranscodeFormatEnum::Bc5: return basist::transcoder_texture_format::cTFBC5_RG;
case ImageKtxTranscodeFormatEnum::Bc7: return basist::transcoder_texture_format::cTFBC7_RGBA;
default: CAGE_THROW_ERROR(Exception, "invalid ImageKtxBlocksFormatEnum");
}
CAGE_THROW_ERROR(Exception, "invalid ImageKtxBlocksFormatEnum");
}

void throwError(basisu::basis_compressor::error_code result)
{
if (result != basisu::basis_compressor::error_code::cECSuccess)
switch (result)
{
switch (result)
{
case basisu::basis_compressor::error_code::cECFailedReadingSourceImages: CAGE_LOG_THROW("failed loading source images"); break;
case basisu::basis_compressor::error_code::cECFailedValidating: CAGE_LOG_THROW("failed validation"); break;
case basisu::basis_compressor::error_code::cECFailedEncodeUASTC: CAGE_LOG_THROW("failed encoding uastc"); break;
case basisu::basis_compressor::error_code::cECFailedFrontEnd: CAGE_LOG_THROW("failed frontend"); break;
case basisu::basis_compressor::error_code::cECFailedFontendExtract: CAGE_LOG_THROW("failed frontend extract"); break;
case basisu::basis_compressor::error_code::cECFailedBackend: CAGE_LOG_THROW("failed backend"); break;
case basisu::basis_compressor::error_code::cECFailedCreateBasisFile: CAGE_LOG_THROW("failed to create basis file"); break;
case basisu::basis_compressor::error_code::cECFailedWritingOutput: CAGE_LOG_THROW("failed writing output"); break;
case basisu::basis_compressor::error_code::cECFailedUASTCRDOPostProcess: CAGE_LOG_THROW("failed uastc rdo post process"); break;
case basisu::basis_compressor::error_code::cECFailedCreateKTX2File: CAGE_LOG_THROW("failed to create ktx file"); break;
}
CAGE_THROW_ERROR(Exception, "failed encoding ktx image");
case basisu::basis_compressor::error_code::cECSuccess: return;
case basisu::basis_compressor::error_code::cECFailedReadingSourceImages: CAGE_LOG_THROW("failed loading source images"); break;
case basisu::basis_compressor::error_code::cECFailedValidating: CAGE_LOG_THROW("failed validation"); break;
case basisu::basis_compressor::error_code::cECFailedEncodeUASTC: CAGE_LOG_THROW("failed encoding uastc"); break;
case basisu::basis_compressor::error_code::cECFailedFrontEnd: CAGE_LOG_THROW("failed frontend"); break;
case basisu::basis_compressor::error_code::cECFailedFontendExtract: CAGE_LOG_THROW("failed frontend extract"); break;
case basisu::basis_compressor::error_code::cECFailedBackend: CAGE_LOG_THROW("failed backend"); break;
case basisu::basis_compressor::error_code::cECFailedCreateBasisFile: CAGE_LOG_THROW("failed to create basis file"); break;
case basisu::basis_compressor::error_code::cECFailedWritingOutput: CAGE_LOG_THROW("failed writing output"); break;
case basisu::basis_compressor::error_code::cECFailedUASTCRDOPostProcess: CAGE_LOG_THROW("failed uastc rdo post process"); break;
case basisu::basis_compressor::error_code::cECFailedCreateKTX2File: CAGE_LOG_THROW("failed to create ktx file"); break;
default: CAGE_THROW_ERROR(Exception, "failed encoding ktx image");
}
}

Expand Down
4 changes: 4 additions & 0 deletions sources/libcore/mesh/importConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ namespace cage
default: CAGE_THROW_ERROR(Exception, "unexpected channels count for opacity texture");
}
} break;
default:
break;
}
}

Expand Down Expand Up @@ -170,6 +172,8 @@ namespace cage
case MeshImportTextureType::Mask:
process(it, 3);
break;
default:
break;
}
}

Expand Down
4 changes: 4 additions & 0 deletions sources/libengine/virtualReality/openxr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@ namespace cage
case XR_SESSION_STATE_EXITING:
stopping = true;
break;
case XR_SESSION_STATE_MAX_ENUM:
break;
}
} break;
case XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED:
Expand Down Expand Up @@ -773,6 +775,8 @@ namespace cage
case XR_ERROR_SESSION_LOST:
case XR_ERROR_SESSION_NOT_RUNNING:
return;
default:
break;
}
check(res);
impl->syncTime = frameState.predictedDisplayTime;
Expand Down
2 changes: 2 additions & 0 deletions sources/test-core/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,8 @@ namespace
case MeshImportTextureType::Normal:
normal = std::move(it.images.parts[0].image);
break;
default:
break;
}
}
const Image *arr[] = { nullptr, +roughness, +metallic };
Expand Down

0 comments on commit 6b7a4bf

Please sign in to comment.