# Why toplevel Cmake can't clean custom project add by ExternProject\_add

**URL:** <https://discourse.cmake.org/t/why-toplevel-cmake-cant-clean-custom-project-add-by-externproject-add/824>\
**Category:** Code\
**Tags:** gen:makefiles\
**Created:** [March 20, 2020, 3:14am UTC](https://discourse.cmake.org/t/why-toplevel-cmake-cant-clean-custom-project-add-by-externproject-add/824 "2020-03-20T03:14:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lijianzhong](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/a5b964/32.png) [@lijianzhong](https://discourse.cmake.org/u/lijianzhong)\
**Post date:** [March 20, 2020, 3:14am UTC](https://discourse.cmake.org/t/why-toplevel-cmake-cant-clean-custom-project-add-by-externproject-add/824/1 "2020-03-20T03:14:37Z")

</div>

[Cmake 3.16.4] I use ExternalProject\_Add command to add a custom project. The generate make file can build and link correctly. But when I use make clean to clean the project , the custom project cant not be cleaned.  
The command is as follow:  
include (ExternalProject)  
ExternalProject\_Add(ivptest  
PREFIX ivptest  
SOURCE\_DIR “${CMAKE\_CURRENT\_LIST\_DIR}/ivptest”  
CMAKE\_ARGS -DCMAKE\_TOOLCHAIN\_FILE=${CMAKE\_SOURCE\_DIR}/cmake/Platform/xtensa-vq6p2.toolchain.cmake  
INSTALL\_COMMAND “”  
)

It cant work correct and make correctly, the log is as follow:  
[12%] Creating directories for ‘ivptest’  
[25%] No download step for ‘ivptest’  
[37%] No patch step for ‘ivptest’  
[50%] No update step for ‘ivptest’  
[62%] Performing configure step for ‘ivptest’  
– The C compiler identification is GNU 4.2.0  
– The CXX compiler identification is GNU 4.2.0  
– Check for working C compiler: /home/l00175099/code/algorithms/Multimedia/cmake/Platform/…/…/Prebuilt/xtensa/XtDevTools/install/tools/RH-2017.4-linux/XtensaTools/bin/xt-xcc  
– Check for working C compiler: /home/l00175099/code/algorithms/Multimedia/cmake/Platform/…/…/Prebuilt/xtensa/XtDevTools/install/tools/RH-2017.4-linux/XtensaTools/bin/xt-xcc – works  
– Detecting C compiler ABI info  
– Detecting C compiler ABI info - done  
– Detecting C compile features  
– Detecting C compile features - done  
– Check for working CXX compiler: /home/l00175099/code/algorithms/Multimedia/cmake/Platform/…/…/Prebuilt/xtensa/XtDevTools/install/tools/RH-2017.4-linux/XtensaTools/bin/xt-xc++  
– Check for working CXX compiler: /home/l00175099/code/algorithms/Multimedia/cmake/Platform/…/…/Prebuilt/xtensa/XtDevTools/install/tools/RH-2017.4-linux/XtensaTools/bin/xt-xc++ – works  
– Detecting CXX compiler ABI info  
– Detecting CXX compiler ABI info - done  
– Detecting CXX compile features  
– Detecting CXX compile features - done  
– Configuring done  
– Generating done  
– Build files have been written to: /home/l00175099/code/algorithms/Multimedia/build/ivptest/src/ivptest-build  
[75%] Performing build step for ‘ivptest’  
Scanning dependencies of target msg  
[25%] Building C object CMakeFiles/msg.dir/message.c.obj  
[50%] Linking C static library libmsg.a  
[50%] Built target msg  
Scanning dependencies of target ivp\_test  
[75%] Building C object CMakeFiles/ivp\_test.dir/main.c.obj  
[100%] Linking C executable ivp\_test  
[100%] Built target ivp\_test  
[87%] No install step for ‘ivptest’  
[100%] Completed ‘ivptest’  
[100%] Built target ivptest

The make clean output no log.  
Then i compile again, the custom project doesn’t compile object and library correctly:  
[12%] Creating directories for ‘ivptest’  
[25%] No download step for ‘ivptest’  
[37%] No patch step for ‘ivptest’  
[50%] No update step for ‘ivptest’  
[62%] Performing configure step for ‘ivptest’  
– Configuring done  
– Generating done  
– Build files have been written to: /home/l00175099/code/algorithms/Multimedia/build/ivptest/src/ivptest-build  
[75%] Performing build step for ‘ivptest’  
[50%] Built target msg  
[100%] Built target ivp\_test  
[87%] No install step for ‘ivptest’  
[100%] Completed ‘ivptest’  
[100%] Built target ivptest

the CMakeFiles/ivptest.dir/cmake\_clean.cmake 's content is as flow:  
file(REMOVE\_RECURSE  
“CMakeFiles/ivptest”  
“CMakeFiles/ivptest-complete”  
“ivptest/src/ivptest-stamp/ivptest-build”  
“ivptest/src/ivptest-stamp/ivptest-configure”  
“ivptest/src/ivptest-stamp/ivptest-download”  
“ivptest/src/ivptest-stamp/ivptest-install”  
“ivptest/src/ivptest-stamp/ivptest-mkdir”  
“ivptest/src/ivptest-stamp/ivptest-patch”  
“ivptest/src/ivptest-stamp/ivptest-update”  
)

---

<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:** [March 20, 2020, 12:47pm UTC](https://discourse.cmake.org/t/why-toplevel-cmake-cant-clean-custom-project-add-by-externproject-add/824/2 "2020-03-20T12:47:04Z")

</div>

It looks like `ExternalProject` could add some `ADDITIONAL_CLEAN_FILES` properties to the associated targets (or maybe directory; not sure which would be better here). Could you please file a new issue?

---

<div class="post-metadata">

**Author:** ![lijianzhong](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/a5b964/32.png) [@lijianzhong](https://discourse.cmake.org/u/lijianzhong)\
**Post date:** [March 23, 2020, 12:35am UTC](https://discourse.cmake.org/t/why-toplevel-cmake-cant-clean-custom-project-add-by-externproject-add/824/3 "2020-03-23T00:35:08Z")

</div>

I don’t; know what you means fire a new issue.  
For my understanding, the clean should remove totally the binary directory that ExternalProject\_Add introduced.

---

<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:** [March 23, 2020, 11:31am UTC](https://discourse.cmake.org/t/why-toplevel-cmake-cant-clean-custom-project-add-by-externproject-add/824/4 "2020-03-23T11:31:23Z")

</div>

“File”, not “fire” 🙂 . [https://gitlab.kitware.com/cmake/cmake/issues](https://gitlab.kitware.com/cmake/cmake/issues)
