Setting compile flags in a way to support both single- and multi-configuration generators can be tricky, as CMake executes if statements and many other constructs at configure time, not at build/install time.
This means that the following is a CMake antipattern:
if(CMAKE_BUILD_TYPE STREQUAL Release)
target_compile_definitions(libcustomer PRIVATE RUN_FAST)
endif()
Instead, generator expressions are the proper way to achieve the same goal, as they're being processed at a later time. Let's see an example of their use in practice. Assuming you want to add a preprocessor definition just for your Release configuration, you could write the following:
target_compile_definitions(libcustomer PRIVATE "$<$<CONFIG:Release>:RUN_FAST>")
This will resolve to RUN_FAST only when building that one selected configuration. For others, it will resolve to an empty value. It works for both single- and multi-configuration generators. That's not...