Skip to content

Commit 9795fbd

Browse files
committed
Fix Windows build: compile module_win32.cpp with C++17
The VST3 SDK's module_win32.cpp uses std::filesystem::path::generic_u8string() which returns std::u8string in C++20 but std::string in C++17. Since the SDK code expects std::string, we compile this specific file with /std:c++17. Also move _UNICODE and UNICODE definitions from target-level to file-level (only for module_win32.cpp) to avoid breaking JUCE's LV2/lilv code which uses ANSI Windows APIs. https://claude.ai/code/session_01AY9chvBEmsCVjNZSUkNcbw
1 parent ab21528 commit 9795fbd

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

CMakeLists.txt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,14 @@ if(PLUGINVAL_VST3_VALIDATOR)
141141
set_source_files_properties(${VST3_MODULE_MAC_FILE} PROPERTIES
142142
COMPILE_FLAGS "-fobjc-arc")
143143
elseif(WIN32)
144-
# Add module_win32.cpp directly - compile definitions are set at target level
145-
list(APPEND VST3ValidatorFiles
146-
${vst3sdk_SOURCE_DIR}/public.sdk/source/vst/hosting/module_win32.cpp)
144+
set(VST3_MODULE_WIN32_FILE ${vst3sdk_SOURCE_DIR}/public.sdk/source/vst/hosting/module_win32.cpp)
145+
list(APPEND VST3ValidatorFiles ${VST3_MODULE_WIN32_FILE})
146+
# module_win32.cpp requires C++17 (not C++20) because generic_u8string() returns
147+
# std::u8string in C++20 but std::string in C++17, and the SDK code expects std::string.
148+
# Also set UNICODE definitions only for this file to avoid affecting JUCE's LV2/lilv code.
149+
set_source_files_properties(${VST3_MODULE_WIN32_FILE} PROPERTIES
150+
COMPILE_FLAGS "/std:c++17"
151+
COMPILE_DEFINITIONS "NOMINMAX;WIN32_LEAN_AND_MEAN;_UNICODE;UNICODE")
147152
endif()
148153

149154
target_sources(pluginval PRIVATE ${VST3ValidatorFiles})
@@ -180,14 +185,13 @@ target_compile_definitions(pluginval PRIVATE
180185
VERSION="${CURRENT_VERSION}")
181186

182187
# Windows-specific compile definitions for VST3 SDK compatibility
188+
# Note: _UNICODE and UNICODE are NOT set here - they're set only for module_win32.cpp
189+
# to avoid breaking JUCE's LV2/lilv code which uses ANSI Windows APIs
183190
if(WIN32 AND PLUGINVAL_VST3_VALIDATOR)
184191
target_compile_definitions(pluginval PRIVATE
185192
NOMINMAX
186193
WIN32_LEAN_AND_MEAN
187-
_UNICODE
188-
UNICODE
189-
_CRT_SECURE_NO_WARNINGS
190-
_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING)
194+
_CRT_SECURE_NO_WARNINGS)
191195
endif()
192196

193197
if(MSVC AND NOT CMAKE_MSVC_RUNTIME_LIBRARY)

0 commit comments

Comments
 (0)