0

In my code, I set the compile option for a specific target such as

target_compile_options(lib_one PRIVATE "/bigobj")

I initially configure the project to build in Release mode by

-DCMAKE_BUILD_TYPE=Release

However, when I changed the build mode interactively in Visual Studio to Debug, the compile options set for lib_one is lost because it is not transferred automatically. Is there a command in cmake that serve this purpose?

kstn
  • 537
  • 4
  • 14
  • You could use [generator expressions](https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html) for add build type-specific flags. [that answer](https://stackoverflow.com/a/33831145/3440745) contains example of generator expressions for `add_compile_options` command. – Tsyvarev Nov 29 '22 at 12:12
  • Yes, I also found it here: https://stackoverflow.com/questions/23995019/what-is-the-modern-method-for-setting-general-compile-flags-in-cmake – kstn Nov 29 '22 at 12:13

0 Answers0