[CMake] Re: ...TRY_COMPILE ...

Brad King brad.king at kitware.com
Thu Feb 23 14:21:48 EST 2006


Walter E Brown wrote:
>  > >Why does TRY_COMPILE not only compile but also try to link the code? 
> Actually
>  > >compilng only would be enough to run most tests and would also be a bit
>  > >faster if you avoid linking.
>  >Sometimes that is the only way to make sure something actually 
> compiles and works.
> 
> I do not deny the truth of the claim, but am strongly opposed to the lie 
> expressed by the choice of name.  If the command is named TRY_COMPILE, 
> then I expect it to try to compile and no more.  The current behavior is 
> certainly useful, but I expect it to be named TRY_COMPILE_AND_LINK.  The 
> ability to discriminate between a failed compilation attempt and a 
> failed link attempt is useful, and I see no reason to avoid providing 
> both capabilities.

You may submit feature requests here:

http://www.cmake.org/Bug

> 1) I want the ability, at make time as opposed to cmake time, to compile 
> a file without being forced to link it or to make it part of a library. 
>  If this ability exists today, I for one do not know how to do so.

If you mean to generate a project that when built produces an object 
file and no library or executable then you'll have to submit a feature 
request that shows how to do this in Visual Studio and Xcode with a 
manually created project.

If you just want to compile an object file that is part of another 
target without linking the target then you can do

make myobject.o

or in Visual Studio right-click on the source file and choose "Compile".

-Brad


More information about the CMake mailing list