Hi,<div><br></div><div>I love the ExternalProject_Add module and use it extensively in an open-source build system I'm developing for our apps:</div><div><br></div><div><a href="https://github.com/janelia-flyem/buildem">http://github.com/janelia-flyem/buildem</a></div>
<div><br></div><div>The idea is to make a build environment from source, using cached tarballs, and allow different version dependency graphs as commits in a git repository of all build modules. I don't use FindPackage because we want to know exactly how dependencies are built and modify parameters for some of them. Also, just about everything above the language compiler level gets built into one build prefix directory. The goal is to run at most two "cmake..; make..." commands and have the system completely download and build all necessary components from archived source.</div>
<div><br></div><div>In looking through the CMake message boards, I think I understand that external projects aren't real targets but can still be used as dependencies. As long as I use the DEPENDS in ExternalProject_Add(), the dependencies seem to work as expected. However, I've run into an issue where I'm using add_dependencies(EP1) where EP1 is an external project and it's being rebuilt regardless of whether it was built already.</div>
<div><br></div><div>So I was hoping to get clarification on the different ways of specifying dependencies and what happens after those statements.</div><div><br></div><div>DEPENDS in ExternalProject_Add lets you specify other external project targets. The dependencies only get downloaded and built once. Question: how does ExternalProject_Add determine when an external project needs to go through its stages again? I read that git repo external projects are always pulled unless you explicitly use an empty UPDATE_COMMAND.</div>
<div><br></div><div>If two different CMakeLists.txt include the same cmake file with a fixed ExternalProject_Add's PREFIX directory, could there be some thrashing going on?</div><div><br></div><div>add_dependencies(myexe EP1 EP2...) seems to work efficiently for most of my modules (i.e, doesn't try to download, configure, etc, if it's done so already), but for some more complicated ones, the external projects and its dependencies always get rebuilt. I'm assuming there's something in my modules that forces rebuilding of an external project even if its built. In the suspect CMakeLists.txt for external project EP1 that I own, I have a number of commands of the form:</div>
<div><br></div><div>project(EP1)</div><div><br></div><div>add_library(EP1 ${SOURCES})</div><div>add_dependencies(EP1 ep3 ep4)</div><div><br></div><div>add_custom_command(TARGET EP1</div><div> DEPENDS EP2 EP3</div>
<div> COMMAND dostuff)</div><div><br></div><div>add_custom_command(OUTPUT some_constants.h ${more_autogen_include_files}</div><div> DEPENDS thrift_EP</div><div> COMMAND generate_includes)</div>
<div><br></div><div>add_executable(foo foo.cpp)</div><div>target_link_libraries(foo EP1 ${foolibs})</div><div><br></div><div>set_source_files_properties(somestuff.cpp </div><div> PROPERTIES OBJECT_DEPENDS ${generated_file_dir}/some_constants.h)</div>
<div><br></div><div><br></div><div>I think there's either a deficiency in my understanding and/or one of the above is forcing rebuilds. Any help would be appreciated in figuring out where I'm going wrong.</div><div>
<br></div><div>Thanks,</div><div>Bill</div>