# Proper way to craft a CMakeLists.txt whose (only) output is a Bash script?

**URL:** https://discourse.cmake.org/t/proper-way-to-craft-a-cmakelists-txt-whose-only-output-is-a-bash-script/13439
**Category:** Code
**Created:** [January 20, 2025, 5:53pm UTC](https://discourse.cmake.org/t/proper-way-to-craft-a-cmakelists-txt-whose-only-output-is-a-bash-script/13439 "2025-01-20T17:53:12Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![Dennis\_Ferron](https://discourse.cmake.org/user_avatar/discourse.cmake.org/dennis_ferron/32/2953_2.png) [@Dennis\_Ferron](https://discourse.cmake.org/u/Dennis_Ferron)
#### Post date: [January 27, 2025, 4:37am UTC](https://discourse.cmake.org/t/proper-way-to-craft-a-cmakelists-txt-whose-only-output-is-a-bash-script/13439/3 "2025-01-27T04:37:32Z")

</div>

> [@Angew](#):
>
> Can you please clarify when & how you want the script to be _executed?_

What I want is to be able to execute the script from the Run/Debug menu in CLion (as if it were an EXE generated by add\_executable). As a custom target, it does show up in CLion’s drop down of targets, but CLion won’t run non-executable targets, such as scripts:

[https://youtrack.jetbrains.com/issue/CPP-5831](https://youtrack.jetbrains.com/issue/CPP-5831)

However (and as I commented on that issue), I did find a work-around. Since I have Msys2 installed, I can specify msys2.exe as the Executable for CLion to run, and the script as an argument.

One thing this has made me realize is that although the script has a runtime dependency on build outputs, it doesn’t actually have a build dependency on it. In fact, the .sh file can be (and is) written during the configuration step. To my understanding, CMake doesn’t really have a way to express purely runtime dependencies:

> [@Expressing runtime dependencies in CMake](https://discourse.cmake.org/t/expressing-runtime-dependencies-in-cmake/2235):
>
> Hi all, I am working on a project making excessive use of run-time library loading, i.e. dlopen()/LoadLibrary(). This means that if target B uses library A, it needs: at compile time: the include directories of A at link time: nothing at load time: nothing at run time: the shared library A to be present Currently I do the following: add\_library(A.SharedLib SHARED …) add\_library(A INTERFACE) target\_include\_directories(A INTERFACE path/to/A/includes) add\_dependencies(A A.SharedLib) # mak…

…but that’s moot in this case as the script doesn’t take any build-time time. (What does get built at build time is custom commands used to compile the Java code for the grammar, which the .sh script then has a runtime dependency on.)

---

_[View the full topic](https://discourse.cmake.org/t/proper-way-to-craft-a-cmakelists-txt-whose-only-output-is-a-bash-script/13439)._
