Closed ReinhardKeil closed 2 months ago
About CMake Caching https://cmake.org/cmake/help/book/mastering-cmake/chapter/CMake%20Cache.html
Another purpose of the cache is to allow CMake itself to persistently store values between CMake runs. These entries may not be visible or adjustable by the user. Typically, these values are system-dependent variables that require CMake to compile and run a program to determine their value. Once these values have been determined, they are stored in the cache to avoid having to recompute them every time CMake is run. CMake generally tries to limit these variables to properties that should never change (such as the byte order of the machine you are on). If you significantly change your computer, either by changing the operating system or switching to a different compiler, you will need to delete the cache file (and probably all of your binary tree’s object files, libraries, and executables).
Today cbuild
is responsible for running the clean
.
On the other hand probably cbuild2cmake
is best placed to see whether the compiler was changed.
Therefore we need a mechanism that allow cbuild2cmake to instruct cbuild which targets need to be cleaned.
I don't want to judge if CMake Caching is an option. I believe you are right cbuild2cmake
is the right place to judge if a Rebuild is required. This are the scenarios that I discovered so far:
Changing Toolchain, for example.
cbuild hello.csolution.yml --toolchain GCC
cbuild hello.csolution.yml --toolchain AC6
Maybe this can be triggered when a toolchain.cmake
file is changed
Add targets or change context-set. Basically when tmp\CMakeLists.txt
changes as this contains the mapping to tmp
sub-directories).
Revised based on @brondani comment below:
a) cbuild
to clean all targets: if the top level CMakeCache.txt exists and CMAKE_CACHEFILE_DIR:INTERNAL=<abs_tmp_path>
") does not match the file's location. (the solution was copied to a new location or the directory renamed or the tmpdir
was changed. (in these cases the build would fail without a clean)
b) csolution
sets a node in the <name>.cbuild-idx.yml
for each context that requires a "rebuild" because
cbuild
to read the <name>.cbuild-idx.yml
and clean each context that is marked with "rebuild" nodeif the top level CMakeLists.txt exists and set(SOLUTION_ROOT "
") does not match the filepath of the loaded .csolution.yml
This may not cover a situation where only the tmp
directory is moved or redefined. For this reason I would recommend to read CMakeCache.txt
instead and check whether its location matches the path reported in CMAKE_CACHEFILE_DIR:INTERNAL=<abs_tmp_path>
.
Note: a) above was updated accordingly.
Problem solved
The Problem To Be Solved The build process requires a rebuild in cases when a compiler is changed (using --toolchain) or context-set is changed. The output is misleading and may lead to user confusion.
Suggest A Solution A potential solution might be to force a rebuild in this situation. We should define when a rebuild is required.