I have a custom command that is executed if a directory exists. I need to know if the directory is not empty before executing another command.
Question: How to read, detect or get the number of files of a directory?
You can run regular CMake code as script using cmake -P
as part of build process.
The script itself would contain somethng like
file(GLOB RESULT DIR)
list(LENGTH RESULT RES_LEN)
if(RES_LEN EQUAL 0)
# DIR is empty, do something
endif()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With