Subject: Re: [Cmake] howto add *.cpp sources
Karr, David
David . Karr at titan . com
Wed, 30 Jul 2003 16:15:52 -0400
Sebastien BARRE <sebastien . barre at kitware . com> wrote:
> At 7/29/2003 10:40 AM, Jan Woetzel wrote:
> >
> >I want to add all *.cpp files to a variable SRC and all=20
> headers *.hh to=20
> >HEADER.
>=20
> Possible with 1.6, but it is tricky, and was tested for Msdev=20
> compilers only.
> I had to write 2 macros.
>=20
> 1) GET_SPECIAL_COMPILE_FLAGS_TO_FORCE_CPP
> [...] to force a source file to be compiled as C++. [...]
>=20
> 2) FIX_MSDEV_EXTENSION_SUPPORT_IN_REGISTRY
> [...] actually patches your registery on Windows to have=20
> Msdev6 support that extension as a C++ file. [...]
>=20
> Here is how to use the macros (for .cc files, but this is the=20
> same scheme=20
> for .cpp)
Are you sure you need to do all this for *.cpp? I've been
building .cpp files for a couple of years in Visual Studio 6.0
and never had to force any compilation or tweak the registry--
just install Msdev and it already "knows" a bunch of C++
extensions, including .cpp, .cxx, and .c. The extension .cc
does NOT appear to be in that default list; I'll hazard a
very uneducated guess that that's why you ended up with such
tricky macros, and that they aren't needed for *.cpp.
> FOREACH (sfile
> dcmhmod.cc
> dcstrmpl.cc
> )
> SET (SRCS ${SRCS} ${sfile})
> [...]
> ENDFOREACH (sfile)
Wouldn't the following work just as well?
SET(SRCS
dcmhmod.cpp
dcstrmpl.cpp
)
FOREACH (sfile $(SRCS)
[...]
ENDFOREACH (sfile)
In fact that's what I ended up doing in order to put several
hundred .cpp files into a CMake build, except I didn't need
the FOREACH part, for the reasons I mentioned.
Of course it's already been discussed that if you literally
want to write the string "*.cpp" in your CMakeLists.txt=20
instead of writing the actual names of all the source files
one by one, you need a version of CMake later than 1.6.
-- David