2013-02-01 13:10:20 +01:00
|
|
|
# - Emulate a rule to patch the Makefile, adding a line to the source
|
|
|
|
|
# tree and write a marker file indicating it is done.
|
|
|
|
|
|
|
|
|
|
set (base_dir ".")
|
|
|
|
|
set (marker_file "${base_dir}/CMakeFiles/marker")
|
|
|
|
|
set (makefile "${base_dir}/Makefile")
|
|
|
|
|
|
2013-02-01 23:06:32 +01:00
|
|
|
# if the Makefile has changed, then update it
|
2013-02-01 13:10:20 +01:00
|
|
|
if ("${makefile}" IS_NEWER_THAN "${marker_file}")
|
2013-02-01 23:06:32 +01:00
|
|
|
# only add the string once, so it does not return multiple
|
|
|
|
|
# results for the command line (will lead to syntax error)
|
|
|
|
|
file (STRINGS "${makefile}" abs_top_srcdir_FOUND
|
|
|
|
|
REGEX "^abs_top_srcdir = "
|
2013-02-01 13:10:20 +01:00
|
|
|
)
|
2013-02-01 23:06:32 +01:00
|
|
|
if (NOT abs_top_srcdir_FOUND)
|
|
|
|
|
file (APPEND "${makefile}"
|
|
|
|
|
"abs_top_srcdir = ${CMAKE_HOME_DIRECTORY}\n"
|
|
|
|
|
)
|
|
|
|
|
endif (NOT abs_top_srcdir_FOUND)
|
|
|
|
|
# touch the marker so that we won't update the Makefile again
|
2013-02-01 13:10:20 +01:00
|
|
|
execute_process (COMMAND
|
|
|
|
|
${CMAKE_COMMAND} -E touch "${marker_file}"
|
|
|
|
|
)
|
|
|
|
|
endif ("${makefile}" IS_NEWER_THAN "${marker_file}")
|
|
|
|
|
|