Hi, that sounds like it would do the trick. I wasn't aware that execute_process will block the script until it's done executing. Need to check this out but that definitely looks like the way to go, thanks!
Cheers, Matthäus Am 24.09.2015 um 10:14 schrieb Tamás Kenéz: > 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: > > set(DEP_SCRIPT_OUT ${CMAKE_CURRENT_BINARY_DIR}/dep-script-out.cmake) > if(NOT EXISTS "${DEP_SCRIPT_OUT}") > execute_process(${CMAKE_COMMAND} > -DC_COMPILER_ID=${CMAKE_C_COMPILER_ID} > -DC_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION} > -DDEP_SCRIPT_OUT =${DEP_SCRIPT_OUT} > -P dependency-fetcher.cmake) > endif() > include(${DEP_SCRIPT_OUT}) > > or, simply: > > if(NOT DEPENDENCIES_FETCHED) > include(dependency-fetcher.cmake) > # fetch_dependencies() # call it in case it's implemented as a > macro/function > set(DEPENDENCIES_FETCHED ON CACHE BOOL "" FORCE) > endif() > > In the latter case there's no need to write the variables into a script > since the fetcher runs in the same scope. > > Tamas > > > On Wed, Sep 23, 2015 at 9:49 PM, Matthäus G. Chajdas <cm...@anteru.net > <mailto:cm...@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 <http://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 > > > > -- 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