[CMake] Using ExternalProject_Add when CMakeFiles.txt is not in the root directory.

David Cole DLRdave at aol.com
Sat Jul 18 11:48:05 EDT 2015


The split technique should be able to help in this scenario as well,
because for the second project, which builds the code downloaded by the
first project, you can specify a different SOURCE_DIR value... (A sub
directory of the first project's source dir, for example.)

It would be nice if EP stuff were more compose-able. If you have any good
ideas for making it so, this and the dev list are the right places
to mention them.


D

On Friday, July 17, 2015, Klaim - Joël Lamotte <mjklaim at gmail.com> wrote:

>
>
> On 17 July 2015 at 20:06, Bradley Lowekamp <blowekamp at mail.nih.gov
> <javascript:_e(%7B%7D,'cvml','blowekamp at mail.nih.gov');>> wrote:
>
>> Hello,
>>
>> David Cole just said the solution in another post.
>>
>> You can split the project into two, with the first one being just the
>> download step, the second is the configuration and build. This should allow
>> you to configure the paths for your project correctly.
>>
>>
> I am not 100% sure that the split can solve this problem too, but I will
> try it.
>
> Now that I have the split trick in mind, it seems to match my initial
> assumption that ExternalProjects should have a "download only"
> function/macro
> separated from the other steps, so that it is possible to compose complex
> setup in easier ways than hacking ExternalProjects_Add parametters and
> using clunky patches.
>
>
>> I need to do this for my project too. Thanks for the question to get me
>> paying attention here, and finding the answer is another post :)
>>
>> Brad
>>
>> On Jul 14, 2015, at 5:14 PM, Klaim - Joël Lamotte <mjklaim at gmail.com
>> <javascript:_e(%7B%7D,'cvml','mjklaim at gmail.com');>> wrote:
>>
>> I am attempting to use ExternalDependencies_Add with the last Protobuf
>> version (v3.0.0) which is in alpha3 (I'm using the master branch
>> actually)[1].
>> If you don't already know: contrary to previous Protobuf version, v3.x
>> provides
>> cmake scripts (and also makes CMake's FindProtobuf module unusuable if
>> you build Protobuf using CMake BTW).
>>
>> I am having trouble figuring out how to ExternalProject_add work in this
>> case:
>> the CMakeFiles.txt is not in the root directory of Protobuf sources, it
>> is in ./cmake/ [2]
>> So at build time, after download, I obviously get:
>>
>> >CUSTOMBUILD : CMake error : The source directory
>> "blahblah/install_protobuf" does not appear to contain CMakeLists.txt.
>>
>> I tried several approaches using this as a base:
>>
>> ExternalProject_Add( install_protobuf
>>     PREFIX ${NETRUSH_DEPENDENCIES_DIR}/protobuf
>>     GIT_REPOSITORY https://github.com/google/protobuf.git
>>     GIT_TAG master
>>
>>     CMAKE_CACHE_ARGS
>>         -DBUILD_TESTING:bool=FALSE
>> )
>>
>>
>> I tried setting SOURCE_DIR but failed to make it work mainly because I'm
>> not sure what value to set exactly, and
>>
>>    SOURCE_DIR cmake
>>
>> Does not seem to work.
>>
>> I was wondering if there is some args I could pass to CMake using
>> CMAKE_ARGS
>> but from the cmake[3] page in the doc I don't see anything that match
>> exactly, or
>> I might be misunderstanding something.
>>
>> I found this recommandation from Miklos Espak from 8th February 2015:
>> "Specify a patch command that creates a toplevel cmake list with one
>> 'add_subdirectory(A)'  line."
>>
>> It seems to work, but it also means that the repository is modified,
>> which is something
>> I want to avoid. Also it's really a hack for passing the right working
>> directory to cmake.
>>
>> Is there a simpler way to do it that I missed?
>>
>> Thanks for your time.
>>
>> Joël Lamotte
>>
>>
>> [1] https://github.com/google/protobuf
>> [2] https://github.com/google/protobuf/tree/master/cmake
>> [3]
>> http://www.cmake.org/cmake/help/v3.3/manual/cmake.1.html#manual:cmake(1)
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150718/eda62ca4/attachment-0001.html>


More information about the CMake mailing list