[CMake] How to write find_package when *Config.cmake is given?

Hauke Heibel hauke.heibel at googlemail.com
Mon Apr 4 14:17:50 EDT 2011


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 ...


More information about the CMake mailing list