2

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).

Kevin
  • 16,549
  • 8
  • 60
  • 74

1 Answers1

0

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()
Kevin
  • 16,549
  • 8
  • 60
  • 74