foxygit / Torlinkc Log in
commit b46304c44ac03d4914b57462e61af23775a2e0ec
Author:     MrJensK <jens.se@icloud.com>
AuthorDate: Sun Aug 23 11:57:17 2026 +0200
Commit:     MrJensK <jens.se@icloud.com>
CommitDate: Sun Aug 23 11:57:17 2026 +0200

    Add cmake --install support

    Installs the TUI as "torlinkc" (the build-tree target name stays
    torlinkc_tui) and the console harness as torlinkc_core_cli, both to
    CMAKE_INSTALL_PREFIX/bin (/usr/local/bin by default on Linux). Verified
    against a scratch prefix: both installed binaries run correctly.

    Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---
 README.md                    | 15 +++++++++++++++
 apps/core_cli/CMakeLists.txt |  2 ++
 apps/tui/CMakeLists.txt      |  6 ++++++
 3 files changed, 23 insertions(+)

diff --git a/README.md b/README.md
index 0010278..0e932e5 100644
--- a/README.md
+++ b/README.md
@@ -65,6 +65,19 @@ This builds three programs plus the test suite:
   smoke tests
 - `build/tests/torlinkc_tests` — the doctest suite

+### Install (optional)
+
+```sh
+sudo cmake --install build
+```
+
+Installs the TUI as `torlinkc` and the console harness as
+`torlinkc_core_cli` into `/usr/local/bin` (CMake's default
+`CMAKE_INSTALL_PREFIX` on Linux), which is on `PATH` for most
+distros -- so `torlinkc` works from anywhere afterward. For a user-local
+install that needs no `sudo`, point it at a prefix already on your
+`PATH` instead, e.g. `cmake --install build --prefix ~/.local`.
+
 ### Test

 ```sh
@@ -77,6 +90,8 @@ cd build && ctest --output-on-failure

 ```sh
 ./build/apps/tui/torlinkc_tui
+# or, if installed (see above):
+torlinkc
 ```

 Opens straight to a search screen. Type a query and press Enter to search
diff --git a/apps/core_cli/CMakeLists.txt b/apps/core_cli/CMakeLists.txt
index 7026562..d987fe3 100644
--- a/apps/core_cli/CMakeLists.txt
+++ b/apps/core_cli/CMakeLists.txt
@@ -1,2 +1,4 @@
 add_executable(torlinkc_core_cli main.cpp)
 target_link_libraries(torlinkc_core_cli PRIVATE torlinkc_core)
+
+install(TARGETS torlinkc_core_cli RUNTIME DESTINATION bin)
diff --git a/apps/tui/CMakeLists.txt b/apps/tui/CMakeLists.txt
index d04ef5d..1569ea3 100644
--- a/apps/tui/CMakeLists.txt
+++ b/apps/tui/CMakeLists.txt
@@ -1,2 +1,8 @@
 add_executable(torlinkc_tui main.cpp)
 target_link_libraries(torlinkc_tui PRIVATE torlinkc_ui)
+
+# Installed as "torlinkc" (the target/build-tree name stays torlinkc_tui,
+# unchanged, so nothing else in the build has to know about the rename).
+# install(TARGETS) has no RENAME option -- installing the built file
+# directly via its generator expression is the standard way to rename it.
+install(PROGRAMS $<TARGET_FILE:torlinkc_tui> DESTINATION bin RENAME torlinkc)