Consider a target with compile definitions like this
target_compile_definitions(myapp PRIVATE
TESTCASE_BUILDDIR="${CMAKE_BINARY_DIR}/foo%2bar"))
This works fine on Linux, but on Windows there will be errors. For example, MSVC’s cl.exe yields “cl : Command line error D8038 : invalid argument”.
According to MS docs at /D (Preprocessor Definitions) | Microsoft Docs percent sign should be written as doubled percent sign when passing it to the compiler with -D.
A more thorough explanation of the issue can be found in this blog post: Percent-sign in preprocessor definition breaks CMake Visual Studio generator
Given that target_compile_definitions already does some escaping, should it also take care of doubling the percent sign on Windows?