# Special action for special source files

**URL:** https://discourse.cmake.org/t/special-action-for-special-source-files/3267
**Category:** Code
**Created:** [May 5, 2021, 11:01am UTC](https://discourse.cmake.org/t/special-action-for-special-source-files/3267 "2021-05-05T11:01:09Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![KUGA2](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kuga2/32/4968_2.png) [@KUGA2](https://discourse.cmake.org/u/KUGA2)
#### Post date: [May 5, 2021, 11:01am UTC](https://discourse.cmake.org/t/special-action-for-special-source-files/3267/1 "2021-05-05T11:01:10Z")

</div>

I will try to explain my problem abstractly:

I have a huge project, that compiles a lot of cpp files. Some of them do need special treatment after the build.  
(My case: the need to be installed to a special folder and doxygen generation over these files)  
They can be distinguished by individual properties  
(My case: special folder name)

How do i do this?

I am thinking of a hook in add\_library (etc.), that run (pseudo code):

```
foreach(SOURCE in SOURCES)
    if(hasProperty(FILE))
       doSomething(FILE)

```

I guess i have to do the Hook myself by overloading add\_library(). Am I correct? is there another way to do this? Maybe:

```
foreach(TARGET)
   SOURCES = get_properties(TARGET SOURCES)
   foreach(SOURCE in SOURCES)
      ...

```

(Using this [CMake List of all Project Targets - #5 by developer](https://discourse.cmake.org/t/cmake-list-of-all-project-targets/1077/5))

Or is this like bad practice and I should do:

```
target_do_special(TARGET)

```

for each and every target?

---

<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: [May 5, 2021, 1:54pm UTC](https://discourse.cmake.org/t/special-action-for-special-source-files/3267/2 "2021-05-05T13:54:36Z")

</div>

You can either have a `doxygen_wrap_sources(target)` call or do tracking via some `myproj_add_library` that does things at that time. Which is better depends on the circumstances. Personally, I would think `doxygen_wrap_sources` works better here especially now that sources can be added after a target is declared (using `target_sources`).
