[CMake] External_Project_Add() and custom build configurations ?
David Cole
david.cole at kitware.com
Thu Jul 7 10:15:13 EDT 2011
On Thu, Jul 7, 2011 at 7:36 AM, Glenn Coombs <glenn.coombs at gmail.com> wrote:
> On 6 July 2011 17:27, David Cole <david.cole at kitware.com> wrote:
>
>> (Don't know if you meant to omit the CMake mailing list on that, or if
>> that was on oversight.... Feel free to put my responses back on list if you
>> wish.)
>
>
> Oops, no I didn't mean to omit the mailing list.
>
>
> One more point: ExternalProject is completely and fully customizable. You
>> could certainly add a "clean" step to any ExternalProject that you like. Or
>> you could define a "clean_externals" at the top level that goes and cleans
>> everything. If you can figure out the right clean sub-commands.....
>>
>
> I'm not sure but wouldn't getting clean to work with Visual Studio require
> changes to the generator code to add hooks in the vcproj files on either the
> BeforeClean or AfterClean events ? As far as I can tell Visual Studio cleans
> a project by deleting the files it thinks the project creates. For normal
> C/C++ projects this works as expected but for external projects the created
> files are not known in the external project vcproj file. However, they are
> known in the subdirectory external project vcproj file. To clarify, in my
> case the external project has these 2 vcproj files:
>
> <buildDir>/external_proj.vcproj
> <buildDir>/external_proj/src/external_proj-build/myProjName.vcproj
>
> The top level external_proj.vcproj file only contains a folder of
> CMakeBuildRules which specify custom build commands for each of the
> configure, build, install etc. steps. When this top level project is built
> it invokes cmake --build <buildDir>/external_proj/src/external_proj-build to
> do the actual build.
>
> If I clean external_proj then it has no idea what to delete under the
> <buildDir>/external_proj/src/external_proj-build directory. But if cmake
> had hooked the AfterClean event on external_proj and then called cmake
> --build <buildDir>/external_proj/src/external_proj-build --target clean then
> that would get Visual Studio to clean the lower level myProjName.vcproj
> which does know which files to clean because it is a normal C/C++ project.
>
> The top level external_proj is the only one visible in Visual Studio. The
> lower level myProjName is not visble in Visual Studio but it is the only one
> that knows how to do the clean. If the top level one forwarded the clean to
> it then everything would work.
>
> I haven't checked but I suspect the same thing would work for the Makefile
> generators. The top level "make clean" would just call "make clean" on the
> lower level makefile.
>
> --
> Glenn
>
>
I'm sure that what you want to do is possible. I'm also sure that it's a
huge effort to get it to work with all CMake generators. It will also be
difficult to write a good test of the functionality.
Furthermore, I view it as largely unnecessary work...
...because a full file-system-level clean of deleting the entire build tree,
followed by a quick configure with CMake of the top level project, followed
by a regular build has largely the same net result with negligible
difference in total build time. If the difference in total build time is
non-negligible, and really annoying to somebody, then this huge effort may
well be worth it to them, at that point in time.
Right now, I'm not convinced the extra effort and extra complications in the
code are worthwhile additions to CMake.
Respectfully,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110707/b26cd31a/attachment-0001.htm>
More information about the CMake
mailing list