[CMake] Subdirectories and FIND_LIBRARY routines
themiwi at gmail.com
Mon Jul 26 13:28:43 EDT 2010
On 26. Jul, 2010, at 19:09 , Clifford Yapp wrote:
> Thanks for an interesting reply. How do you decide what value to put
> in XXX_LIBRARIES? Is that pulled from the child CMakeLists.txt file
> back into the parent?
> On Mon, Jul 26, 2010 at 12:46 PM, Michael Wild <themiwi at gmail.com> wrote:
>> Where build_thirdparty() is a macro that builds the named package (in my case through ExternalProject_Add) and sets compatibility variables (i.e. the XXX_INCLUDE_DIR and XXX_LIBRARIES variables). This is possible since you can always override the cached values of a variable (the reverse is undefined, however. so be careful). Above code is intentionally a macro, since otherwise it would be cumbersome to propagate the variables XXX_INCLUDE_DIR and XXX_LIBRARIES (and similar ones) to the caller scope.
The build_thirdparty macro calls itself other macros, e.g. build_zlib. That one "guesses" the output location of the zlib libraries, creates an IMPORTED library target and sets XXX_LIBRARIES accordingly.
The problem of finding the output location of external projects has been discussed quite a few times, and there is only one really clean, although complex and confusing solution: There is one "master" project which only makes calls to ExternalProject_Add, even the main project is build as such an external project.
More information about the CMake