Non-fatal failure in get_filename_component can lead to data loss
Consider this:
cmake_minimum_required(VERSION 3.10)
project(cmakeplayground VERSION 1.2.3)
set(EC_EXTERNAL_DIR /tmp)
# The path does not exist on the filesystem
file(GLOB globResult "/tmp/somedir/onefile*")
get_filename_component(extDir ${globResult} NAME)
message("RM -RF /tmp/somedir/${extDir}")
The output is:
$ /opt/cmake-3.15.0-Linux-x86_64/bin/cmake ..
CMake Error at CMakeLists.txt:7 (get_filename_component):
get_filename_component called with incorrect number of arguments
RM -RF /tmp/somedir/
-- Configuring incomplete, errors occurred!
See also "/home/stephen/dev/src/playground/cmake/build/CMakeFiles/CMakeOutput.log".
The get_filename_component
line should be fatal. It should prevent any following lines from executing.