From add5d9fc0759f082b8b85066648307ad8d598519 Mon Sep 17 00:00:00 2001 From: krasko <154632626+krasko78@users.noreply.github.com> Date: Sun, 4 May 2025 17:47:02 +0200 Subject: [PATCH] Visual Studio warning fixes and improvements --- .gitignore | 4 ++++ buildscripts/cmake/SetupBuildEnvironment.cmake | 7 +++++++ src/app/CMakeLists.txt | 14 ++++++++++++++ .../flac/flac-1.4.3/src/libFLAC++/metadata.cpp | 7 +++++-- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ab439b6bec2b6..78ef29cb0f28a 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,7 @@ __pycache__/ # Stuff from 3.x builds /share/sound/MuseScore_General* + +# User overrides of SetupBuildEnvironment +/buildscripts/cmake/SetupBuildEnvironment.user.cmake + diff --git a/buildscripts/cmake/SetupBuildEnvironment.cmake b/buildscripts/cmake/SetupBuildEnvironment.cmake index 3bc4e18fe74e8..4e10e911313ec 100644 --- a/buildscripts/cmake/SetupBuildEnvironment.cmake +++ b/buildscripts/cmake/SetupBuildEnvironment.cmake @@ -75,6 +75,8 @@ if(CC_IS_MSVC) add_compile_definitions(_UNICODE UNICODE) add_compile_definitions(_USE_MATH_DEFINES) add_compile_definitions(NOMINMAX) + + add_link_options("/NODEFAULTLIB:LIBCMT") endif() # MinGW-specific @@ -111,3 +113,8 @@ endif(CC_IS_EMSCRIPTEN) # Warnings include(SetupCompileWarnings) + +# User overrides +if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SetupBuildEnvironment.user.cmake") + include(${CMAKE_CURRENT_LIST_DIR}/SetupBuildEnvironment.user.cmake) +endif() diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 57b3416460820..c4e23632942e7 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -443,6 +443,20 @@ endif() # Miscellaneous Microsoft Visual Studio settings ################################################# if (MSVC) + # Add a post-build event to deploy the application to the output folder. Same as building the INSTALL target. + STRING(TOUPPER ${CMAKE_GENERATOR} UPPER_CMAKE_GENERATOR) + if (${UPPER_CMAKE_GENERATOR} MATCHES "VISUAL STUDIO") + # We want $(Configuration) passed verbatim. Note the round brackets. + set(CONFIG_STR "$(Configuration)") + + add_custom_command( + TARGET MuseScoreStudio POST_BUILD + COMMAND ${CMAKE_COMMAND} -DBUILD_TYPE=${CONFIG_STR} -P cmake_install.cmake + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + VERBATIM + ) + endif() + # Force the "install" and "package" targets not to depend on the "all" target. set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true) set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY true) diff --git a/src/framework/audio/thirdparty/flac/flac-1.4.3/src/libFLAC++/metadata.cpp b/src/framework/audio/thirdparty/flac/flac-1.4.3/src/libFLAC++/metadata.cpp index beab110903c83..7428f4caa16a9 100644 --- a/src/framework/audio/thirdparty/flac/flac-1.4.3/src/libFLAC++/metadata.cpp +++ b/src/framework/audio/thirdparty/flac/flac-1.4.3/src/libFLAC++/metadata.cpp @@ -35,11 +35,14 @@ #include "config.h" #endif +// MuseScore change: moved these two includes before the others +// to avoid a "M_LN2 macro redefinition" warning in Visual Studio. +#include // for malloc(), free() +#include // for memcpy() etc. + #include "share/alloc.h" #include "FLAC++/metadata.h" #include "FLAC/assert.h" -#include // for malloc(), free() -#include // for memcpy() etc. #ifdef _MSC_VER // warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning)