[CMake] Question on ExternalProject_Add and different dependency directives
Bill Katz
billkatz at gmail.com
Fri Dec 7 14:20:44 EST 2012
Hi,
I love the ExternalProject_Add module and use it extensively in an
open-source build system I'm developing for our apps:
http://github.com/janelia-flyem/buildem<https://github.com/janelia-flyem/buildem>
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.
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.
So I was hoping to get clarification on the different ways of specifying
dependencies and what happens after those statements.
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.
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?
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:
project(EP1)
add_library(EP1 ${SOURCES})
add_dependencies(EP1 ep3 ep4)
add_custom_command(TARGET EP1
DEPENDS EP2 EP3
COMMAND dostuff)
add_custom_command(OUTPUT some_constants.h ${more_autogen_include_files}
DEPENDS thrift_EP
COMMAND generate_includes)
add_executable(foo foo.cpp)
target_link_libraries(foo EP1 ${foolibs})
set_source_files_properties(somestuff.cpp
PROPERTIES OBJECT_DEPENDS ${generated_file_dir}/some_constants.h)
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.
Thanks,
Bill
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20121207/b448adcf/attachment.htm>
More information about the CMake
mailing list