diff --git a/python/dune/perftool/sumfact/autotune.py b/python/dune/perftool/sumfact/autotune.py index 1b48dffc14871588d19b278fa77c004f92079984..af324722d1d393cfef15bdaa0d411b60d0453ac9 100644 --- a/python/dune/perftool/sumfact/autotune.py +++ b/python/dune/perftool/sumfact/autotune.py @@ -15,11 +15,18 @@ import subprocess def get_cmake_cache_entry(entry): for line in open(os.path.join(get_option("project_basedir"), "CMakeCache.txt"), "r"): - match = re.match("{}:[INTERNAL|FILEPATH|BOOL|STRING|PATH|UNINITIALIZED]+=(.*)".format(entry), line) + match = re.match("{}:[INTERNAL|FILEPATH|BOOL|STRING|PATH|UNINITIALIZED|STATIC]+=(.*)".format(entry), line) if match: return match.groups()[0] +def get_perftool_dir(): + if get_cmake_cache_entry("CMAKE_PROJECT_NAME") == "dune-perftool": + return get_option("project_basedir") + else: + return get_cmake_cache_entry("dune-perftool_DIR") + + def compiler_invocation(name, filename): # Determine the CMake Generator in use gen = get_cmake_cache_entry("CMAKE_GENERATOR") @@ -30,7 +37,7 @@ def compiler_invocation(name, filename): compile_flags = [compiler] # Parse compiler flags - for line in open(os.path.join(get_option("project_basedir"), "python", "CMakeFiles", "_autotune_target.dir", "flags.make"), "r"): + for line in open(os.path.join(get_perftool_dir(), "python", "CMakeFiles", "_autotune_target.dir", "flags.make"), "r"): match = re.match("([^=]*)=(.*)", line) if match: compile_flags.extend(match.groups()[1].split()) @@ -39,14 +46,14 @@ def compiler_invocation(name, filename): compile_flags.append(filename) # Parse linker flags - for line in open(os.path.join(get_option("project_basedir"), "python", "CMakeFiles", "_autotune_target.dir", "link.txt"), "r"): + for line in open(os.path.join(get_perftool_dir(), "python", "CMakeFiles", "_autotune_target.dir", "link.txt"), "r"): match = re.match(".*_autotune_target (.*)", line) if match: for flag in match.groups()[0].split(): if flag.startswith("-") or os.path.isabs(flag): compile_flags.append(flag) else: - compile_flags.append(os.path.join(get_option("project_basedir"), "python", flag)) + compile_flags.append(os.path.join(get_perftool_dir(), "python", flag)) # Set an output name compile_flags.append("-o")