Possible bug setting VS_SETTINGS "ExcludedFromBuild=true" for Wavefornt obj files.

Hi,

When I include a Wavefront obj file to my project and generate a Visual Studio solution, the generator labels the file as an obj file meant for the c++ linker. See the following from my .vcxproj file.

This causes an error when building and linking. To get around this I thought to set item metadata property ExcludedFromBuild=true. See below for the code.

file(GLOB_RECURSE RESOURCES
“${CMAKE_SOURCE_DIR}/rsc/.glsl"
"${CMAKE_SOURCE_DIR}/rsc/
.jpeg”
“${CMAKE_SOURCE_DIR}/rsc/.png"
)
file(GLOB_RECURSE RESOURCES_OBJ
"${CMAKE_SOURCE_DIR}/rsc/
.obj”
)
target_sources(${CMAKE_PROJECT_NAME} PUBLIC ${RESOURCES} ${RESOURCES_OBJ})
set_property(SOURCE ${RESOURCES_OBJ} PROPERTY VS_SETTINGS “ExcludedFromBuild=true”)

The set_property command does not do anything though. If I were to replace ${RESOURCES_OBJ} with ${RESOURCES} then those image/glsl files will be excluded from the build, but there is no need to set this property for these files because Visual Studio already excludes files with these extensions from the build.

I tried this with CMake version 3.19.2.

Thanks.

You could try setting the .obj files’ HEADER_FILE_ONLY property to TRUE. I haven’t tested it, but it might help.

That works! I am now able to add Wavefront obj files without any linker errors. Thank you.