0

I'm using the Emacs eshell's alias feature to make an alias to the cmake command like below:

$ alias cmake 'cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1'

The alias is created correctly, here is the output of running which cmake inside eshell:

$ which cmake
cmake is an alias, defined as "cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1"

However, when running this alias cmake inside my project, it doesn't recognize the input path correctly. For example, when running cmake .., it seems unable to interpret the .. path.

Here are the detailed steps to produce this error:

$ cd my-project     # the CMakeLists.txt is stored at the root folder of this project
$ mkdir build
$ cd build
$ cmake ..          # running the cmake alias
CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.


CMake Error: The source directory "/home/trungtq/workspace/ocaml/discover/llvm-normalizer/build" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

Does anyone know how to fix this problem?

Thank you very much!

1

You need to include the arguments in the Eshell alias as $1, $2, ... or as full list of provided arguments $*. See the documentation of Eshell aliases.

In your special case you could use:

alias cmake 'cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 $*'
1
  • Thank you very much for the tip! I realized that previously I also used the arguments $*, $1, but enclosed the alias definition in the double quote "...", hence it didn't work. But somehow, when posting the question, I used the single quote '...' :-D
    – Trung Ta
    May 11 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.