Irbis
Irbis

Reputation: 1491

Visual Studio 2017 - how to set the installation directory

I need to build a library on Windows. I generate a sln file using cmake:

cmake -G "Visual Studio 15 2017 Win64" CMakeLists.txt

Then I open sln file in Visual Studio and I build the solution. There is INSTALL.vcxproj. It looks like I should run it because "include" directory for that lib is not separated. How I can set the installation directory in Visual Studio ?

Upvotes: 0

Views: 1227

Answers (1)

fabian
fabian

Reputation: 82451

You need to set the cache variable CMAKE_INSTALL_PREFIX to the directory you want to install to via the install target when setting up the project.

Furthermore you should specify the directory containing the CMakeLists.txt file, not the file itself (in source builds are usually not a good idea anyways.

cmake -G "Visual Studio 15 2017" -A x64 -D "CMAKE_INSTALL_PREFIX:PATH=C:/Program Files/some_dir" source_dir

Note that the path for installing from a package can be set seperately, if you're planing to use the PACK target/cpack; Use CPACK_PACKAGING_INSTALL_PREFIX for this purpose.

Btw: Usually the files from the include directory are available regardless of whether you install the target or not via INTERFACE_INCLUDE_DIRECTORIES target property of the target, so if you link the library using target_link_libraries, the include directories should be available; At least that's the case, if the library is properly set up.

Upvotes: 1

Related Questions