CMake Error: Unknown argument --install

I download cmake-3.31.4.tar.gz and try to build it local, so I use the following comands:

mkdir build install
cd build
cmake …/ --build . --install …/intall

it reports a strange error as I can see the option –install with cmake --help,

CMake Error: Unknown argument --install

my local cmake version is

cmake version 3.31.0

Short version: these cannot be used together.

Full version:
CMake has several modes in which it can be run, which are triggered by different command-line arguments:

  • Generate a buildsystem: no special argument, or use -B and maybe -S
  • Build a project: cmake --build
  • Install a project: cmake --install
  • And many others

You can think of cmake --build and cmake --install as subcommands in the same way as e.g. git status and git commit. Just like git status . commit . does not work, neither does cmake --build --install.

try cmake --build . --target install
but the corresponding project must, of course, support installation.

Thanks @adaldev @Angew ,but I still fail even with cmake …/ --build .

(base) root@szvphis3874429:/home/zhongyunde/cann_code/asl/aoetools/aoe/buildtmp# cmake …/ --build .
CMake Error: Unknown argument --build

Please take a look at: https://cmake.org/cmake/help/latest/manual/cmake.1.html
Especially:

Build a Project
cmake --build <dir> [<options>] [-- <build-tool-options>]

1 Like

See Jakub Zarzewski answer. You have also switched the command and the path.

Besides, as told within the doc, my command line is only available if a target command “install” is generated. It may depend on how the CMakeLists is written. I’m not sure about what are exactly the requirements to have this target.

1 Like

Thanks it works fine with cmake -S … -B build

There seems to be a confusion in usage.
cmake -S … -B build will only perform configuration and generation
cmake --build . <–target install> will build an already generated project (and optionally install the result)

Fine if you achieved what you wanted. Regards
A.