Inconsistencies between using `setup` and bare `cmake`
Opened this issue · 4 comments
I think configuring a project with setup
and bare cmake
should lead to the exact same result, but this is not currently the case:
setup
sets compilers asFC=gfortran cmake
. I think it is better to pass them as CMake variables:cmake -DCMAKE_Fortran_COMPILER=gfortran
, which is also portable.setup
creates the build directory beforehand and then moves into it before runningcmake
. With barecmake
I docmake -H. -Bbuild
(also portable) I encountered this problem because I am running a configuration script that needscmake
to be run from the root directory (I know this is bad practice)- For some reason, running bare
cmake
leads the math detector to believe that I want to use MKL. I haven't investigated this last problem more.
Possible solutions:
- If you agree, I can change this rather easily. Some of the code in
configure.py
andgenerate.py
can be simplified/removed. - I would keep the check on existing build directories (though this is not CMake behavior and it might confuse people used to bare
cmake
) but generate the CMake command ascmake -H<project_root_dir> -B<build_path>
.
I agree with you that "configuring a project with setup and bare cmake should lead to the exact same result" and I can imagine that it may not always and when it does not, I consider it a bug or bad design of some of the components. This is important when a project is included as external project.
- Agree. What you describe is clearly better. I simply did not know better in the past. Will also simplify Windows and as you say remove a lot of clutter.
- Agree. It's more portable. But I really want to know what
-H
means and perhaps rather use the--long-flags
for more clarity. This will be mostly transparent but if somebody goes into the code that they have an idea what is happening. - We can look at it but good to have a concrete example that I can copy paste into my terminal.
I will send a PR for this. My example for the moment was hande-qmc/hande#2, but really, any project using Autocmake will be an example. For -H
the documentation says it will output an help message if called without a directory as argument.
So we can leave out the -H
? Since the script will always call it with an argument.
I feel -H
is the proper way of doing it, even if it's undocumented.