[CMake] Fwd: controlling which instantiations to make for given templates

Eric Noulard eric.noulard at gmail.com
Thu Mar 19 10:45:23 EDT 2009


Re-transfer,
I did dropped the list


---------- Forwarded message ----------
From: Eric Noulard <eric.noulard at gmail.com>
Date: 2009/3/19
Subject: Re: [CMake] controlling which instantiations to make for
given templates
To: Hicham Mouline <hicham at mouline.org>


2009/3/19 Hicham Mouline <hicham at mouline.org>:
> Hello,
> we have a number of projects, in some of them, we have translation units that define member functions of template classes,
> and at the bottom we have explicit template instantiations of those templates:
> template class Templ<ArgList1>;
> template class Templ<ArgList2>;
>
> it turns out under VS2005/2008 we only need the instantiation with Templ<ArgList1>
> while under gcc3 we need Templ<ArgList2>
>
> I saw some aux sources command in cmake that considers a "Template" subdir, but we don't wish to use this method.
> Is there any other feature of cmake to help with this?
> Otherwise, we will use processor defines to test which env and then choose the appropriate instantiation.

I think that in this case compiler specific pre-defined MACRO is the way to go
see: http://predef.sourceforge.net/precomp.html

for gcc
http://predef.sourceforge.net/precomp.html#sec14
and MSVC
http://predef.sourceforge.net/precomp.html#sec34

CMake provides you with
CMAKE_COMPILER_IS_GNUCC
and
MSVC*
see
http://www.cmake.org/Wiki/CMake_Useful_Variables#System_.26_Compiler_Information

But then you'll have to CONFIGURE_FILE and/or ADD_DEFINITION in order
select what you want.


--
Erk



-- 
Erk


More information about the CMake mailing list