I want to know how I can set the following Visual Studio build options in my CMakeLists.txt.
Struct Member Alignment = 1 Byte (/Zp1) which is set in the Project properties (Configuration Properties -> C/C++ -> Code Generation).
I want to know how I can set the following Visual Studio build options in my CMakeLists.txt.
Struct Member Alignment = 1 Byte (/Zp1) which is set in the Project properties (Configuration Properties -> C/C++ -> Code Generation).
You can set this MSVC-specific compilation flag (/Zp
) as a CMake compile option:
add_library(MyLib SHARED ${MY_SOURCES})
if(MSVC)
# Add the /Zp flag for the MyLib library target.
target_compile_options(MyLib PRIVATE /Zp1)
endif()