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.
<<attachment: loose.vcf>>
-- 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
