[CMake] How to write find_package when *Config.cmake is given?
Michael Wild
themiwi at gmail.com
Mon Apr 4 15:26:14 EDT 2011
On 04/04/2011 08:17 PM, Hauke Heibel wrote:
> Hi,
>
> I am wondering how to write find_package when I am providing a
> <module>Config.cmake file.
>
> Do I do something like this?
>
> find_file(MY_CONFIG_FILE "<module>Config.cmake" HINTS "...")
> if (MY_CONFIG_FILE)
> include(${MY_CONFIG_FILE})
> endif()
>
> What I actually would like to have is a configuration like this
>
> /foo/moduleA
> /foo/moduleB
> /foo/superProject
>
> in which "moduleB" depends on "moduleA" and in which I can build each
> module individually but also all together in a "superProject".
>
> With the setup above, building each of the libraries on its own, works
> just fine -- as long as the order is correct.
>
> As soon as I switch to the "superProject" setting, the configuration
> is not the way I would like to have it. moduleB still links against
> the installed version of moduleA (my find_package points to this one)
> whereas I would like moduleB to link against the version of mdouleA
> which is being build by the "superProject".
>
> Is there a simple CMake trick to achieve this behavior? Any help is
> highly appreciated!
>
> Regards,
> Hauke
>
> ---
> Main references I've read till now ...
>
> [1] http://www.cmake.org/Wiki/CMake:How_to_create_a_ProjectConfig.cmake_file
> [2] http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries
> [3] \CMake 2.8\share\cmake-2.8\Modules\readme.txt
> [4] ITK modularization configuration files ...
Huh? FindXXX.cmake and XXXConfig.cmake are usually considered to be
"mutually exclusive". The former is used to find software *not* built by
CMake, while the latter is installed by a package that has been built
*with* CMake. The find_package command will first try to find a
XXXConfig.cmake file (read the doc for all the names and locations it
searches), unless told otherwise, and then goes on and tries to find a
FindXXX.cmake module.
HTH
Michael
More information about the CMake
mailing list