On 5/25/2010 8:57 PM, Michael Hertling wrote:
On 05/25/2010 06:13 PM, Theodore Papadopoulo wrote:
In porting a library (blitz) from autoconf to cmake, I have the
sub-project of testing C++ compiler features.
The autoconf way was to create some C++ files and test that they are
compiling (and just compiling not linking).

TRY_COMPILE (in the variant that creates automatically the CMake
project) seems to oblige me to link the code.
Many of the tests (taken from autoconf) do not include a main(), some
the tests fail. Obviously, I can create a main,
but I wondered if there was an easy way to avoid the linking phase
(without having to create my own CMake project
for all those files).

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.

-Bill
_______________________________________________
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 via email to