Skip to content

Commit 92593df

Browse files
committed
Use wrapper file for Windows VST3 module compilation
Instead of adding compile flags to the SDK's module_win32.cpp directly, use a wrapper source file that sets up the necessary preprocessor definitions (NOMINMAX, WIN32_LEAN_AND_MEAN, _UNICODE, etc.) before including the SDK source. This ensures proper compilation environment when building outside the VST3 SDK's CMake context. https://claude.ai/code/session_01AY9chvBEmsCVjNZSUkNcbw
1 parent 1218b64 commit 92593df

File tree

2 files changed

+54
-10
lines changed

2 files changed

+54
-10
lines changed

CMakeLists.txt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,9 @@ if(PLUGINVAL_VST3_VALIDATOR)
138138
set_source_files_properties(${VST3_MODULE_MAC_FILE} PROPERTIES
139139
COMPILE_FLAGS "-fobjc-arc")
140140
elseif(WIN32)
141-
set(VST3_MODULE_WIN_FILE ${vst3sdk_SOURCE_DIR}/public.sdk/source/vst/hosting/module_win32.cpp)
142-
list(APPEND VST3ValidatorFiles ${VST3_MODULE_WIN_FILE})
143-
# Add Windows-specific compile flags for compatibility
144-
if(MSVC)
145-
set_source_files_properties(${VST3_MODULE_WIN_FILE} PROPERTIES
146-
COMPILE_FLAGS "/DNOMINMAX /DWIN32_LEAN_AND_MEAN /D_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING")
147-
else()
148-
set_source_files_properties(${VST3_MODULE_WIN_FILE} PROPERTIES
149-
COMPILE_DEFINITIONS "NOMINMAX;WIN32_LEAN_AND_MEAN;_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING")
150-
endif()
141+
# Use wrapper file that sets up preprocessor definitions before including SDK source
142+
list(APPEND VST3ValidatorFiles
143+
Source/vst3validator/module_win32_wrapper.cpp)
151144
endif()
152145

153146
target_sources(pluginval PRIVATE ${VST3ValidatorFiles})
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*==============================================================================
2+
3+
Copyright 2018 by Tracktion Corporation.
4+
For more information visit www.tracktion.com
5+
6+
You may also use this code under the terms of the GPL v3 (see
7+
www.gnu.org/licenses).
8+
9+
pluginval IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
10+
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
11+
DISCLAIMED.
12+
13+
==============================================================================*/
14+
15+
/**
16+
* Wrapper file for VST3 SDK module_win32.cpp
17+
* This wrapper ensures proper preprocessor setup before including the SDK source.
18+
*/
19+
20+
#if defined(_WIN32)
21+
22+
// Prevent Windows headers from defining min/max macros
23+
#ifndef NOMINMAX
24+
#define NOMINMAX
25+
#endif
26+
27+
// Reduce Windows header bloat
28+
#ifndef WIN32_LEAN_AND_MEAN
29+
#define WIN32_LEAN_AND_MEAN
30+
#endif
31+
32+
// Silence deprecation warning for experimental/filesystem
33+
#ifndef _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
34+
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
35+
#endif
36+
37+
// Ensure _UNICODE is defined for proper Windows API usage
38+
#ifndef _UNICODE
39+
#define _UNICODE
40+
#endif
41+
42+
#ifndef UNICODE
43+
#define UNICODE
44+
#endif
45+
46+
// Include the actual VST3 SDK module implementation
47+
// Note: The path is relative to this file's location, but the build system
48+
// sets up include directories so we can use the SDK path directly
49+
#include "public.sdk/source/vst/hosting/module_win32.cpp"
50+
51+
#endif // _WIN32

0 commit comments

Comments
 (0)