Merge topic 'file-size'

12b471e828 file: add SIZE option

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2639
This commit is contained in:
Brad King
2018-11-28 14:05:04 +00:00
committed by Kitware Robot
9 changed files with 69 additions and 0 deletions
+2
View File
@@ -36,6 +36,8 @@ run_cmake(READ_ELF)
run_cmake(GLOB)
run_cmake(GLOB_RECURSE)
run_cmake(GLOB_RECURSE-noexp-FOLLOW_SYMLINKS)
run_cmake(SIZE)
run_cmake(SIZE-error-does-not-exist)
# tests are valid both for GLOB and GLOB_RECURSE
run_cmake(GLOB-sort-dedup)
@@ -0,0 +1 @@
1
@@ -0,0 +1,5 @@
^CMake Error at SIZE-error-does-not-exist.cmake:[0-9]+ \(file\):
file SIZE requested of path that is not readable
/a/file/that/does-not-exist
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
@@ -0,0 +1,3 @@
set(file "/a/file/that/does-not-exist")
file(SIZE "${file}" CALCULATED_SIZE)
+9
View File
@@ -0,0 +1,9 @@
set(file "${CMAKE_CURRENT_BINARY_DIR}/a-test-file")
file(WRITE "${file}" "test")
file(SIZE "${file}" CALCULATED_SIZE)
if (NOT CALCULATED_SIZE EQUAL 4)
message(FATAL_ERROR "Unexpected file size")
endif()