From cmake Mon Oct 22 16:34:19 2012 From: Ian Monroe Date: Mon, 22 Oct 2012 16:34:19 +0000 To: cmake Subject: Re: [CMake] using find_library with a ExternalProject Message-Id: X-MARC-Message: https://marc.info/?l=cmake&m=135092367324400 On Mon, Oct 22, 2012 at 6:07 AM, Bill Hoffman wrote: > On 10/21/2012 10:20 PM, Ian Monroe wrote: >> >> So I had code like: >> include(ExternalProject) >> ExternalProject_Add( >> mockcpp >> DOWNLOAD_COMMAND hg clonessh://hg@bitbucket.org/godsme/mockcpp >> >> CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${MOCKCPP_PREFIX} >> UPDATE_COMMAND hg pull >> ) >> >> find_library(MOCKCPP_LIBRARY >> NAMES >> mockcpp >> PATHS >> ${MOCKCPP_PREFIX}/lib >> NO_DEFAULT_PATH) >> >> This worked just fine until I used it on a fresh build. Then cmake >> wouldn't finish since at cmake-time the library doesn't exist. > > > This is a limitation of External project, you can not mix external project > with non-external project CMake code and have it work in a portable manner. > Since external project defers download, configure and build until build > time, there is nothing for the find_library to find at configure time > because the code is not even there in many cases. > > The way to do it is to change the rest of the project into external > projects: > ExternalProject_Add(mockcpp) > ExternalProject_Add(MyProject) > > Inside MyProject, you call find_library because mockcpp will be downloaded, > configured, and built by then. So what was the target use-case for ExternalProject? From the name it sounds like it was meant exactly for making your non-external project (aka your project) be able to pull in dependencies from external projects. To make the project itself an external project gives up a lot of flexibility in cmake configuration. And would just plan mess up my source tree. :) Ian -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake