[cmake-developers] CheckSymbolExists.cmake

Brad King brad.king at kitware.com
Thu Jun 6 10:42:21 EDT 2013


On 06/06/2013 10:37 AM, Christopher Sean Morrison wrote:
>> $ cat symbol_main.c
>> #include <stdio.h> /* declares tested symbol */
>> extern int cmakeRequireSymbol(int, ...);
>> int main(int argc, const char* argv[]) { return cmakeRequireSymbol(argc, &printf); }
>>
>> $ cat symbol_impl.c
>> int cmakeRequireSymbol(int x, ...) { return x; }
> 
> This sounds looks like the best option to me, better than
> casting through an integer.
> 
> Want me to work up a patch or is someone already on it?

It will be simpler if we first extend the try_compile command
to support multiple source files in the "source file" signature
so we do not need to construct a full source tree and write the
CMakeLists.txt by hand for the check.

Recently in master I merged some refactoring of the try_compile
command argument processing so it should now be straightforward
to add more options.  Currently the signatures are

 try_compile(RESULT_VAR <bindir> <srcdir> <projectName> ...) #dir
 try_compile(RESULT_VAR <bindir> <srcfile> ...) #file

Perhaps we should add

 try_compile(RESULT_VAR <bindir> SOURCES <src>... ...)

Would you be able to try all that?

Thanks,
-Brad



More information about the cmake-developers mailing list