clion中cpp文件显示This file does not belong to any project ,code insight features might not work【解决方案】

简介: clion中cpp文件显示This file does not belong to any project ,code insight features might not work【解决方案】

问题


cpp文件上方出现

This file does not belong to any project ,code insight features might not work properly,并且main函数无法运行

1.png


解决方案


第一步:修改下CMakeLists.txt文件


为了以后方便,我们先修改下CMakeLists.txt文件

1.png

CMakeLists.txt:


# 遍历项目根目录下所有的 .cpp 文件
file (GLOB_RECURSE files *.cpp)
foreach (file ${files})
    string(REGEX REPLACE ".+/(.+)\\..*" "\\1" exe ${file})
    add_executable (${exe} ${file})
    message (\ \ \ \ --\ src/${exe}.cpp\ will\ be\ compiled\ to\ bin/${exe})
endforeach ()

这样以后就不用再修改CMakeLists.txt这个文件了。


第二步:重新加载下项目


2.png

加载完成后main函数就可以执行了,及时cpp文件上方还有那句话也不影响。

3.png



以上就是clion中cpp文件显示This file does not belong to any project ,code insight features might not work【解决方案】的全部内容

相关文章
|
11月前
|
C++
Clion配置单个project下可以运行多个CPP文件的main函数
Clion配置单个project下可以运行多个CPP文件的main函数
733 0
|
NoSQL IDE Java
使用CLion调试Redis源码的超详细步骤
因为我本人主要是写Java的,有强烈的IDE依赖症,不喜欢使用文本编辑器或者命令行这样的工具,所以选择使用CLion搭建一个IDE环境来辅助 Redis 源码阅读。
492 1
使用CLion调试Redis源码的超详细步骤
|
编解码 缓存 NoSQL
用Ubuntu18与clion调试FFmpeg
用Ubuntu18与clion调试FFmpeg
253 0
|
弹性计算 并行计算 NoSQL
Clion配置远程CUDA调试环境
在阿里云GPU ECS实例上搭建Remote CUDA开发环境,使用Jetbrains Clion作为Develop IDE。
724 1
Clion配置远程CUDA调试环境
|
Java 开发工具 数据安全/隐私保护
在Clion上调试LeetCode代码
在Clion上调试LeetCode代码
932 0
在Clion上调试LeetCode代码
|
关系型数据库 MySQL 开发工具
Mac下使用Clion调试MySQL版本5.7源码
Mac下使用Clion调试MySQL版本5.7源码
165 0
Mac下使用Clion调试MySQL版本5.7源码
|
关系型数据库 C++ iOS开发
【从入门到放弃-MySQL】CLion调试MySQL8.0源码
前言 想对的MySQL底层实现做一些了解,奈何没有用过C++不知道怎么调试一个大型项目,一日和大神交流时大神扔给我了一份《XCode调试MySQL8秘籍》。于是在几经波折(主要是因为菜)之后终于打开了MySQL的调试大门。
3149 0
|
7月前
|
C++
解决方案-CMake error: error in configuration process, project files may be invalid(Windows&VS可参考)
解决方案-CMake error: error in configuration process, project files may be invalid(Windows&VS可参考)
983 0
|
数据安全/隐私保护
导入 Walle 时报:ERROR: A problem occurred configuring project ':app'.
导入 Walle 时报:ERROR: A problem occurred configuring project ':app'.
导入 Walle 时报:ERROR: A problem occurred configuring project ':app'.
codeblocks中出现#error This file requires compiler and library support for the错误时的解决方案
codeblocks中出现#error This file requires compiler and library support for the错误时的解决方案
466 0
codeblocks中出现#error This file requires compiler and library support for the错误时的解决方案