From b3c7bdbdd656d08e5f927bf4305962df222480c2 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 17 Sep 2022 18:16:42 +0200 Subject: [PATCH] Add check for wall switch from cmake --- code/AssetLib/FBX/FBXConverter.cpp | 17 +++++++---------- test/CMakeLists.txt | 8 ++++++++ tools/assimp_cmd/CMakeLists.txt | 10 ++++++++-- tools/assimp_view/CMakeLists.txt | 8 ++++++++ 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp index ffe961a4e..e5ba37642 100644 --- a/code/AssetLib/FBX/FBXConverter.cpp +++ b/code/AssetLib/FBX/FBXConverter.cpp @@ -305,19 +305,16 @@ void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node) } } - if (nodes.size()) { - parent->mChildren = new aiNode *[nodes.size()](); - parent->mNumChildren = static_cast(nodes.size()); - - for (unsigned int i = 0; i < nodes.size(); ++i) - { - parent->mChildren[i] = nodes[i].mOwnership.release(); - } - nodes.clear(); - } else { + if (nodes.empty()) { parent->mNumChildren = 0; parent->mChildren = nullptr; } + + parent->mChildren = new aiNode *[nodes.size()](); + parent->mNumChildren = static_cast(nodes.size()); + for (unsigned int i = 0; i < nodes.size(); ++i) { + parent->mChildren[i] = nodes[i].mOwnership.release(); + } } void FBXConverter::ConvertLights(const Model &model, const std::string &orig_name) { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 87a5ebadb..72cb1e4d2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -263,6 +263,14 @@ IF(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) ENDIF() +IF (ASSIMP_WARNINGS_AS_ERRORS) + IF (MSVC) + TARGET_COMPILE_OPTIONS(unit PRIVATE /W4 /WX) + ELSE() + TARGET_COMPILE_OPTIONS(unit PRIVATE -Wall -Werror) + ENDIF() +ENDIF() + target_link_libraries( unit assimp ${platform_libs} ) add_subdirectory(headercheck) diff --git a/tools/assimp_cmd/CMakeLists.txt b/tools/assimp_cmd/CMakeLists.txt index e66a5694d..5b80ee77b 100644 --- a/tools/assimp_cmd/CMakeLists.txt +++ b/tools/assimp_cmd/CMakeLists.txt @@ -2,8 +2,6 @@ # ---------------------------------------------------------------------- # # Copyright (c) 2006-2022, assimp team - - # All rights reserved. # # Redistribution and use of this software in source and binary forms, @@ -62,6 +60,14 @@ ADD_EXECUTABLE( assimp_cmd ${ASSIMP_CMD_RC} ) +IF (ASSIMP_WARNINGS_AS_ERRORS) + IF (MSVC) + TARGET_COMPILE_OPTIONS(assimp_cmd PRIVATE /W4 /WX) + ELSE() + TARGET_COMPILE_OPTIONS(assimp_cmd PRIVATE -Wall -Werror) + ENDIF() +ENDIF() + TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp_cmd) SET_PROPERTY(TARGET assimp_cmd PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) diff --git a/tools/assimp_view/CMakeLists.txt b/tools/assimp_view/CMakeLists.txt index 25304f407..a5a9eed35 100644 --- a/tools/assimp_view/CMakeLists.txt +++ b/tools/assimp_view/CMakeLists.txt @@ -95,6 +95,14 @@ IF ( MSVC ) REMOVE_DEFINITIONS( -DUNICODE -D_UNICODE ) ENDIF () +IF (ASSIMP_WARNINGS_AS_ERRORS) + IF (MSVC) + TARGET_COMPILE_OPTIONS(assimp_viewer PRIVATE /W4 /WX) + ELSE() + TARGET_COMPILE_OPTIONS(assimp_viewer PRIVATE -Wall -Werror) + ENDIF() +ENDIF() + # Link the executable to the assimp + dx libs. TARGET_LINK_LIBRARIES ( assimp_viewer assimp ${DirectX_LIBRARY} ${DirectX_D3DX9_LIBRARY} comctl32 winmm )