[CMake] TRY_COMPILE without linking...

Theodore Papadopoulo Theodore.Papadopoulo at sophia.inria.fr
Wed May 26 12:10:25 EDT 2010


On 05/26/2010 04:03 AM, Bill Hoffman wrote:
> On 5/25/2010 8:57 PM, Michael Hertling wrote:
>> Use the CMAKE_FLAGS of TRY_COMPILE() to pass in a no-op for the linker:
>>
>> TRY_COMPILE(...
>>      CMAKE_FLAGS "-DCMAKE_CXX_LINK_EXECUTABLE='echo not linking now...'"
>> ...)
>
>
> That will not work with Xcode and VS.  The best you can do with those 
> generators is to create a static library instead of a linked executable.
>
Good point... So I ended up adding main to all tests...
Thank's a lot.

In case this interests somebody, I attach my current version of the C++ 
tests in this mail
(this is clearly work in progress, needs some cleaning and some 
improvement -- such as limiting
the number of times it is launched -- but if there are useful comments 
I'll take them).

Usage: dump the directory under your project, add these lines to your 
project:

SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
INCLUDE(CheckCXXFeatures)
CHECK_ALL_CXX_FEATURES(BZ_)

The BZ_ is a prefix to add to all the various variables defined by this 
"module".
This is maybe misplaced but allows generated config.h of various project 
to not conflict...

     Theo.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CheckCXXFeatures.tgz
Type: application/x-compressed-tar
Size: 15848 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100526/e8157c9d/attachment.bin>


More information about the CMake mailing list