pfultz2 / cget

C++ package retrieval
http://cget.readthedocs.io
Other
453 stars 27 forks source link

Usage for System Admins #32

Closed jonathonl closed 7 years ago

jonathonl commented 7 years ago

I'm trying to figure out a sane way to allow sys admins to install just the library dependencies of an executable into the build tree, link to the libs statically and then install just the executable into a system path. In this scenario the install prefix for the dependencies is different than the install prefix for the executable. The following does the trick but is a little verbose.

mkdir build
cd build
cget install --file ../requirements.txt --prefix .
cmake -DCMAKE_PREFIX_PATH=`pwd` ..
make
sudo make install # Installs executable to /usr/local

Is there a better way of doing this or are there any ideas on how cget could support this in the future?

Also, is setting CMAKE_PREFIX_PATH to the cget prefix path the recommended way of using cget with IDEs like CLion?

pfultz2 commented 7 years ago

Is there a better way of doing this or are there any ideas on how cget could support this in the future?

I have not tested it but this should work(run in the source directory):

cget build --target install

Also, you can specify the install directory with CMAKE_INSTALL_PREFIX if you don't like the default:

cget build -DCMAKE_INSTALL_PREFIX=/usr/local --target install

Also, is setting CMAKE_PREFIX_PATH to the cget prefix path the recommended way of using cget with IDEs like CLion?

That is one way, although I am not very familiar with CLion. Cget provides a toolchain file in $CGET_PREFIX/cget/cget.cmake that sets everything needed in cmake. So if you want to run cmake manually you can do:

mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$CGET_PREFIX/cget/cget.cmake ..

I don't know if there is a way in CLion to specify a toolchain file or not, but it is a better choice.

jonathonl commented 7 years ago

So cget build --target install works, but -DCMAKE_INSTALL_PREFIX is applied to dependencies when specified (nothing is installed into $CGET_PREFIX).

pfultz2 commented 7 years ago

but -DCMAKE_INSTALL_PREFIX is applied to dependencies when specified

Thats right, as defines are applied to all packages including dependencies. It would probably be better not to have the user overwrite this when installing dependencies.

pfultz2 commented 7 years ago

I merged a fix for this in master, so you can set CMAKE_INSTALL_PREFIX and it won't apply to the dependencies.