I have a project that depends on a git submodule and several static libraries that are built with add_subdirectory and they all have install commands to install the libraries and header files in CMAKE_INSTALL_PREFIX/lib, /include. I invoke the main cmake command CMakeLists.txt, with:
$ cd build
$ cmake … -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install -DCMAKE_PREFIX_PATH=$PWD/install (+ flags for the submodule )l
$ cmake --build . -j 4 -config Release
This works perfectly and it creates a executable binary, .h files, .so and .a libraries in the right places (build/bin/, build/include and build/lib/ respectively).
My problem now is trying to pack the binary into a tar.gz or similar package. My problem is two fold:
It packs alll the .h files, .a files and all that is in the bin directory, in the binary distribution when I only need to pack the main executable, a shell start up script and the .so files. I need a way to set a regex in some variable to exclude the unwanted files and directories.
It installs it into a path that mimics my CMAKE_INSTALL_PREFIX (the full $PWD/install inside the tar.gz file, which is /home/$USER/code/ directory and leaves the CPACK_INSTALL_PREFIX path empty),. This is me probably using CPACK_INSTALL_PREFIX wrong, my guess.