martinmoene / span-lite

span lite - A C++20-like span for C++98, C++11 and later in a single-file header-only library
Boost Software License 1.0
499 stars 43 forks source link

Added cmake package exportation, both in install tree and build tree #29

Closed gracicot closed 5 years ago

gracicot commented 6 years ago

This path exports the cmake package install and build tree. This means that cmake can now find and import the package in user projects like this:

find_package(span-lite REQUIRED)
target_link_libraries(user-target PUBLIC span-lite::span-lite)

Any user that builds the package on it's system will make the package available unless span-lite is included as a subdirectory.

Installing the package in /usr/local/ or /usr/ will also make the package discoverable by cmake.

It also export the version, giving a nice diagnostic to users specifying an older package version.