[CMake] cmake-gui leaves CMAKE_<language>_COMPILER_WORKS undefined for simple test case and CMake-2.6.4

Alan W. Irwin irwin at beluga.phys.uvic.ca
Thu Jul 16 20:04:17 EDT 2009


On 2009-07-16 13:23-0700 Alan W. Irwin wrote:

> Hi David:
>
> [...] Your idea (for temporarily working around bug 9220)
> even takes care of the broken compiler case.  (My attempted workaround only
> took care of the missing compiler case.) I will implement that workaround
> for now for the PLplot build system [....]

For those following this thread, here is my first implementation of your
idea for this workaround.  When I uncommented the tests, I got

CXX_language_works = ON
CXXp_language_works = OFF

as expected.

*********
# cmake/modules/language_support.cmake
#
# Temporary additional general language support is contained within this
# file.

# This additional function definition is needed to provide a workaround for
# CMake bug 9220.

function(workaround_9220 language language_works)
   #message("DEBUG: language = ${language}")
   set(text
     "project(test NONE)
cmake_minimum_required(VERSION 2.6.0)
enable_language(${language} OPTIONAL)
"
     )
   file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/language_tests/${language})
   file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/language_tests/${language})
   file(WRITE ${CMAKE_BINARY_DIR}/language_tests/${language}/CMakeLists.txt
     ${text})
   execute_process(
     COMMAND ${CMAKE_COMMAND} .
     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/language_tests/${language}
     RESULT_VARIABLE return_code
     OUTPUT_QUIET
     ERROR_QUIET)
   if(return_code EQUAL 0)
     set(${language_works} ON PARENT_SCOPE)
   else(return_code EQUAL 0)
     set(${language_works} OFF PARENT_SCOPE)
   endif(return_code EQUAL 0)
endfunction(workaround_9220)

# Temporary tests of the above function.
#workaround_9220(CXX CXX_language_works)
#message("CXX_language_works = ${CXX_language_works}")
#workaround_9220(CXXp CXXp_language_works)
#message("CXXp_language_works = ${CXXp_language_works}")
*********

I hope this file (which I have also attached to bug 9220) will help someone
else looking for a workaround for the bug.

I now have further work to do to add copying of local language support files
when the language is Ada or D, but this first implementation that works both
for CXX (a.k.a C++) and the non-existing language CXXp shows I am well on
the way to a good general bug 9220 workaround for PLplot. I am looking
forward to giving our users a soft landing for the case where some of the
five compilers that can optionally be used to build various PLplot
components are broken or non-existent on their systems.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list