CMake: How to add .def file to Visual Studio proje

2019-07-18 13:42发布

问题:

How to add .def file to Visual Studio project filters (*.filters file)? Visual Studio consumes .def file.

CMake code:

set(a_src a.cpp a.def)
add_library(a SHARED ${a_src})

In solution and then in project there is no a.def file in filters, only a.cpp. But CMake generates a rule for .def file (/DEF:a.def option to linker).

Is there any way to show .def files in the project filters (a.filters file near the project)?

回答1:

This is a CMake bug. It is reported in their tracker at http://www.cmake.org/Bug/view.php?id=15313