<div dir="ltr">What if you call your dependency-fetcher script with a straight macro/function call or `include` or `execute_process` instead of putting it into a custom target? I'm thinking of something like this:<div><br></div><div>    set(DEP_SCRIPT_OUT ${CMAKE_CURRENT_BINARY_DIR}/dep-script-out.cmake) </div><div>    if(NOT EXISTS "${DEP_SCRIPT_OUT}")</div><div>      execute_process(${CMAKE_COMMAND}</div><div>        -DC_COMPILER_ID=${CMAKE_C_COMPILER_ID}</div><div>        -DC_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION}</div><div>        -DDEP_SCRIPT_OUT =${DEP_SCRIPT_OUT}</div><div>        -P dependency-fetcher.cmake)</div><div>    endif()</div><div>    include(${DEP_SCRIPT_OUT})</div><div><br></div><div>or, simply:</div><div><div><br></div><div>    if(NOT DEPENDENCIES_FETCHED)<br></div><div>      include(dependency-fetcher.cmake)</div><div>      # fetch_dependencies() # call it in case it's implemented as a macro/function</div><div>      set(DEPENDENCIES_FETCHED ON CACHE BOOL "" FORCE)</div><div>    endif()</div><div><br></div></div><div>In the latter case there's no need to write the variables into a script since the fetcher runs in the same scope.</div><div><br></div><div>Tamas</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 23, 2015 at 9:49 PM, Matthäus G. Chajdas <span dir="ltr"><<a href="mailto:cmake@anteru.net" target="_blank">cmake@anteru.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm trying to solve the following the problem: I have a C++ application<br>
and a dependency fetching script. I want to simplify the initial build<br>
such that the following happens: On the first run of cmake, the compiler<br>
ID and version is passed to an external script, which fetches some<br>
pre-build binaries. It then writes a CMake file which contains basically<br>
only set(FOO_INCLUDE_DIR /dep-dir), set(FOO_LIBRARY_DIR /dep-dir)<br>
commands. CMake would then read this file and subsequent find_library<br>
calls would pick up the values from this new CMake file. The idea is<br>
that "actual" build is dependent on this first dependency step, but it's<br>
already within the CMake framework so I can grab the compiler info and<br>
other build info.<br>
<br>
The obvious problem is that while I can easily run the external script<br>
by using configure_file, and have a custom target that does the<br>
dependency fetching and CMake configure file generation. But I don't see<br>
an easy way to get CMake to make the "rest of the project" depend on<br>
that configure file. How can I make such a "two-stage" build with CMake?<br>
<br>
Cheers,<br>
  Matthäus<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a></blockquote></div><br></div>