[CMake] How to skip steps and use default values in ExternalProject_Add command?
Cedric Doucet
cedric.doucet at inria.fr
Thu May 21 07:43:42 EDT 2015
Hi Petr!
Thank you for the trick: it's very powerful!
Does this mean that these two calls are equivalent if I write: set(the_configure_command CONFIGURE_COMMAND) ?
ExternalProject_Add(${${LIBRARY}_LOWERNAME}
PREFIX ${${LIBRARY}_PREFIX}
URL ${${LIBRARY}_URL}
${the_configure_command}
)
ExternalProject_Add(${${LIBRARY}_LOWERNAME}
PREFIX ${${LIBRARY}_PREFIX}
URL ${${LIBRARY}_URL}
)
I guess the default value of CONFIGURE_COMMAND will be used, right?
Cédric
----- Mail original -----
> De: "Petr Kmoch" <petr.kmoch at gmail.com>
> À: "Cedric Doucet" <cedric.doucet at inria.fr>
> Cc: cmake at cmake.org
> Envoyé: Jeudi 21 Mai 2015 13:33:27
> Objet: Re: [CMake] How to skip steps and use default values in
> ExternalProject_Add command?
> Hi Cedric.
> When doing things like that, remember that CMake's "named arguments" are
> arguments just like any other. So you can easily obtain them from variable
> expansion; something like this:
> if(${LIBRARY}_CONFIGURE_COMMAND)
> set(the_configure_command CONFIGURE_COMMAND ${${LIBRARY}_CONFIGURE_COMMAND})
> else()
> set(the_configure_command "")
> endif()
> ExternalProject_Add(${${LIBRARY}_LOWERNAME}
> PREFIX ${${LIBRARY}_PREFIX}
> URL ${${LIBRARY}_URL}
> ${the_configure_command}
> BUILD_COMMAND ${${LIBRARY}_BUILD_COMMAND}
> INSTALL_COMMAND ${${LIBRARY}_INSTALL_COMMAND}
> )
> The same trick can be applied to any other command you need to conditionally
> exclude, of course.
> Petr
> On Thu, May 21, 2015 at 1:10 PM, Cedric Doucet < cedric.doucet at inria.fr >
> wrote:
> > Hello,
>
> > I would like to loop on a list of libraries to download and install, by
> > calling the ExternalProject_Add command for each of these libraries.
>
> > To do that, I need to define some commands for each library, like
> > CONFIGURE_COMMAND, BUILD_COMMAND and INSTALL_COMMAND.
>
> > These commands may differ from one library to another; for example, some of
> > them may be based on make, or autoconfig, or cmake, etc.
>
> > Furthermore, some of these libraries may not need to be built.
>
> > What is the good way to skip some steps?
>
> > Is it possible to use default values for some commands?
>
> > The problem in my situation is that I have to fill in each command since I
> > want to design way of downloading and installing third party libraries.
>
> > To be clear, I wrote a loop which looks like this:
>
> > ==========================================================================
>
> > foreach(LIBRARY IN LISTS NOT_FOUND_LIBRARIES)
>
> > ExternalProject_Add(${${LIBRARY}_LOWERNAME}
>
> > PREFIX ${${LIBRARY}_PREFIX}
>
> > URL ${${LIBRARY}_URL}
>
> > CONFIGURE_COMMAND ${${LIBRARY}_CONFIGURE_COMMAND}
>
> > BUILD_COMMAND ${${LIBRARY}_BUILD_COMMAND}
>
> > INSTALL_COMMAND ${${LIBRARY}_INSTALL_COMMAND}
>
> > )
>
> > endforeach(LIBRARY)
>
> > ==========================================================================
>
> > However, if a library is based on cmake, I do not need to specify commands
> > for configuration and building.
>
> > Is it possible to say that the default value of CONFIGURE_COMMAND will be
> > used for example?
>
> > The only way I know to do that is to suppress the line defining
> > CONFIGURE_COMMAND but I can't do that since other libraries may need to
> > define it.
>
> > To skip steps, I replace the corresponding command by 'ls' but it's not
> > very
> > clean.
>
> > That is to say, the value of ${LIBRARY}_CONFIGURE_COMMAND is 'ls' when I
> > want
> > to skip the configuration step.
>
> > Thank you very much for your help.
>
> > Cédric
>
> > --
>
> > 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/20150521/2e7fae1b/attachment.html>
More information about the CMake
mailing list