From 6224e5ed6bef061fad0ca4fd71672c20a551999b Mon Sep 17 00:00:00 2001 From: Lukas W Date: Wed, 22 Nov 2017 13:49:57 +0100 Subject: [PATCH] MSVC: Various fixes * CMake * Compiler flags fixes * Don't strip * Fix default template argument errors * Fix VLAs. MSVC doesn't support C99, so Variable-Length-Arrays are not available. Use QVarLengthArray instead. --- CMakeLists.txt | 4 +++- cmake/modules/BuildPlugin.cmake | 4 ++-- include/lmms_basics.h | 2 +- plugins/DualFilter/DualFilterControls.cpp | 4 ++-- plugins/LadspaEffect/LadspaEffect.cpp | 5 +++-- plugins/MultitapEcho/MultitapEchoControls.cpp | 4 ++-- plugins/xpressive/CMakeLists.txt | 2 +- src/CMakeLists.txt | 2 +- 8 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bfacedc90..b27c52da5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -489,7 +489,9 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES (GNU|AppleClang)) IF (CMAKE_COMPILER_IS_GNUCXX AND ((CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "4.8.0") OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.8.0") OR LMMS_BUILD_WIN32)) SET(WERROR_FLAGS "${WERROR_FLAGS} -Wno-array-bounds") ENDIF() -ELSE() +ELSEIF(MSVC) + # Remove any existing /W flags + STRING(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) SET(WERROR_FLAGS "/W2") IF(${USE_WERROR}) SET(WERROR_FLAGS "${WERROR_FLAGS} /WX") diff --git a/cmake/modules/BuildPlugin.cmake b/cmake/modules/BuildPlugin.cmake index f3bea9e31..586279e82 100644 --- a/cmake/modules/BuildPlugin.cmake +++ b/cmake/modules/BuildPlugin.cmake @@ -74,10 +74,10 @@ MACRO(BUILD_PLUGIN PLUGIN_NAME) SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LINK_FLAGS "-bundle_loader ${CMAKE_BINARY_DIR}/lmms") ADD_DEPENDENCIES(${PLUGIN_NAME} lmms) ENDIF(LMMS_BUILD_APPLE) - IF(LMMS_BUILD_WIN32) + IF(LMMS_BUILD_WIN32 AND STRIP) SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES PREFIX "") ADD_CUSTOM_COMMAND(TARGET ${PLUGIN_NAME} POST_BUILD COMMAND ${STRIP} $) - ENDIF(LMMS_BUILD_WIN32) + ENDIF() SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${RCC_OUT} ${plugin_MOC_out}") ENDMACRO(BUILD_PLUGIN) diff --git a/include/lmms_basics.h b/include/lmms_basics.h index 9b4bd6d55..637867b4d 100644 --- a/include/lmms_basics.h +++ b/include/lmms_basics.h @@ -96,7 +96,7 @@ struct typeInfo template<> inline float typeInfo::minEps() { - return 1.0e-10; + return 1.0e-10f; } template<> diff --git a/plugins/DualFilter/DualFilterControls.cpp b/plugins/DualFilter/DualFilterControls.cpp index 7fdd59e88..63f7887f1 100644 --- a/plugins/DualFilter/DualFilterControls.cpp +++ b/plugins/DualFilter/DualFilterControls.cpp @@ -40,7 +40,7 @@ DualFilterControls::DualFilterControls( DualFilterEffect* effect ) : m_enabled1Model( true, this, tr( "Filter 1 enabled" ) ), m_filter1Model( this, tr( "Filter 1 type" ) ), m_cut1Model( 7000.0f, 1.0f, 20000.0f, 1.0f, this, tr( "Cutoff 1 frequency" ) ), - m_res1Model( 0.5, BasicFilters<0>::minQ(), 10.0, 0.01, this, tr( "Q/Resonance 1" ) ), + m_res1Model( 0.5, BasicFilters<>::minQ(), 10.0, 0.01, this, tr( "Q/Resonance 1" ) ), m_gain1Model( 100.0f, 0.0f, 200.0f, 0.1f, this, tr( "Gain 1" ) ), m_mixModel( 0.0f, -1.0f, 1.0f, 0.01f, this, tr( "Mix" ) ), @@ -48,7 +48,7 @@ DualFilterControls::DualFilterControls( DualFilterEffect* effect ) : m_enabled2Model( true, this, tr( "Filter 2 enabled" ) ), m_filter2Model( this, tr( "Filter 2 type" ) ), m_cut2Model( 7000.0f, 1.0f, 20000.0f, 1.0f, this, tr( "Cutoff 2 frequency" ) ), - m_res2Model( 0.5, BasicFilters<0>::minQ(), 10.0, 0.01, this, tr( "Q/Resonance 2" ) ), + m_res2Model( 0.5, BasicFilters<>::minQ(), 10.0, 0.01, this, tr( "Q/Resonance 2" ) ), m_gain2Model( 100.0f, 0.0f, 200.0f, 0.1f, this, tr( "Gain 2" ) ) { m_filter1Model.addItem( tr( "LowPass" ), new PixmapLoader( "filter_lp" ) ); diff --git a/plugins/LadspaEffect/LadspaEffect.cpp b/plugins/LadspaEffect/LadspaEffect.cpp index d24574ff9..0ce667213 100644 --- a/plugins/LadspaEffect/LadspaEffect.cpp +++ b/plugins/LadspaEffect/LadspaEffect.cpp @@ -24,6 +24,7 @@ */ +#include #include #include "LadspaEffect.h" @@ -141,12 +142,12 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, int frames = _frames; sampleFrame * o_buf = NULL; - sampleFrame sBuf [_frames]; + QVarLengthArray sBuf(_frames * DEFAULT_CHANNELS); if( m_maxSampleRate < Engine::mixer()->processingSampleRate() ) { o_buf = _buf; - _buf = &sBuf[0]; + _buf = reinterpret_cast(sBuf.data()); sampleDown( o_buf, _buf, m_maxSampleRate ); frames = _frames * m_maxSampleRate / Engine::mixer()->processingSampleRate(); diff --git a/plugins/MultitapEcho/MultitapEchoControls.cpp b/plugins/MultitapEcho/MultitapEchoControls.cpp index 09c45228d..899d3e80f 100644 --- a/plugins/MultitapEcho/MultitapEchoControls.cpp +++ b/plugins/MultitapEcho/MultitapEchoControls.cpp @@ -102,7 +102,7 @@ void MultitapEchoControls::setDefaultAmpShape() { const int length = m_steps.value(); - float samples [length]; + QVarLengthArray samples(length); for( int i = 0; i < length; ++i ) { samples[i] = 0.0f; @@ -116,7 +116,7 @@ void MultitapEchoControls::setDefaultLpShape() { const int length = m_steps.value(); - float samples [length]; + QVarLengthArray samples(length); for( int i = 0; i < length; ++i ) { samples[i] = 3.0f; diff --git a/plugins/xpressive/CMakeLists.txt b/plugins/xpressive/CMakeLists.txt index 68cb0a02b..a9de4646e 100644 --- a/plugins/xpressive/CMakeLists.txt +++ b/plugins/xpressive/CMakeLists.txt @@ -2,7 +2,7 @@ INCLUDE(BuildPlugin) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dexprtk_disable_sc_andor -Dexprtk_disable_return_statement -Dexprtk_disable_break_continue -Dexprtk_disable_comments -Dexprtk_disable_string_capabilities -Dexprtk_disable_rtl_io_file -Dexprtk_disable_rtl_vecops ${WERROR_FLAGS} -fexceptions") -IF(WIN32) +IF(WIN32 AND NOT MSVC) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj -Dexprtk_disable_enhanced_features") ENDIF() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4dd7c6505..078205189 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -118,7 +118,7 @@ ENDIF() SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LMMS_RCC_OUT} ${LMMS_UI_OUT} lmmsconfig.h lmms.1.gz") IF(LMMS_BUILD_WIN32) - SET(EXTRA_LIBRARIES "-lwinmm") + SET(EXTRA_LIBRARIES "winmm") ENDIF() IF(LMMS_BUILD_APPLE)