cmake-rs
cmake-rs copied to clipboard
Cmake restart fix v2
Extracted from comments that I add to cmake-rs:
// Acording to // https://gitlab.kitware.com/cmake/cmake/-/issues/18959 // CMake does not support usage of the same build directory for different // compilers. The problem is that we can not make sure that we use the same compiler // before running of CMake without CMake's logic duplication (for example consider // usage of CMAKE_TOOLCHAIN_FILE). Fortunately for us, CMake can detect is // compiler changed by itself. This is done for interactive CMake's configuration, // like ccmake/cmake-gui. But after compiler change CMake resets all cached variables. // So
run cmake twice with parameters specified by user of cmake-rs
to make sure that
settings not disappear. Tested on macOS during several weeks. As I found out the problem that I faced in #98 ,
is unrelated to this patch, and related to alexcrichton/cc-rs#530 , but I made little changes of the implementation
to make it more robust.
I faced with this problem on macOS, where /usr/bin/clang
and /Application/Xcode/.../clang
are different binaries,
but have the same version. Plus some tools like to set /usr/bin/cc
(that link to /usr/bin/clang
) but cmake
can not distinguish them.
@alexcrichton , have no time to review, or have some doubts about this PR?
First off, I want to say I'm sorry for being so glacially slow on this PR, I got too used to this email sitting in my inbox.
Other than that though I'm reading this over and this looks pretty reasonable to me, thanks for sending this PR and doing the work here! Code-wise I was wondering if perhaps run_{configure,build}
could share some implementation? They're largely the same except for one needing to run two commands instead of one. Also, the comment on run_and_check_if_need_reconf
looks like it may have been cut off?
Again I'm sorry about the pace here, but I'll do my best to be more responsive on this in the future!
run_{configure,build}
refactor these two into run_cmake_action function
the comment on run_and_check_if_need_reconf looks like it may have been cut off?
Also I removed unfinished sentence in comment
Plus rebase.
Ping @alexcrichton
I rebased my branch, it is again ready to merge @alexcrichton
Sorry I think I'm gonna be real with myself, I don't have time to maintain this crate any more. I've opened https://github.com/alexcrichton/cmake-rs/issues/127.
Rebase on master. Ping @alexcrichton and @strega-nil .