[CMake] What is the proper way to handle additional non-object files generated by compilation?
Maik Beckmann
beckmann.maik at googlemail.com
Fri May 23 03:31:40 EDT 2008
Am Freitag 23 Mai 2008 08:57:21 schrieb Alan W. Irwin:
> On 2008-05-23 07:07+0200 Maik Beckmann wrote:
> >
> > All target directories, Fortran or not, contain a cmake_clean.cmake,
> > i.e. CMakeFiles/foolib.dir/cmake_clean.cmake
> > which in turn contains
> > {{{
> > #...
> > # Per-language clean rules from dependency scanning.
> > FOREACH(lang Fortran)
> > INCLUDE(CMakeFiles/libfoo.dir/cmake_clean_${lang}.cmake OPTIONAL)
> > ENDFOREACH(lang)
> > }}}
> >
> > The CMakeFiles/foolib.dir/cmake_clean_Fortran.cmake looks like this
> > {{{
> > # Remove fortran modules provided by this target.
> > FILE(REMOVE
> > "mathconstants.mod"
> > "MATHCONSTANTS.mod"
> > "CMakeFiles/wzl_fortran.dir/mathconstants.mod.stamp"
> >
> > # ... for all mod files
> > )
> > }}}
> >
> > I bet this is what you're searching for :o)
>
> Thanks for your response. Of course, what I would really like to know is
> how that list of *.mod files is set up by CMake. Does anybody here know
> that?
>
To get orientation, a grep at the cmake Sources dir:
{{{
CMake/Source$ find|xargs grep -n cmake_clean
./cmDependsFortran.cxx:270: fcName += "/cmake_clean_Fortran.cmake";
./cmLocalUnixMakefileGenerator3.cxx:1094: cleanfile += "/cmake_clean";
./cmLocalUnixMakefileGenerator3.cxx:1135:
<< "/cmake_clean_${lang}.cmake OPTIONAL)\n"
}}}
As you see there are two files involved and as we will see one function in
each of these files.
The member function cmLocalUnixMakefileGenerator3::AppendCleanCommand(..)
{{{
CMake/Source$ find|xargs grep -n ::AppendCleanCommand
./cmLocalUnixMakefileGenerator3.cxx:1085:::AppendCleanCommand(std::vector<std::string>&
commands,
}}}
will add Ada to the list of languages optionally providing a cleaner script,
if Ada is listed as a language of the target:
{{{
fout << "\n"
<< "# Per-language clean rules from dependency scanning.\n"
<< "FOREACH(lang";
for(std::set<cmStdString>::const_iterator l = languages.begin();
l != languages.end(); ++l)
{
fout << " " << *l;
}
...
}}}
The cleaner script itself can be provided provided somewhere else during the
cmake run. In case of Fortran cmDependsFortran::Finalize(..)
{{{
CMake/Source$ find|xargs grep -n cmDependsFortran::Finalize
./cmDependsFortran.cxx:216:bool cmDependsFortran::Finalize(std::ostream&
makeDepends,
}}}
does the job:
{{{
if(!provides.empty())
{
std::string fcName = this->TargetDirectory;
fcName += "/cmake_clean_Fortran.cmake";
...
}}}
HTH,
-- Maik
More information about the CMake
mailing list