Skip to content

Commit

Permalink
Hide cmake cache during fakebuild, so that the previous in-tree build…
Browse files Browse the repository at this point in the history
…s do not affect build system generation.

See ycm-core#16
  • Loading branch information
rdnetto committed Jun 15, 2015
1 parent 40acbf5 commit 048ace1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions config_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ def run(cmd, *args, **kwargs):
build_dir = tempfile.mkdtemp()
proc_opts["cwd"] = build_dir

# if the project was built in-tree, we need to hide the cache file so that cmake
# populates the build dir instead of just re-generating the existing files
cache_path = os.path.join(project_dir, "CMakeCache.txt")

if(os.path.exists(cache_path)):
fd, cache_tmp = tempfile.mkstemp()
os.close(fd)
shutil.move(cache_path, cache_tmp)
else:
cache_tmp = None

print("Running cmake in '{}'...".format(build_dir))
run(["cmake", project_dir] + configure_opts, env=env_config, **proc_opts)

Expand All @@ -192,6 +203,9 @@ def run(cmd, *args, **kwargs):
print("")
shutil.rmtree(build_dir)

if(cache_tmp):
shutil.move(cache_tmp, cache_path)

elif(os.path.exists(os.path.join(project_dir, "configure"))):
# Autotools
# perform build in-tree, since not all projects handle out-of-tree builds correctly
Expand Down

0 comments on commit 048ace1

Please sign in to comment.