[CMake] find_package with ###Config.cmake

Andreas Pakulat apaku at gmx.de
Fri Dec 3 02:45:03 EST 2010


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.

Andreas

-- 
Don't you feel more like you do now than you did when you came in?


More information about the CMake mailing list