<div class="gmail_quote">On Fri, Jan 29, 2010 at 4:07 PM, Brian Davis <span dir="ltr">&lt;<a href="mailto:bitminer@gmail.com">bitminer@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
ExternalProject_Add does not like BINARY_DIR same for multiple packages... Why?<br></blockquote><div><br></div><div>To avoid one package&#39;s output from clobbering another package&#39;s output. For CMake built projects, for example, the BINARY_DIR is where CMakeCache.txt ends up. There can only be one CMakeCache.txt in a directory, so there can only be one project for each BINARY_DIR.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">SET( THIRD_PARTY_PACKAGES<br>    vtk-5.4.2<br>    dcmtk-3.5.4<div class="im"><br>    boost-cmake-1_41_0  <br>
</div>)<br><br>foreach( PACKAGE in ${THIRD_PARTY_PACKAGES} )<br>
<br>    ExternalProject_Add(<br>        ${PACKAGE}<br>        DOWNLOAD_COMMAND &quot;&quot;<br>        SOURCE_DIR ${TOP}/source/cpp/lib/3rdParty/Win/${PACKAGE}<br>        BINARY_DIR ${BUILD_DIR}/ouput/bin<br>        INSTALL_DIR ${INSTALL_PREFIX}<br>

    )<br><br>endforeach( PACKAGE )<br></blockquote><div><br></div><div>Instead of &quot;BINARY_DIR ${BUILD_DIR}/ouput/bin&quot;, try:</div><div><br></div><div>        BINARY_DIR ${BUILD_DIR}/${PACKAGE}<br></div><div><br>
</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">from VS Studio I get:<br><br>1&gt;1&gt;CMake Error at cmake_install.cmake:31 (FILE):<br>1&gt;1&gt;  file cannot create directory: C:/Program Files (x86)/VTK/lib/vtk-5.4.<br>
<br>and reading http:///<a href="http://www.kitware.com/products/archive/" target="_blank">www.kitware.com/products/archive/</a><em>kitware_quarterly1009</em>.<em>pdf</em> excerpt:<br>
<br><br>Install step<br>The INSTALL_DIR is underneath the calling project’s binary<br>directory. Use INSTALL_DIR to specify a different location.<br>Note that in addition to setting INSTALL_DIR, you also have<br>to pass -DCMAKE_INSTALL_PREFIX or --prefix to the CMake<br>

