user7867434
user7867434

Reputation:

CMake "--target install" without "--build" command line

It might be a silly question for some of you, but is it possible to call cmake --target install command option without having to specify --build when using VS generator?

I'm working on a library project that sometimes I don't want to always specify build, i.e:

cmake --build . --target install

I guess cmake forces us to do it in this order to avoid errors, but what if my project is already built and I don't want cmake to re-check my project build and just install? Like we can do with jom install or nmake install etc..
this won't work:

cmake --target install

or

cmake . --target install

Thanks in advance for the answers! :)

Upvotes: 6

Views: 5434

Answers (2)

jmon12
jmon12

Reputation: 1230

For cmake, version >= 3.15, you now have the --install flag doing exactly what you need. The flag is required to be the first, see the relevant cmake doc. It works like a charm on UNIX and Windows (also with VS generator). In your case, it would be:

cmake --install .

Note: I experienced one (probable) backward compatibility problem which I didn't investigate further when building and installing VTK-7.1.1 on windows: the plugins were not handled correctly. I don't know if it's specific to VTK's cmake implementation.

Upvotes: 6

sakra
sakra

Reputation: 65751

The dependency of the install target on the "Build All" target is controlled by the setting of the cmake variable CMAKE_SKIP_INSTALL_ALL_DEPENDENCY.

If you are using a Makefile based generator, CMake also generates a special install target "install/fast" which does not build before installing. It can be invoked in the following way:

cmake --build . --target install/fast

Upvotes: 2

Related Questions