[CMake] CMAKE_<languageName>_COMPILER_WORKS no longer cached?!
Marcel Loose
loose at astron.nl
Fri Jun 7 10:33:45 EDT 2013
Hi all,
I noticed that, as of CMake 2.8.10, the variable
CMAKE_<languageName>_COMPILER_WORKS is no longer cached. This breaks
some of my code.
I have wrapped find_package() into a my own project-specific
CMake-function <myproject>_find_package(). In one of my Find*.cmake
files I do a enable_language(Fortran) and check the value of
CMAKE_Fortran_COMPILER_WORKS. The thing is, this works when this Find*
macro is called for the first time, but not for subsequent calls; and I
think it is caused by the fact that CMAKE_Fortran_COMPILER_WORKS is no
longer cached.
Stripping away the irrelevant parts of my Find module, here's what remains:
# Enable the Fortran compiler, if that has not been done yet.
get_property(_enabled_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
if(NOT _enabled_languages MATCHES Fortran)
# Work-around for CMake issue #9220
if(CMAKE_Fortran_COMPILER MATCHES "^$")
set(CMAKE_Fortran_COMPILER CMAKE_Fortran_COMPILER-NOTFOUND)
endif(CMAKE_Fortran_COMPILER MATCHES "^$")
enable_language(Fortran)
endif(NOT _enabled_languages MATCHES Fortran)
# Check if we have a working Fortran compiler
if(CMAKE_Fortran_COMPILER_WORKS)
# Do some fancy stuff.
else(CMAKE_Fortran_COMPILER_WORKS)
message(SEND_ERROR "A working Fortran compiler is required!")
endif(CMAKE_Fortran_COMPILER_WORKS)
When this Find module is called for the first time by
<myproject>_find_package(), the "Do some fancy stuff" is done. On
subsequent calls, however, the error is triggered, because
CMAKE_Fortran_COMPILER_WORKS is empty.
What's the correct way of handling this, without breaking backward
compatibility?
Best regards,
Marcel Loose.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: loose.vcf
Type: text/x-vcard
Size: 292 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130607/ad022abc/attachment.vcf>
More information about the CMake
mailing list