[CMake] CheckLibraryExists requires C Compiler

Hannes Hauswedell h2+lists2016 at fsfe.org
Sun Jan 31 09:21:55 EST 2016


Dear CMake-Hackers,

I have a project which is purely C++. We have recently switched from

project (FOO)

to

project (FOO CXX)

so that we don't depend on CMAKE_C_COMPILER being set. This has broken
our BZip2 detection:

-- Found BZip2: /usr/lib/x86_64-linux-gnu/libbz2.so (found version "1.0.6")
-- Looking for BZ2_bzCompressInit in /usr/lib/x86_64-linux-gnu/libbz2.so
CMake Error at /usr/share/cmake-3.0/Modules/CheckLibraryExists.cmake:52
(try_compile):
  Unknown extension ".c" for file

    /usr/share/cmake-3.0/Modules/CheckFunctionExists.c

  try_compile() works only for enabled languages.  Currently these are:

    CXX

  See project() command to enable other languages.
Call Stack (most recent call first):
  /usr/share/cmake-3.0/Modules/FindBZip2.cmake:60 (CHECK_LIBRARY_EXISTS)

Note that this is fixed in cmake-3.4 by
https://github.com/Kitware/CMake/commit/23876eda9f1d4b5725407aef7d218fc3ce4113cb
because the CheckLibraryExists is removed. However I depend on shipping
the software on platforms with cmake>=3.0 so this doesn't help.

I have tried to set
SET_SOURCE_FILES_PROPERTIES(CheckFunctionExists.c PROPERTIES LANGUAGE CXX)
but this doesn't help, either.

Is there any workaround for this problem?

And isn't requiring C_COMPILER in CheckLibraryExists a bug? IMHO it
should check CMAKE_C_COMPILER_LOADED and use cxx otherwise...

Thank you for your help!
-- 
Best regards,
Hannes Hauswedell
Free Software Foundation Europe -- German Team

pgp-key:
https://blogs.fsfe.org/h2/files/2015/09/hannes_hauswedell_public_key.asc
fingerprint: FC35 7547 7916 DA55 DC42 27EA 1D57 8E18 A109 60BF

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160131/32bb7c5e/attachment.sig>


More information about the CMake mailing list