I have the same problem. The reason for the problem is that I am
comparing the speed of the exact same source code compiled by C and C++.
I have heard folk lore that C is faster, so I want an automated test to
check for this for an arbitrary hardware and compiler.
What I did was to create two source files, copied from the exact same
original file, but with the .c and .cpp extensions using CONFIGURE_FILE. See
https://projects.coin-or.org/CppAD/browser/trunk/compare_c/CMakeLists.txt
On 01/09/2013 02:27 AM, Andreas Pakulat wrote:
Hi,
On Wed, Jan 9, 2013 at 1:17 AM, kgardenia42 <[email protected]> wrote:
I am trying to write a CMakeLists.txt where the same source files are
compiled separately to both a C library and a C++ library.
So, lets say I have foo.c, bar.c and baz.c and I would like to build
mylib.a and mylib++.a
My intuition is to use one CMakefile and add multiple targets for each
library I want to build. Does that seem like a reasonable approach?
Other suggestions welcome. Also, can anyone point me to an open
source library that uses cmake and builds both a C and C++ version.
I'd say this does not make any sense. The mylib++.a will still be a C
library because all the compiled code in it will be C code unless your
c files are somehow using a preprocessor macro to enable C and C++
code. And if they I'd say you'd be better off to split the files into
a .c and a .cpp one and drop the macro.
A C++ program can link to C libraries just fine, so there's really no
need for that that I can see right now.
Andreas
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake