I would like to add a build system (Copy a single CMakeLists.txt file
to the unpacked source tree) to an external project build with a
proper file dependency on the source CMakeLists.txt file so
if that file is changed (or touched) a complete rebuild occurs.
Here is how I am attempting to do this:
ExternalProject_Add(
build_shapelib
URL http://download.osgeo.org/shapelib/shapelib-1.3.0.tar.gz
URL_MD5 2ff7d0b21d4b7506b452524492795f77
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=${EP_BASE}/Install/build_shapelib
-DEG_DATA:PATH=${EP_BASE}/Source/build_shapelib/eg_data
TEST_BEFORE_INSTALL ON
TEST_COMMAND ctest
STEP_TARGETS download update_build_system download_eg_data
clean_unpacked_eg_data unpack_eg_data configure build install test
)
add_custom_command(
OUTPUT ${EP_BASE}/Source/build_shapelib/CMakeLists.txt
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/shapelib/CMakeLists.txt
${EP_BASE}/Source/build_shapelib/CMakeLists.txt
DEPENDS
${CMAKE_SOURCE_DIR}/shapelib/CMakeLists.txt
)
ExternalProject_Add_Step(build_shapelib update_build_system
COMMENT "Updating build system"
DEPENDS ${EP_BASE}/Source/build_shapelib/CMakeLists.txt
DEPENDERS configure
ALWAYS OFF
)
ExternalProject_Add_Step(build_shapelib [...]
The remaining elided steps finish the complete external build but
are not relevant to the file dependency issue I appear to be
encountering.
From looking at the code for ExternalProject_Add_Step, I _thought_
what should be going on here was that the add_custom_command does the
required copy with correct file dependency on the source CMakeLists.txt
file for the copy, and the update_build_system step file-depends on
that OUTPUT file and creates an OUTPUT timestamp file. Then because
update_build_system was mentioned as one of the STEP_TARGETS, a custom
target would be created that file depended on that timestamp file.
To test that mental model, I do the following steps.
(1) Do a fresh configure in an initially empty build tree.
(2) build
(3) build again #no commands executed as expected
(4) touch source file
(5) build
(6) build again #commands are executed.... why?
(7) build for a third time # no commands executed, but why didn't
this happen at step 6?
Details of those steps:
1.
wine@raven> rm -rf /home/wine/newstart/build_script/build_dir/*
wine@raven> cmake ..
-- CMake version = 2.8.10.2
-- CMAKE_SYSTEM = Linux-3.2.0-4-amd64
-- EP_BASE = /home/wine/newstart/build_script/build_dir/build_projects
-- Configuring done
-- Generating done
-- Build files have been written to:
/home/wine/newstart/build_script/build_dir
2.
wine@raven> make build_shapelib-update_build_system
Scanning dependencies of target build_shapelib-update_build_system
[ 50%] Generating build_projects/Source/build_shapelib/CMakeLists.txt
[100%] Updating build system
[100%] Built target build_shapelib-update_build_system
3.
wine@raven> make build_shapelib-update_build_system
[100%] Built target build_shapelib-update_build_system
4.
wine@raven> touch ../shapelib/CMakeLists.txt
5.
wine@raven> make build_shapelib-update_build_system
[ 50%] Generating build_projects/Source/build_shapelib/CMakeLists.txt
[100%] Updating build system
[100%] Built target build_shapelib-update_build_system
6.
wine@raven> make build_shapelib-update_build_system
[ 50%] Updating build system
[100%] Built target build_shapelib-update_build_system
7.
wine@raven> make build_shapelib-update_build_system
[100%] Built target build_shapelib-update_build_system
Why do two build steps (6 and 7) have to be done to satisfy the file
depends after the touch? I must be doing something wrong with the
file depends above, but I cannot see what it is.
This is a simple example of a more important issue where the
complete build shows the same behaviour. After the touch,
the first make does a complete rebuild, but then so does
the second. And it is only the third that shows no build activity.
Alan
__________________________
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________
Linux-powered Science
__________________________
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake