CHECK_CXX_SOURCE_COMPILES attempts linking

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

CHECK_CXX_SOURCE_COMPILES attempts linking

John Smith-6
It seems that CHECK_CXX_SOURCE_COMPILES attempts to link the object
files into an executable:

[...]
Performing C++ SOURCE FILE Test <sometest> failed with the following output:
Change Dir: /my-proj/builddir/CMakeFiles/CMakeTmp

Run Build Command:/usr/bin/gmake "cmTryCompileExec/fast"
[...]
gmake[1]: Entering directory `/my-proj/builddir/CMakeFiles/CMakeTmp'
[...]
Building CXX object CMakeFiles/cmTryCompileExec.dir/src.cxx.o
[...]
Linking CXX executable cmTryCompileExec
[...]
/usr/lib64/gcc/x86_64-slamd64-linux/4.1.2/../../../../lib/crt1.o: In
function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
[...]
Source file was:

#include <string.h>
bool ignore = &strerror_r != 0;

[...]

IMHO, the macro should only attempt to compile the source file. Is
this by design or by accident? If by design, what is the rationale
behind it?

Thanks.

-J
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: CHECK_CXX_SOURCE_COMPILES attempts linking

Alexander Neundorf-3
On Thursday 03 September 2009, John Smith wrote:
> It seems that CHECK_CXX_SOURCE_COMPILES attempts to link the object
> files into an executable:

Yes. Sometimes having it only compile but not link would be nice, but that's
not the case.
You can specifiy libraries to link to, so it should be possible to get it
linking.
Or just add an empty main() ?

Alex
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: CHECK_CXX_SOURCE_COMPILES attempts linking

John Smith-6
Alexander Neundorf wrote:
> On Thursday 03 September 2009, John Smith wrote:
>> It seems that CHECK_CXX_SOURCE_COMPILES attempts to link the object
>> files into an executable:
>
> Yes. Sometimes having it only compile but not link would be nice, but that's
> not the case.

So, this is not by design, instead it is an artifact of the implementation?


> You can specifiy libraries to link to, so it should be possible to get it
> linking.

That is true. But what is the obstacle to implementing the macro such
that it just does compilation (as the name suggests) and not compilation
and linking?

Thanks!


_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: CHECK_CXX_SOURCE_COMPILES attempts linking

Alexander Neundorf-3
On Saturday 05 September 2009, you wrote:

> Alexander Neundorf wrote:
> > On Thursday 03 September 2009, John Smith wrote:
> >> It seems that CHECK_CXX_SOURCE_COMPILES attempts to link the object
> >> files into an executable:
> >
> > Yes. Sometimes having it only compile but not link would be nice, but
> > that's not the case.
>
> So, this is not by design, instead it is an artifact of the implementation?
>
> > You can specifiy libraries to link to, so it should be possible to get it
> > linking.
>
> That is true. But what is the obstacle to implementing the macro such
> that it just does compilation (as the name suggests) and not compilation
> and linking?

(without checking) I think it creates a small project, where the
CMakeLists.txt uses add_executable(). This links.
There is not cmake command which only compiles, but not links.
add_library(STATIC) may be close.

Alex
_______________________________________________
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