2

我想知道如何在我的 CMakeLists.txt 中设置以下 Visual Studio 构建选项。

Struct Member Alignment = 1 Byte (/Zp1),在项目属性(配置属性 -> C/C++ -> 代码生成)中设置。

4

1 回答 1

0

您可以将此特定于 MSVC 的编译标志 ( /Zp) 设置为 CMake编译选项

add_library(MyLib SHARED ${MY_SOURCES})

if(MSVC)
    # Add the /Zp flag for the MyLib library target.
    target_compile_options(MyLib PRIVATE /Zp1)
endif()
于 2020-02-12T13:11:06.493 回答