[CMake] find_package with ###Config.cmake

Michael Hertling mhertling at online.de
Fri Dec 3 07:11:08 EST 2010


On 12/03/2010 08:45 AM, Andreas Pakulat wrote:
> On 03.12.10 07:11:23, Micha Renner wrote:
>> There is a small library "TLib" which is installed like this
>>
>> Install the project...
>> -- Install configuration: "Debug"
>> -- Installing: /usr/local/lib/libTLibd.so
>> -- Installing: /usr/local/lib/TLib/TLibExport.cmake
>> -- Installing: /usr/local/lib/TLib/TLibExport-debug.cmake
>> -- Installing: /usr/local/include/TLib/cmFile.h
>> -- Installing: /usr/local/lib/TLib/TLIBConfig.cmake
>> -- Installing: /usr/local/lib/TLib/TLIBConfigVersion.cmake
>>
>> The CMakeLists file for the application program has the following line
>> to find the library
>>
>> FIND_PACKAGE(TLIB)
>>
>> This works, surprisingly, very good. No CMAKE_MODULE_PATH, no TLIB_DIR
>> in this case. 
>>
>> But...
>>
>> If I call FIND_PACKAGE with version:
>> FIND_PACKAGE(TLIB 1.3)
>>
>> I get the std-warning:
>> -----------------
>> CMake Warning at TestDLL/CMakeLists.txt:20 (FIND_PACKAGE):
>>   Could not find module FindTLIB.cmake or a configuration file for
>> package
>>   TLIB.
>>
>>   Adjust CMAKE_MODULE_PATH or TLIB_DIR...
>> -----------------
>>
>>
>> Why can't CMake find the TLIBConfig file, if FIND_PACKAGE is called with
>> version and TLIB_DIR is not set? 
> 
> The problem might not be finding the Config file, but rather that the
> ConfigVersion file doesn't set the VERSION_COMPATIBLE or VERSION_EXACT
> variables. Or maybe it even sets the VERSION_UNSUITABLE to indicate that
> the installed version of TLib doesn't match the version you request.
> 
> Unfortunately cmake currently cannot seem to distinguish between these
> two cases (non-matching version vs. no config-file found), hence it
> produces the same message in both cases.

Meanwhile, with 2.8.3 to be exact, the warning message issued by CMake
if a version file is found but the requested version doesn't suit is:

Could not find a configuration file for package "..." that is compatible
with requested version "...".

The following configuration files were considered but not accepted:

  ..., version: ...

So, Micha, which CMake version do you use? If it's not 2.8.3 could you
give that a try and report the message if the problem still persists?
Additionally, the <package>_CONSIDERED_{CONFIGS,VERSIONS} variables
would be of special interest, see dfe9c95.

Regards,

Michael


More information about the CMake mailing list