[PATCH] Adds a CMake package configuration file for libclang

Brad King brad.king at kitware.com
Thu Mar 7 06:42:00 PST 2013


On 03/06/2013 07:40 PM, Damien Buhl wrote:
>  > will work but it will not hook up a dependency to cause the app
>  > to re-link when the clang library file changes.  To achieve that
>  > you need full target export/import support
> 
> This would be nice and especially for people patching libclang, testing 
> their custom build of libclang.
> 
> It should be pretty easy to add this, by adding an EXPORT param to the 
> install call in the add_clang_library macro (see root CMakeLists.txt), 
> and we could add an install(EXPORT...) call there, to put a full 
> import/export support per library. I'll try to make a new patch for this 
> once this first patch get merged, because this requires same 
> modifications for the install of llvm/ libraries too.

Note that exported targets can put arch-specific information into the
targets file it generates.  Therefore lib/ is better than share/ as
a place for the package configuration file.

Also it will take some manual work to get imported targets to work
when building without CMake.  A fallback would be to just produce the
basic file with autotools and do the full target exports only when
building with CMake.

> Please find a new patch with the different modifications discussed as 
> attachment.

The new patch looks good, though I haven't had time to try building it.

One thing the upstream devs should check is whether the version test
in libclang-config-version.cmake.in looks correct.  The logic needs to
match your interface compatibility and versioning policy.  Currently
it says that versions will be forward and backward compatible across
all minor versions of the same major version, and that a change in
major version breaks compatibility.  This is a reasonable policy, but
this code needs to match your actual policy.

The file will be loaded by CMake's find_package to test whether the
version is a suitable match for the version requested by the application.
When the file is loaded the PACKAGE_FIND_VERSION_* variables have the
components as requested by the app in its find_package call.  The file
needs to set PACKAGE_VERSION_COMPATIBLE and possibly PACKAGE_VERSION_EXACT
to indicate whether the installed libclang version is a compatible/exact
match for that requested.

-Brad



More information about the cfe-commits mailing list