From ae14059a1500514f24197d05e73edc88dc445da0 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 1 Feb 2013 23:06:32 +0100 Subject: [PATCH] Only write source path line once If more than one match is written, then DUNE_CHECK_MODULES will return several matches, which becomes a syntax error on the resulting command- line. Thus, check if there is a match before writing anything. --- cmake/Scripts/DuneCompat2.cmake | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cmake/Scripts/DuneCompat2.cmake b/cmake/Scripts/DuneCompat2.cmake index e6a83258..86780776 100644 --- a/cmake/Scripts/DuneCompat2.cmake +++ b/cmake/Scripts/DuneCompat2.cmake @@ -5,12 +5,19 @@ set (base_dir ".") set (marker_file "${base_dir}/CMakeFiles/marker") set (makefile "${base_dir}/Makefile") -# if the Makefile has changed, then update it and touch the marker so that -# the marker is newer and won't update the Makefile again +# if the Makefile has changed, then update it if ("${makefile}" IS_NEWER_THAN "${marker_file}") - file (APPEND "${makefile}" - "abs_top_srcdir = ${CMAKE_HOME_DIRECTORY}\n" + # 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 = " ) + 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 execute_process (COMMAND ${CMAKE_COMMAND} -E touch "${marker_file}" )