[CMake] "Pre-configure" step in CMake
Petr Kmoch
petr.kmoch at gmail.com
Thu Sep 24 02:52:49 EDT 2015
Hi Matthaus,
do you need the pre-configure step to happen at build time? Would it be an
option for you to use file(WRITE) instead of configure_file(), and
execute_process() instead of add_custom_target()? Basically, perform the
pre-configure step as part of the first CMake run itself.
Alternatively, you could look into the ExternalProject module, which is (I
believe) designed for situations like yours:
http://cmake.org/cmake/help/v3.3/module/ExternalProject.html
The basic idea of ExternalProject is that you create one top-level,
"SuperBuild" project, which will include each dependency as an external
project, and your real project *as an external project too.* That way, you
can easily gather all dependencies by building the "SuperBuild". Then you
switch to working just with your own project inside the SuperBuild
structure, but all the dependencies are already there.
(Note: I've never used ExternalProject myself, this info comes from what
I've learned on this mailing list from other people using it).
Hope this helps,
Petr
On Wed, Sep 23, 2015 at 9:49 PM, Matthäus G. Chajdas <cmake at anteru.net>
wrote:
> Hi,
>
> I'm trying to solve the following the problem: I have a C++ application
> and a dependency fetching script. I want to simplify the initial build
> such that the following happens: On the first run of cmake, the compiler
> ID and version is passed to an external script, which fetches some
> pre-build binaries. It then writes a CMake file which contains basically
> only set(FOO_INCLUDE_DIR /dep-dir), set(FOO_LIBRARY_DIR /dep-dir)
> commands. CMake would then read this file and subsequent find_library
> calls would pick up the values from this new CMake file. The idea is
> that "actual" build is dependent on this first dependency step, but it's
> already within the CMake framework so I can grab the compiler info and
> other build info.
>
> The obvious problem is that while I can easily run the external script
> by using configure_file, and have a custom target that does the
> dependency fetching and CMake configure file generation. But I don't see
> an easy way to get CMake to make the "rest of the project" depend on
> that configure file. How can I make such a "two-stage" build with CMake?
>
> Cheers,
> Matthäus
> --
>
> 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/20150924/9299d505/attachment.html>
More information about the CMake
mailing list