diff --git a/docs/config/README.md b/docs/config/README.md index ef6a871a..fcfab550 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -444,9 +444,10 @@ vicmd_symbol = "[V](bold green) " ## CMake -The `cmake` module shows the currently installed version of CMake if: +The `cmake` module shows the currently installed version of CMake if any of the following conditions are met: - The current directory contains a `CMakeLists.txt` file +- The current directory contains a `CMakeCache.txt` file ### Options diff --git a/src/modules/cmake.rs b/src/modules/cmake.rs index 3e15eb0c..e15e4186 100644 --- a/src/modules/cmake.rs +++ b/src/modules/cmake.rs @@ -11,7 +11,7 @@ use crate::utils; pub fn module<'a>(context: &'a Context) -> Option> { let is_cmake_project = context .try_begin_scan()? - .set_files(&["CMakeLists.txt"]) + .set_files(&["CMakeLists.txt", "CMakeCache.txt"]) .is_match(); if !is_cmake_project { @@ -81,4 +81,14 @@ mod tests { assert_eq!(expected, actual); dir.close() } + + #[test] + fn buildfolder_with_cmake_cache() -> io::Result<()> { + let dir = tempfile::tempdir()?; + File::create(dir.path().join("CMakeCache.txt"))?.sync_all()?; + let actual = ModuleRenderer::new("cmake").path(dir.path()).collect(); + let expected = Some(format!("via {} ", Color::Blue.bold().paint("喝 v3.17.3"))); + assert_eq!(expected, actual); + dir.close() + } }