My problem: I have a library project which I want to distribute in binary form. I want my clients to be able to integrate this library with their projects as comfortably as possible. Also, I would prefer if they did not have to deal with a complex installation process. I assume them to be able to use CMake at a beginners level (which means adding header and source files, find_package()
and add_executable()
).
In best case, I'd imagine the workflow with my package to look like this:
- Download the package with headers and binaries only. No source, no CMake,
make
,make install
! - Extract the package.
- Move the content to special directory where other packages are. (This directory can be in environment variable or anything like that.)
find_package()
works.
It should be like this in both Windows 7 and newest Ubuntu.
For me, I've been learning CMake for the last 2 days and I find the documentation extremely hard-to-understand (I never had such trouble with learning things like Qt, qtcreator, sdl, pulse audio, git, OpenGL, ...) and that's why I'm asking.
Resolution:
Use packaging system of cmake.
Notes:
- Of course I found this solution before asking, but I made an error (used
*Targets.cmake
file for build tree in install tree) and thought it's not usable for my purposes. - I used the package system and it wasn't working well, see related problems.
Related problems:
- CPack: How to use exporting to create library package? Missing *Targets-noconfig.cmake file - my testing project, still not completely working for creating packages.
EDIT:
- Changed "find_library" references to "find_package" as I mistook these two during writing.
- Added resolution and related problems sections.