FOLDER: Set the folder name. Use to organize targets in an IDE.Targets with no FOLDER property will appear as top level entities in IDEs like Visual Studio. Targets with the same FOLDER property value will appear next to each other in a folder of that name. To nest folders, use FOLDER values such as 'GUI/Dialogs' with '/' characters separating folder levels.
方法如下:
Add this to the top level CMakeLists.txt
#Use solution folders.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Then in some target add this to put the target in the Development folder.
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER Development)不过VcExpress因为不支持工程目录,所以FOLDER属性无效。
因为机器上同时安装了VC和VcExpress,CMake总是判断为Express版,所以FOLDER设置总是无效。
最终打开sln文件看到了头部的这行才找到问题原因:
# Visual C++ Express
然后在CMake源码中找到了Express版本检测代码:
this->ExpressEdition = cmSystemTools::ReadRegistryValue(
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\14.0\\Setup\\VC;"
"ProductDir", vc14Express, cmSystemTools::KeyWOW64_32);
删除该注册表项就不会被判为Express版了,FOLDER设置成功。
本文详细介绍了如何使用CMake的FOLDER属性来区分Visual Studio的不同版本,解决IDE版本误判导致的FOLDER设置无效的问题。通过在CMakeLists.txt文件中配置FOLDER属性,可以确保在Visual Studio中正确地组织和显示项目结构。
3003

被折叠的 条评论
为什么被折叠?



