# Little question about command "target\_sources(FILE\_SET)"

**URL:** https://discourse.cmake.org/t/little-question-about-command-target-sources-file-set/11273
**Category:** Development
**Tags:** os:linux, gen:makefiles
**Created:** [July 18, 2024, 6:12am UTC](https://discourse.cmake.org/t/little-question-about-command-target-sources-file-set/11273 "2024-07-18T06:12:47Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Li\_Haohuang](https://discourse.cmake.org/user_avatar/discourse.cmake.org/li_haohuang/32/4771_2.png) [@Li\_Haohuang](https://discourse.cmake.org/u/Li_Haohuang)
#### Post date: [July 18, 2024, 6:12am UTC](https://discourse.cmake.org/t/little-question-about-command-target-sources-file-set/11273/1 "2024-07-18T06:12:47Z")

</div>

I’m using the command target\_sources(FILE\_SET) to add header files for my project.

I find the following description in official documentation.

 ![image](https://discourse.cmake.org/uploads/default/original/2X/9/9f6a4747ab4c76b72e4db7fb0f44cca6ae5f5229.png)

In my native opinion, I thouht if relative paths are specified, they are considered relative to BASE\_DIRS specified dirs, cmake will compose/resolve the final absolute paths of each file items for me. So I don’t understand the meaning of BASE\_DIRS parameter in target\_sources() command. Can I think this argument is only used for checking the rightness of file items specified by FILES argument?

May anybody help me understand this question? Thank you very much!  
**BEST WISHES!**

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 18, 2024, 11:58am UTC](https://discourse.cmake.org/t/little-question-about-command-target-sources-file-set/11273/2 "2024-07-18T11:58:24Z")

</div>

The purpose of `BASE_DIRS` is to be able to compute a “root” for each file listed. Without this information, when installing the headers, it is ambiguous how many path components should be preserved upon installation. Should `/path/to/some/header/under/directories/header.h` be installed to `<include>/header.h`, `<include>/directories/header.h`, `<include>/under/directories/header.h`, or any other possibility? That is what `BASE_DIRS` is for (and why each file must live under exactly one such `BASE_DIRS` entry).

---

<div class="post-metadata">

### Author: ![Li\_Haohuang](https://discourse.cmake.org/user_avatar/discourse.cmake.org/li_haohuang/32/4771_2.png) [@Li\_Haohuang](https://discourse.cmake.org/u/Li_Haohuang)
#### Post date: [July 19, 2024, 2:41am UTC](https://discourse.cmake.org/t/little-question-about-command-target-sources-file-set/11273/3 "2024-07-19T02:41:47Z")

</div>

**THANK YOU VERY MUCH!** 🥰

I’ve tried it in my project, changing the value of BASE\_DIRS’ value, then executing _install/cpack_ command, get the result what you explained above.

After all, I have another question about the explanation, I didn’t see similar description in official documentation

 ![image](https://discourse.cmake.org/uploads/default/original/2X/0/0566defbc6213a50b1de0fd97f97d0240e8036f4.png)  
Can you tell me where to find the more detailed description about each parameter specified in each cmake command? SO that I wouldn’t have to issue such post to waste your time to solve this kind of questions. 🤔

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 19, 2024, 5:44pm UTC](https://discourse.cmake.org/t/little-question-about-command-target-sources-file-set/11273/4 "2024-07-19T17:44:22Z")

</div>

That would be the docs you have. If you have suggestions to make it clearer, the docs could always use improvement.

Alternatively, a step of the tutorial could explain this better in prose where it is used (and we should add an example if we don’t already have one).

---

<div class="post-metadata">

### Author: ![Li\_Haohuang](https://discourse.cmake.org/user_avatar/discourse.cmake.org/li_haohuang/32/4771_2.png) [@Li\_Haohuang](https://discourse.cmake.org/u/Li_Haohuang)
#### Post date: [July 20, 2024, 7:13am UTC](https://discourse.cmake.org/t/little-question-about-command-target-sources-file-set/11273/5 "2024-07-20T07:13:34Z")

</div>

Thanks!

I agree with you, an example is much better than tedious prose style!

I have no other questions, thank you for your support!

best wishes!

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 20, 2024, 12:40pm UTC](https://discourse.cmake.org/t/little-question-about-command-target-sources-file-set/11273/6 "2024-07-20T12:40:47Z")

</div>

Issue filed: [https://gitlab.kitware.com/cmake/cmake/-/issues/26153](https://gitlab.kitware.com/cmake/cmake/-/issues/26153)
