feat(cmake): Add CMakeCache.txt detection to CMake module (#1795)

* Add CMakeCache.txt to cmake module

* Remove trailing whitespace

* Apply fixes by @andytom

* Add CMakeCache.txt to docs

* Revert documentation for languages other than en
This commit is contained in:
Christoph Schlosser 2020-10-25 19:10:42 +01:00 committed by GitHub
parent 9d5770544e
commit 89fc93d1f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -444,9 +444,10 @@ vicmd_symbol = "[V](bold green) "
## CMake ## 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 `CMakeLists.txt` file
- The current directory contains a `CMakeCache.txt` file
### Options ### Options

View File

@ -11,7 +11,7 @@ use crate::utils;
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
let is_cmake_project = context let is_cmake_project = context
.try_begin_scan()? .try_begin_scan()?
.set_files(&["CMakeLists.txt"]) .set_files(&["CMakeLists.txt", "CMakeCache.txt"])
.is_match(); .is_match();
if !is_cmake_project { if !is_cmake_project {
@ -81,4 +81,14 @@ mod tests {
assert_eq!(expected, actual); assert_eq!(expected, actual);
dir.close() 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()
}
} }