如何使Clion与子目录一起工作

发布于 2025-01-28 13:39:45 字数 933 浏览 4 评论 0 原文

我目前是一个学生,需要学习C。我正在使用Clion在Debian虚拟机上工作。

为了更好地管理我的作业,我创建了一个GitHub存储库来同步和存储所有C分配。因此,我在GIT中有一个项目,其中包含每个作业的子目录。所有任务彼此独立。

我目前的项目结构看起来像这样。

project
   assignment 1
      main.c
      some.c
      some.h
      Makefile
      ...
   assignment 2
      main.c
      some.c
      some.h
      Makefile
      ...
   assignment 3
      main.c
      some.c
      some.h
      Makefile
      ...
   ...

但是,我无法启动任何主要文件。我在Clion之前使用了VisualStudio代码,不得不创建那些Makefiles以使我的程序运行。我仍然可以使用CLION中的终端使用Make-Command并从那里启动程序,但我希望它们在Crion中正常工作。

我读到Clion使用cmakelist.txt-files,但我对它们不熟悉。我尝试使用源文件顶部的蓝色提示符自动创建它,但是在此之后弹出的窗口都有每个文件夹,并且(几乎)检查了每个文件。我认为这是错误的(我怀疑Clion认为每个目录和每个文件都是一个大型项目的一部分)

我必须如何设置clion/cmakelist.txt才能像我想要的那样工作?子目录是否需要自己的cmakelist.txt?甚至有可能在同一项目中的子目录中具有完全独立的程序吗?

I'm currently a student and need to learn C. I'm working on a Debian Virtual Machine using CLion.

To manage my assignments better, I created a github repository to synchronize and store all my C assignments. So I have one project in git containing sub-directories for every assignment I have to do. All assignments are independent of each other.

My current project structure looks like this.

project
   assignment 1
      main.c
      some.c
      some.h
      Makefile
      ...
   assignment 2
      main.c
      some.c
      some.h
      Makefile
      ...
   assignment 3
      main.c
      some.c
      some.h
      Makefile
      ...
   ...

However I can not start any of the main.c files. I used VisualStudio Code before CLion and had to create those makefiles to make my programs run. I can still use the terminal in CLion to use the make-command and start the programs from there but I'd like for them to work properly in CLion.

I read that CLion uses CMakeList.txt-files but I'm not familiar with them. I tried to auto-create it using the blue prompt at the top of a source file but the window that pops up after that has every folder and (almost) every file checked. I think this is wrong (I suspect CLion thinks every directory and every file is part of one large project)

CLion create CMakeList.txt

How do I have to set up CLion/CMakeList.txt to work like I want? Does ever sub-directory needs it's own CMakeList.txt? Is it even possible to have completely independent programs in sub-directories within the same project?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文