Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ jobs:
- name: Build
env:
CMAKE_PREFIX_PATH: ${{ env.QT6_PREFIX }}
run: cargo build --verbose

run: |
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DRUST_VERBOSE=ON
cmake --build build

- name: Test
run: cargo test --verbose
run: ctest --test-dir build --output-on-failure
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
**/cmake_install.cmake
**/Makefile
**/compile_commands.json
**/Testing/
output.txt
*.code-workspace
42 changes: 41 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,44 @@ project(tlockr_qt LANGUAGES CXX)

add_subdirectory(cpp)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(CARGO_MANIFEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml)
set(CARGO_TARGET_DIR ${CMAKE_CURRENT_BINARY_DIR}/target)

option(RUST_VERBOSE "Enable verbose output for Cargo build and test" OFF)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CARGO_PROFILE "")
set(CARGO_OUTPUT ${CARGO_TARGET_DIR}/debug/tlockr)
else()
set(CARGO_PROFILE "--release")
set(CARGO_OUTPUT ${CARGO_TARGET_DIR}/release/tlockr)
endif()

if(RUST_VERBOSE)
set(CARGO_VERBOSE "--verbose")
else()
set(CARGO_VERBOSE "")
endif()

add_custom_command(
OUTPUT ${CARGO_OUTPUT}
COMMAND cargo build ${CARGO_PROFILE} ${CARGO_VERBOSE} --manifest-path ${CARGO_MANIFEST_PATH} --target-dir ${CARGO_TARGET_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Building tlockr with Cargo (${CMAKE_BUILD_TYPE})"
DEPENDS tlockr_qt
)

add_custom_target(tlockr ALL
DEPENDS ${CARGO_OUTPUT}
)

add_test(NAME rust_tests
COMMAND cargo test ${CARGO_VERBOSE} --manifest-path ${CARGO_MANIFEST_PATH} --target-dir ${CARGO_TARGET_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

set_tests_properties(rust_tests PROPERTIES
DEPENDS tlockr
)
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ You can then proceed to the building step. You will need:

```sh
$ cd tlockr
$ cargo build --release
$ mkdir build && cd build
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ make -j${nproc}
```

The compiled binary can be found at `target/release/tlockr`.
The compiled binary can be found at `build/target/release/tlockr`.

## Themes

Expand Down
10 changes: 4 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
*/

use std::env;
use std::path::PathBuf;

fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());

let dst = cmake::Config::new(".").out_dir(&out_dir).build();

println!("cargo:rustc-link-search=native={}/lib", dst.display());
println!(
"cargo:rustc-link-search=native={}/build/cpp",
env!("CARGO_MANIFEST_DIR")
);
println!("cargo:rustc-link-lib=static=tlockr_qt");

println!("cargo:rustc-link-lib=Qt6Quick");
Expand Down