Support cmake exported targets
If cmake exported targets are implemented in uchardet, a downstream project using CMake can find and link the libuchardet library directly with cmake (without needing pkg-config at all) this way:
project(sample LANGUAGES C)
find_package ( uchardet )
if (uchardet_FOUND)
add_executable( sample sample.c )
target_link_libraries ( sample PRIVATE uchardet::libuchardet )
endif ()
The build system should create one exported target for each built target feature, for instance:
- The executable uchardet::uchardet
- The shared library uchardet::libuchardet
- The static library uchardet::libuchardet_static
After installing the project in a prefix like "$HOME/uchardet/", the downstream project can be configured with a command like:
cmake -DCMAKE_PREFIX_PATH="$HOME/uchardet/;..."
Instead of installing, the build directory can be used directly, for instance:
cmake -Duchardet_DIR="$HOME/build-uchardet-0.1.0/" ...