I'm trying to make another guy's research code reproducible, so that others don't have the same trouble I'm having right now. But, I'm lacking the experience with cmake for that. Here is what I could do after reading the docs:
In the same folder as my CMakeLists.txt
I have a file called io_utils.h
with a ROOT_PATH
variable whose value is VALUE_ROOT_PATH
.
I want to replace that string with the value of the file's current directory. So I tried to add the following to CMakeLists.txt
:
# Set ROOT_PATH in io_utils.h
FIND_PATH(BUILD_PATH CMakeLists.txt . )
FILE(READ ${BUILD_PATH}io_utils.h IO_UTILS)
STRING(REGEX REPLACE "VALUE_ROOT_PATH" "${BUILD_PATH}" MOD_IO_UTILS "${IO_UTILS}" )
FILE(WRITE ${BUILD_PATH}io_utils.h "${MOD_IO_UTILS}")
I tried to make and install that but it is not working, the file isn't changed. What's wrong with what I did?