I have a project that builds several executables and also installs them. For the executables the relevant CMake code is:
add_executable(foo "foo.cpp")
add_executable(bar "bar.cpp;qux.cpp")
install(TARGETS foo bar "/usr/bin")
Then I create a .deb package and when it installs I can run foo
and bar
from the command line. I want to do something like this:
add_executable(foo "foo.cpp")
add_executable(bar "bar.cpp;qux.cpp")
add_script(hello "hello.sh")
install(TARGETS foo bar hello)
...so that hello
is executable from the command line. But there isn't actually a CMake command called add_script
. How can I achieve this?
You can use
which will automatically make your script executable. See the docs for install(FILES):