or configure command. It is not used automatically in the<br>configure step since not all projects follow this convention.<br><br># [INSTALL_DIR dir]<br><br><br>My projects must fall into the &quot;not all projects follow this convention&quot;, but wait Kitware makes vtk and Kitware makes Cmake.  Is Kitware not following it&#39;s own convention here or is something else going on?<br>
</blockquote><div><br></div><div>&quot;Kitware projects&quot; are built with CMake and all use CMAKE_INSTALL_PREFIX to determine the install directory. You should use CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}</div>
<div>for &quot;Kitware projects&quot;</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br>I also get when I build dcmtk:<br><br>1&gt;CMake Error: The source &quot;C:/projects/NIH2009/source/branches/trunk/source/cpp/lib/3rdParty/Win/dcmtk-3.5.4/CMakeLists.txt&quot; does not match the source &quot;C:/projects/NIH2009/source/branches/trunk/source/cpp/lib/3rdParty/Win/vtk-5.4.2/CMakeLists.txt&quot; used to generate cache.  Re-run cmake with a different source directory.<br>
</blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Looks like there is some CMake cache cross mojonation going on here</blockquote><div><br></div>
<div>This is because of using the same BINARY_DIR for multiple ExternalProject_Add calls.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I guess I&#39;ll try:<br><br>    ExternalProject_Add(<br>        ${PACKAGE}<br>        DOWNLOAD_COMMAND &quot;&quot;<br>        SOURCE_DIR ${TOP}/source/cpp/lib/3rdParty/Win/${PACKAGE}<br>
#        BINARY_DIR ${BUILD_DIR}/ouput/bin<br>        INSTALL_DIR ${INSTALL_PREFIX}<br>        CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}<br>    )<br><br>as:<br><br>C:\projects\NIH2009\source\branches\trunk\platform\tools\cmake-2.8.0-win32-x86\bin&gt;cmake --help-module ExternalProject<div class="im">
<br>
cmake version 2.8.0<br></div>  ExternalProject<br>       Create custom targets to build projects in external trees<br><br>       The &#39;ExternalProject_Add&#39; function creates a custom target to drive<br>       download, update/patch, configure, build, install and test steps of an<br>

       external project:<br><br>         ExternalProject_Add(&lt;name&gt;    # Name for custom target<br>           [DEPENDS projects...]       # Targets on which the project depends<br>           [PREFIX dir]                # Root dir for entire project<br>

           [LIST_SEPARATOR sep]        # Sep to be replaced by ; in cmd lines<br>           [TMP_DIR dir]               # Directory to store temporary files<br>           [STAMP_DIR dir]             # Directory to store step timestamps<br>

          #--Download step--------------<br>           [DOWNLOAD_DIR dir]          # Directory to store downloaded files<br>           [DOWNLOAD_COMMAND cmd...]   # Command to download source tree<br>           [CVS_REPOSITORY cvsroot]    # CVSROOT of CVS repository<br>

           [CVS_MODULE mod]            # Module to checkout from CVS repo<br>           [CVS_TAG tag]               # Tag to checkout from CVS repo<br>           [SVN_REPOSITORY url]        # URL of Subversion repo<br>           [SVN_REVISION rev]          # Revision to checkout from Subversion repo<br>

           [URL /.../src.tgz]          # Full path or URL of source<br>          #--Update/Patch step----------<br>           [UPDATE_COMMAND cmd...]     # Source work-tree update command<br>           [PATCH_COMMAND cmd...]      # Command to patch downloaded source<br>

          #--Configure step-------------<br>           [SOURCE_DIR dir]            # Source dir to be used for build<br>           [CONFIGURE_COMMAND cmd...]  # Build tree configuration command<br>           [CMAKE_COMMAND /.../cmake]  # Specify alternative cmake executable<br>

           [CMAKE_GENERATOR gen]       # Specify generator for native build<br>           [CMAKE_ARGS args...]        # Arguments to CMake command line<br>          #--Build step-----------------<br>           [BINARY_DIR dir]            # Specify build dir location<br>

           [BUILD_COMMAND cmd...]      # Command to drive the native build<br>           [BUILD_IN_SOURCE 1]         # Use source dir for build dir<br>          #--Install step---------------<br>           [INSTALL_DIR dir]           # Installation prefix<br>

           [INSTALL_COMMAND cmd...]    # Command to drive install after build<br>          #--Test step---------------<br>           [TEST_BEFORE_INSTALL 1]     # Add test step executed before install step<br>           [TEST_AFTER_INSTALL 1]      # Add test step executed after install step<br>

           [TEST_COMMAND cmd...]       # Command to drive test<br>           )<br><br>       The *_DIR options specify directories for the project, with default<br>       directories computed as follows.  If the PREFIX option is given to<br>

       ExternalProject_Add() or the EP_PREFIX directory property is set, then<br>       an external project is built and installed under the specified prefix:<br><br>          TMP_DIR      = &lt;prefix&gt;/tmp<br>          STAMP_DIR    = &lt;prefix&gt;/src/&lt;name&gt;-stamp<br>

          DOWNLOAD_DIR = &lt;prefix&gt;/src<br>          SOURCE_DIR   = &lt;prefix&gt;/src/&lt;name&gt;<br>          BINARY_DIR   = &lt;prefix&gt;/src/&lt;name&gt;-build<br>          INSTALL_DIR  = &lt;prefix&gt;<br><br>
       Otherwise, if the EP_BASE directory property is set then components of<br>
       an external project are stored under the specified base:<br><br>          TMP_DIR      = &lt;base&gt;/tmp/&lt;name&gt;<br>          STAMP_DIR    = &lt;base&gt;/Stamp/&lt;name&gt;<br>          DOWNLOAD_DIR = &lt;base&gt;/Download/&lt;name&gt;<br>

          SOURCE_DIR   = &lt;base&gt;/Source/&lt;name&gt;<br>          BINARY_DIR   = &lt;base&gt;/Build/&lt;name&gt;<br>          INSTALL_DIR  = &lt;base&gt;/Install/&lt;name&gt;<br><br>       If no PREFIX, EP_PREFIX, or EP_BASE is specified then the default is<br>

       to set PREFIX to &quot;&lt;name&gt;-prefix&quot;.  Relative paths are interpreted with<br>       respect to the build directory corresponding to the source directory<br>       in which ExternalProject_Add is invoked.<br>

<br>       If SOURCE_DIR is explicitly set to an existing directory the project<br>       will be built from it.  Otherwise a download step must be specified<br>       using one of the DOWNLOAD_COMMAND, CVS_*, SVN_*, or URL options.  The<br>

       URL option may refer locally to a directory or source tarball, or<br>       refer to a remote tarball (e.g.  http://.../src.tgz).<br><br>       The &#39;ExternalProject_Add_Step&#39; function adds a custom step to an<br>

       external project:<br><br>         ExternalProject_Add_Step(&lt;name&gt; &lt;step&gt; # Names of project and custom step<br>           [COMMAND cmd...]        # Command line invoked by this step<br>           [COMMENT &quot;text...&quot;]     # Text printed when step executes<br>

           [DEPENDEES steps...]    # Steps on which this step depends<br>           [DEPENDERS steps...]    # Steps that depend on this step<br>           [DEPENDS files...]      # Files on which this step depends<br>           [ALWAYS 1]              # No stamp file, step always runs<br>

           [WORKING_DIRECTORY dir] # Working directory for command<br>           )<br><br>       The command line, comment, and working directory of every standard and<br>       custom step is processed to replace tokens &lt;SOURCE_DIR&gt;, &lt;BINARY_DIR&gt;,<br>

       &lt;INSTALL_DIR&gt;, and &lt;TMP_DIR&gt; with corresponding property values.<br><br>       The &#39;ExternalProject_Get_Property&#39; function retrieves external project<br>       target properties:<br><br>         ExternalProject_Get_Property(&lt;name&gt; [prop1 [prop2 [...]]])<br>

<br>       It stores property values in variables of the same name.  Property<br>       names correspond to the keyword argument names of<br>       &#39;ExternalProject_Add&#39;.<br><br><br>       Defined in: C:/projects/NIH2009/source/branches/trunk/platform/tools/cmake-2.8.0-win32-x86/share/cmake-2.8/Modules/ExternalProject.cmake<br>

<br>Leads me to believe that I should use CMAKE_ARGS<br><br></blockquote><div><br></div><div><br></div><div>Is it getting any easier yet...?</div><div><br></div><div>Hopefully this is helpful,</div><div>David</div><div><br>
</div></div>