Skip to content

Commit c50abc8

Browse files
authored
Merge pull request #253 from alnitak/winOptimization
fix win: force CMakeLists to build the plugin in release mode even in debug mode
2 parents 3b217c8 + cdcac70 commit c50abc8

File tree

6 files changed

+57
-18
lines changed

6 files changed

+57
-18
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#### 3.1.11 (X Xxx 2025)
1+
#### 3.1.11 (16 Jun 2025)
22
- fix: Loading the same AudioSource twice (in parallel) crashes #247
3+
- fix win: force cmake to build the plugin in release mode even if building in debug
34

45
#### 3.1.10 (8 May 2025)
56
- fix: Setting pan doesn't cancel pan oscillation #239

android/Configure.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ print_option_status (SOLOUD_STATIC "Build static library")
1212
option (SOLOUD_C_API "Set to ON to include the C API" OFF)
1313
print_option_status (SOLOUD_C_API "Build C API")
1414

15-
# TODO:
1615
option (SOLOUD_BACKEND_MINIAUDIO "Set to ON to include MiniAudio" ON)
17-
print_option_status (SOLOUD_WITH_MINIAUDIO "Build MiniAudio")
16+
print_option_status (SOLOUD_BACKEND_MINIAUDIO "Build MiniAudio")
1817

1918
option (SOLOUD_BUILD_DEMOS "Set to ON for building demos" OFF)
2019
print_option_status (SOLOUD_BUILD_DEMOS "Build demos")

example/pubspec.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ packages:
7777
dependency: transitive
7878
description:
7979
name: ffi
80-
sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418"
80+
sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6"
8181
url: "https://pub.dev"
8282
source: hosted
83-
version: "2.1.4"
83+
version: "2.1.3"
8484
file_picker:
8585
dependency: "direct main"
8686
description:
@@ -108,7 +108,7 @@ packages:
108108
path: ".."
109109
relative: true
110110
source: path
111-
version: "3.1.10"
111+
version: "3.1.11"
112112
flutter_test:
113113
dependency: "direct dev"
114114
description: flutter
@@ -376,10 +376,10 @@ packages:
376376
dependency: transitive
377377
description:
378378
name: win32
379-
sha256: "329edf97fdd893e0f1e3b9e88d6a0e627128cc17cc316a8d67fda8f1451178ba"
379+
sha256: daf97c9d80197ed7b619040e86c8ab9a9dad285e7671ee7390f9180cc828a51e
380380
url: "https://pub.dev"
381381
source: hosted
382-
version: "5.13.0"
382+
version: "5.10.1"
383383
xdg_directories:
384384
dependency: transitive
385385
description:
@@ -389,5 +389,5 @@ packages:
389389
source: hosted
390390
version: "1.1.0"
391391
sdks:
392-
dart: ">=3.7.0 <4.0.0"
392+
dart: ">=3.7.0-0 <4.0.0"
393393
flutter: ">=3.27.0"

linux/Configure.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ option (SOLOUD_C_API "Set to ON to include the C API" OFF)
1313
print_option_status (SOLOUD_C_API "Build C API")
1414

1515

16-
# TODO:
1716
option (SOLOUD_BACKEND_MINIAUDIO "Set to ON to include MiniAudio" ON)
18-
print_option_status (SOLOUD_WITH_MINIAUDIO "Build MiniAudio")
17+
print_option_status (SOLOUD_BACKEND_MINIAUDIO "Build MiniAudio")
1918

2019
option (SOLOUD_BUILD_DEMOS "Set to ON for building demos" OFF)
2120
print_option_status (SOLOUD_BUILD_DEMOS "Build demos")

windows/CMakeLists.txt

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,53 @@ else()
104104
add_definitions(-DNO_OPUS_OGG_LIBS)
105105
endif()
106106

107-
target_compile_options(${PLUGIN_NAME} PRIVATE
108-
/W4 # Warning level 4
107+
if(MSVC)
108+
# Force optimize flags for all configurations
109+
string(REPLACE "/O2" "/Ox" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
110+
string(REPLACE "/Ob1" "/Ob2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
111+
string(REPLACE "/Od" "/Ox" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
112+
string(REPLACE "/Od" "/Ox" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
113+
114+
# Remove RTC1 from debug flags
115+
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
116+
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
117+
118+
# Use static runtime for all configurations
119+
foreach(CONFIG DEBUG RELEASE RELWITHDEBINFO MINSIZEREL)
120+
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_${CONFIG} "${CMAKE_CXX_FLAGS_${CONFIG}}")
121+
string(REPLACE "/MDd" "/MT" CMAKE_CXX_FLAGS_${CONFIG} "${CMAKE_CXX_FLAGS_${CONFIG}}")
122+
endforeach()
123+
124+
# Advanced optimization flags
125+
set(OPTIMIZATION_FLAGS
126+
/GL # Whole program optimization
127+
/Gy # Function-level linking
128+
/Oi # Generate intrinsic functions
129+
/Ot # Favor fast code
130+
/Ox # Full optimization
131+
/fp:fast # Fast floating-point model
132+
/arch:AVX2 # Use AVX2 instructions
133+
/Qpar # Auto-parallelize loops
134+
/O2 # Maximize speed
135+
/RTC- # Disable runtime checks explicitly
136+
)
137+
138+
# Apply optimization flags to all configurations
139+
foreach(FLAG ${OPTIMIZATION_FLAGS})
140+
target_compile_options(${PLUGIN_NAME} PRIVATE ${FLAG})
141+
endforeach()
142+
143+
# Linker optimization flags
144+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG /OPT:REF /OPT:ICF")
145+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LTCG /OPT:REF /OPT:ICF")
146+
147+
# Replace existing compile options with optimized ones
148+
target_compile_options(${PLUGIN_NAME} PRIVATE
149+
/W4 # Warning level 4
109150
/WX- # Disable warnings as errors
110-
/arch:SSE2 # Enable SSE2 instructions
111-
/arch:SSE3 # Enable SSE3 instructions
112-
)
151+
${OPTIMIZATION_FLAGS}
152+
)
153+
endif()
113154

114155
# List of absolute paths to libraries that should be bundled with the plugin.
115156
set(flutter_soloud_bundled_libraries

windows/Configure.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ option (SOLOUD_C_API "Set to ON to include the C API" OFF)
1313
print_option_status (SOLOUD_C_API "Build C API")
1414

1515

16-
# TODO:
1716
option (SOLOUD_BACKEND_MINIAUDIO "Set to ON to include MiniAudio" ON)
18-
print_option_status (SOLOUD_WITH_MINIAUDIO "Build MiniAudio")
17+
print_option_status (SOLOUD_BACKEND_MINIAUDIO "Build MiniAudio")
1918

2019
option (SOLOUD_BUILD_DEMOS "Set to ON for building demos" OFF)
2120
print_option_status (SOLOUD_BUILD_DEMOS "Build demos")

0 commit comments

Comments
 (0)