<div dir="ltr">Hm, this thread: <a href="http://cmake.3232098.n2.nabble.com/ExternalProject-Add-Automatic-Incremental-Rebuilds-Add-Sources-to-IDE-td7585544.html">http://cmake.3232098.n2.nabble.com/ExternalProject-Add-Automatic-Incremental-Rebuilds-Add-Sources-to-IDE-td7585544.html</a><div>
suggests that ExternalProject is not good at all for tracking source file changes, and suggests to use add_subdirectory approach and pass</div><div>information around in variables. Looks like we just can't express rules like "use this just-built compiler to build those libraries" in terms of CMake *sigh*</div>
<div>We can try to configure new build trees with CMake manually, though, similar to the way it's done in add_tablegen() macro.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Feb 21, 2014 at 6:49 PM, Alexey Samsonov <span dir="ltr"><<a href="mailto:samsonov@google.com" target="_blank">samsonov@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Brad,<div><br></div><div>I have a few questions regarding ExternalProject_Add. For me it doesn't really work as expected.</div>
<div>I add the following code to the tools/clang/runtime/CMakeLists.txt to configure compiler-rt as external project:</div>
<div><br></div><div><div> ExternalProject_Add(compiler-rt </div><div> #DEPENDS clang clang++ llvm-config </div>
<div> PREFIX ${CMAKE_BINARY_DIR}/projects/compiler-rt</div><div> SOURCE_DIR ${COMPILER_RT_SRC_ROOT} </div><div> CMAKE_ARGS -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang </div>
<div> -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++ </div><div> -DCMAKE_BUILD_TYPE=Release </div>
<div> -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config </div><div> -DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION} </div>
<div> -DCOMPILER_RT_INSTALL_PATH=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION} </div><div> # -DCOMPILER_RT_INCLUDE_TESTS=ON </div>
<div> INSTALL_COMMAND "" </div><div> )</div><div> add_dependencies(compiler-rt clang clang++ llvm-config)</div></div><div>
<br></div><div>1) Looks like "DEPENDS" option is just broken - docs here (<a href="http://www.kitware.com/media/html/BuildingExternalProjectsWithCMake2.8.html" target="_blank">http://www.kitware.com/media/html/BuildingExternalProjectsWithCMake2.8.html</a>)</div>
<div>state that you can pass CMake targets there, but if I uncomment that line, I get errors like:</div><div><div><br></div><div>CMake Error at /usr/local/share/cmake-2.8/Modules/ExternalProject.cmake:720 (message):</div>
<div> External project "clang" has no stamp_dir</div><div>Call Stack (most recent call first):</div><div> /usr/local/share/cmake-2.8/Modules/ExternalProject.cmake:932 (ExternalProject_Get_Property)</div><div>
/usr/local/share/cmake-2.8/Modules/ExternalProject.cmake:1488 (_ep_get_step_stampfile)</div>
<div> /usr/local/share/cmake-2.8/Modules/ExternalProject.cmake:1702 (_ep_add_configure_command)</div><div> tools/clang/runtime/CMakeLists.txt:18 (ExternalProject_Add)</div></div><div><br></div><div>as if "clang" was supposed to be another external project. FTR, I use cmake 2.8.10.2.<br>
</div><div><br></div><div>2) The dependencies don't act as expected: if I run "make compiler-rt", it builds Clang, uses it to configure</div><div>compiler-rt and builds compiler-rt. But if I then change the Clang sources, and re-run "make compiler-rt",</div>
<div>Clang is re-built, but compiler-rt is *not* re-configured or re-built, while I definitely want this.</div><div><br></div><div>3) The same doc (<a href="http://www.kitware.com/media/html/BuildingExternalProjectsWithCMake2.8.html" target="_blank">http://www.kitware.com/media/html/BuildingExternalProjectsWithCMake2.8.html</a>) states that</div>
<div>"One drawback, however, is ExternalProject’s lack of full dependency analysis. Changes in header files of an external project may</div><div>not cause an incremental rebuild of the affected sources that depend on those headers."<br>
</div><div>Looks like even if I modify *sources* under projects/compiler-rt, and re-run "make compiler-rt" from the build</div><div>directory, it doesn't re-build the compiler-rt libraries. This makes incremental development simply impossible.</div>
<div><br></div><div>What am I doing wrong?</div><div><div><div class="h5"><div><br></div><div>On Fri, Feb 7, 2014 at 1:59 AM, Brad King <span dir="ltr"><<a href="mailto:brad.king@kitware.com" target="_blank">brad.king@kitware.com</a>></span> wrote:<br>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div>
On 02/06/2014 01:02 PM, Alexey Samsonov wrote:<br>
> OK, I feel like I need to learn more about ExternalProject_Add magic.<br>
<br>
</div>It is the CMake equivalent to a configure+make build target that<br>
runs configure+make for another project.<br>
<div><br>
> I have a few quick questions for people with knowledge - currently:<br>
> 1) "compiler-rt"'s CMake needs to know about targets in the Clang build tree ("clang") and<br>
> in LLVM build tree ("FileCheck", llvm-* command-line tools, googletest etc.), and uses common<br>
> macro from LLVM's CMake modules like "configute_lit_site_cfg", "parse_arguments".<br>
<br>
</div>This will be possible once LLVM and Clang are taught to provide proper<br>
content in LLVMConfig.cmake and ClangConfig.cmake package configuration<br>
files. The patch series I proposed in the thread Greg linked at the<br>
start of this thread is the first step to do that.<br>
<div><br>
> 2) top-level targets from compiler-rt's CMake files are visible at the root of LLVM's build tree,<br>
> so that I can run "make check-asan" or even "make clang_rt.asan-x86_64" from the root of<br>
> the build tree.<br>
<br>
</div>This would not work with ExternalProject_Add because the CMake<br>
running on LLVM or Clang would not see the targets in compiler-rt<br>
since the project will not even be processed until build (make) time.<br>
In return the compiler-rt would be able to build using the just-built<br>
Clang because it will now be available when CMake runs on compiler-rt.<br>
(IIUC this is currently the case for configure+make.) Also compiler-rt<br>
could now be built outside of a LLVM/Clang that was built unaware of<br>
compiler-rt.<br>
<br>
It is also possible to make project/compiler-rt build optionally<br>
with add_subdirectory instead of ExternalProject_Add, as it does now,<br>
with the cost of not using the just-built Clang.<br></blockquote><div><br></div></div></div><span class="HOEnZb"><font color="#888888"><div>-- <br></div></font></span></div><span class="HOEnZb"><font color="#888888"><div>
Alexey Samsonov, MSK</div>
</font></span></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div>
</div>