Visual Studio 17 2022 Win64: /FI with space before filepath mis-generates the vcxproj file
The working syntax
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<COMPILE_LANGUAGE:C,CXX>:/FI"js-confdefs.h">
)
or
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<COMPILE_LANGUAGE:C,CXX>:/FIjs-confdefs.h>
)
puts the force include flag into the <ForcedIncludeFiles>"js-confdefs.h"</ForcedIncludeFiles>
XML node as expected.
However
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<COMPILE_LANGUAGE:C,CXX>:/FI js-confdefs.h>
)
or
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<COMPILE_LANGUAGE:C,CXX>:/FI "js-confdefs.h">
)
Adds "js-confdefs.h" to the xml node.
<AdditionalOptions>%(AdditionalOptions) /bigobj /EHac /Zo /Zc:__cplusplus js-confdefs.h</AdditionalOptions>
And inserts an empty <ForcedIncludeFiles></ForcedIncludeFiles>
node.
The MSVC documentation for /FI clearly indicates that this flag supports a space: https://docs.microsoft.com/en-us/cpp/build/reference/fi-name-forced-include-file
As a result, the CMake handling for target_compile_options()
should be adjusted to allow a space between /FI
and the file in question.