diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 50141582..aa0da9ed 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -38,6 +38,10 @@ jobs: uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} + config: | + query-filters: + - exclude: + id: cpp/integer-multiplication-cast-to-long - name: Configure run: | diff --git a/cmake/cage_build_configuration.cmake b/cmake/cage_build_configuration.cmake index e58c4d6b..4d3a74e6 100644 --- a/cmake/cage_build_configuration.cmake +++ b/cmake/cage_build_configuration.cmake @@ -1,7 +1,7 @@ macro(cage_build_configuration) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(FATAL_ERROR "CMAKE_BUILD_TYPE needs to be set") + message(FATAL_ERROR "CMAKE_BUILD_TYPE must be set") endif() cmake_policy(SET CMP0063 NEW) @@ -44,11 +44,12 @@ 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 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") + # disable some warnings + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS /D_ENABLE_EXTENDED_ALIGNED_STORAGE") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd26812") # The enum type ___ is unscoped. Prefer 'enum class' over 'enum' + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd26451") # Arithmetic overflow: Using operator ___ on a 4 byte value and then casting the result to a 8 byte value. - # optionally improve runtime performance in debug builds + # optionally improve runtime performance in debug builds (basic inlining) 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}") @@ -57,10 +58,13 @@ macro(cage_build_configuration) 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") + # optionally improve runtime performance in release builds (more aggressive inlining) + option(cage_faster_release "enable more aggressive inlining in release builds" ON) + if(cage_faster_release) + string(REGEX REPLACE "/Ob[0-9]" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_DEBUG}") + string(REGEX REPLACE "/Ob[0-9]" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG}") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Ob3") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ob3") endif() # 8 MB default stack size @@ -70,12 +74,17 @@ macro(cage_build_configuration) set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto") - # disable warnings about attributes + # disable some warnings set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-attributes") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes -Wno-abi") + endif() - # no warnings about changes in ABI - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-abi") + if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") # multi-process compilation + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") endif() -endmacro(cage_build_configuration) + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-assume") # __builtin_assume has side effects that are discarded + endif() +endmacro(cage_build_configuration) diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index 3220c6b0..ae09e140 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -63,9 +63,6 @@ endif() if(MSVC) set_source_files_properties(libcore/mesh/marchingCubes.cpp PROPERTIES COMPILE_FLAGS "/wd4244 /wd4267") # it includes file with weird extension which does not honor warnings disabled by pragma endif() -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_compile_options(cage-core PUBLIC "-Wno-assume") # __builtin_assume has side effects that are discarded -endif() try_compile(sourceLocationAvailable "${CMAKE_CURRENT_BINARY_DIR}/tryCompile" SOURCES "${CMAKE_CURRENT_LIST_DIR}/tryCompileSourceLocation.cpp" OUTPUT_VARIABLE sourceLocationMessages) if(NOT sourceLocationAvailable) target_compile_definitions(cage-core PUBLIC GCHL_DUMMY_SOURCE_LOCATION) diff --git a/sources/libcore/mesh/importAssimp.cpp b/sources/libcore/mesh/importAssimp.cpp index fb1b6ae4..fa567def 100644 --- a/sources/libcore/mesh/importAssimp.cpp +++ b/sources/libcore/mesh/importAssimp.cpp @@ -646,7 +646,7 @@ namespace cage } totalKeys += n->mNumScalingKeys; } - const uint32 animationBonesCount = numeric_cast(bones.size()); + const uint16 animationBonesCount = numeric_cast(bones.size()); if (config.verbose) { CAGE_LOG(SeverityEnum::Info, "meshImport", Stringizer() + "animated bones: " + animationBonesCount); @@ -658,7 +658,7 @@ namespace cage { std::vector mapping; mapping.resize(skeletonBonesCount, m); - for (uint16 i = 0; i < bones.size(); i++) + for (uint16 i = 0; i < animationBonesCount; i++) { CAGE_ASSERT(mapping[boneIndices[i]] == m); mapping[boneIndices[i]] = i;