I want to populate a variable, MY_VARIABLE, in cmake with a list of all the /foo subdirectories containing a Makefile. The problem is, all the /foo subdirectories are of different depth from where my CMakeLists is located at, and I don't want any subdirectories not containing a Makefile. I also just want the name of the directory.
For example, if $(BUILD_DIR)/A/B/foo/ contained a makefile:
$(BUILD_DIR)/A/B/foo/ would be good
$(BUILD_DIR)/A/B/foo/Makefile would be bad
Tinkering around, I know I can do something like this with the UNIX shell:
find $(BUILD_DIR) -name 'Makefile' | grep 'foo/' | sed 's/\/Makefile//'
But I don't know how to invoke that in CMake, or if there's another way. I tried
execute_process(COMMAND find $(BUILD_DIR) -name 'Makefile' | grep 'foo/' | sed 's/\/Makefile\//'
OUTPUT_VARIABLE MY_VARIABLE
)
only to be met with parsing errors.
Any help or advice would be appreciated.