From: <ai...@us...> - 2009-06-30 01:03:39
|
Revision: 10096 http://plplot.svn.sourceforge.net/plplot/?rev=10096&view=rev Author: airwin Date: 2009-06-30 01:03:14 +0000 (Tue, 30 Jun 2009) Log Message: ----------- Work around CMake enable_language(<language> OPTIONAL) bug (where it errors out for missing or bad compilers rather than returning with CMAKE_<languageName>_COMPILER_WORKS as a status). The idea of the workaround is to first search for the compiler. If it does not exist then disable the appropriate component of PLplot with a WARNING message. Only if the compiler exists is there an attempt made to run the CMake enable_language language command to check the compiler. N.B. This workaround only works if the compiler is completely missing. Ada is ideosyncratic so this workaround does not solve the issue in that case. Also, this workaround does not solve the issue for existing but bad compilers that give results that fail for the try_compile that is run by the enable_language command. Modified Paths: -------------- trunk/cmake/modules/ada.cmake trunk/cmake/modules/c++.cmake trunk/cmake/modules/d.cmake trunk/cmake/modules/fortran.cmake trunk/cmake/modules/java.cmake trunk/examples/plplot_configure.cmake_installed_examples.in Modified: trunk/cmake/modules/ada.cmake =================================================================== --- trunk/cmake/modules/ada.cmake 2009-06-29 20:23:11 UTC (rev 10095) +++ trunk/cmake/modules/ada.cmake 2009-06-30 01:03:14 UTC (rev 10096) @@ -25,7 +25,17 @@ option(ENABLE_ada "Enable Ada bindings" ON) endif(DEFAULT_NO_BINDINGS) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_ada) + include(CMakeDetermineAdaCompiler) + if(NOT CMAKE_Ada_COMPILER) + message(STATUS "WARNING: Ada compiler not found so disabling Ada bindings and examples.") + set(ENABLE_ada OFF CACHE BOOL "Enable Ada bindings" FORCE) + endif(NOT CMAKE_Ada_COMPILER) +endif(ENABLE_ada) + +if(ENABLE_ada) # Find and check Ada compiler enable_language(Ada OPTIONAL) if(NOT CMAKE_Ada_COMPILER_WORKS) @@ -35,13 +45,6 @@ endif(ENABLE_ada) if(ENABLE_ada) - if(NOT CMAKE_Ada_COMPILER) - message(STATUS "WARNING: Ada compiler not found so disabling Ada bindings and examples.") - set(ENABLE_ada OFF CACHE BOOL "Enable Ada bindings" FORCE) - endif(NOT CMAKE_Ada_COMPILER) -endif(ENABLE_ada) - -if(ENABLE_ada) find_library(GNAT_LIB NAMES gnat gnat-4.1 gnat-4.2 gnat-4.3 gnat-4.4) if(NOT GNAT_LIB) message(STATUS "WARNING: " Modified: trunk/cmake/modules/c++.cmake =================================================================== --- trunk/cmake/modules/c++.cmake 2009-06-29 20:23:11 UTC (rev 10095) +++ trunk/cmake/modules/c++.cmake 2009-06-30 01:03:14 UTC (rev 10096) @@ -28,27 +28,38 @@ OPTION(ENABLE_cxx "Enable C++ bindings" ON) endif(DEFAULT_NO_BINDINGS) -# Always carry out C++ checks, since some drivers also use these as -# well as the C++ bindings +# Always carry out C++ checks, since C++ used for more than just +# C++ bindings. +set(alwayscxx ON) -# Find and check C++ compiler. -enable_language(CXX OPTIONAL) - -if(NOT CMAKE_CXX_COMPILER_WORKS) - # This is fatal error message rather than a warning because C++ absolutely - # required for check_prototype_exists test (and perhaps other preliminary - # tests as well). - message(FATAL_ERROR "No working C++ compiler found so PLplot cannot be built.") - set(ENABLE_cxx OFF CACHE BOOL "Enable C++ bindings" FORCE) -endif(NOT CMAKE_CXX_COMPILER_WORKS) - -if(ENABLE_cxx) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. +if(alwayscxx OR ENABLE_cxx) + include(CMakeDetermineCXXCompiler) if(NOT CMAKE_CXX_COMPILER) + # This is FATAL_ERROR rather than STATUS message because C++ absolutely + # required for check_prototype_exists test (and perhaps other preliminary + # tests as well). + message(FATAL_ERROR "C++ compiler absolutely required to build this project.") message(STATUS "WARNING: C++ compiler not found so disabling C++ bindings and examples.") set(ENABLE_cxx OFF CACHE BOOL "Enable C++ bindings" FORCE) endif(NOT CMAKE_CXX_COMPILER) -endif(ENABLE_cxx) +endif(alwayscxx OR ENABLE_cxx) +if(alwayscxx OR ENABLE_cxx) + # Find and check C++ compiler. + enable_language(CXX OPTIONAL) + + if(NOT CMAKE_CXX_COMPILER_WORKS) + # This is FATAL_ERROR rather than STATUS message because C++ absolutely + # required for check_prototype_exists test (and perhaps other preliminary + # tests as well). + message(FATAL_ERROR "C++ compiler absolutely required to build this project.") + message(STATUS "No working C++ compiler found so PLplot cannot be built.") + set(ENABLE_cxx OFF CACHE BOOL "Enable C++ bindings" FORCE) + endif(NOT CMAKE_CXX_COMPILER_WORKS) +endif(alwayscxx OR ENABLE_cxx) + # Check if "using namespace std;" works INCLUDE(TestForNamespace) Modified: trunk/cmake/modules/d.cmake =================================================================== --- trunk/cmake/modules/d.cmake 2009-06-29 20:23:11 UTC (rev 10095) +++ trunk/cmake/modules/d.cmake 2009-06-30 01:03:14 UTC (rev 10096) @@ -28,7 +28,17 @@ option(ENABLE_d "Enable D bindings" OFF) endif(DEFAULT_NO_BINDINGS) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_d) + include(CMakeDetermineDCompiler) + if(NOT CMAKE_D_COMPILER) + message(STATUS "WARNING: D compiler not found so disabling D bindings and examples.") + set(ENABLE_d OFF CACHE BOOL "Enable D bindings" FORCE) + endif(NOT CMAKE_D_COMPILER) +endif(ENABLE_d) + +if(ENABLE_d) # Find and check D compiler enable_language(D OPTIONAL) if(NOT CMAKE_D_COMPILER_WORKS) @@ -37,10 +47,3 @@ endif(NOT CMAKE_D_COMPILER_WORKS) endif(ENABLE_d) -if(ENABLE_d) - if(NOT CMAKE_D_COMPILER) - message(STATUS "WARNING: D compiler not found so disabling D bindings and examples.") - set(ENABLE_d OFF CACHE BOOL "Enable D bindings" FORCE) - endif(NOT CMAKE_D_COMPILER) -endif(ENABLE_d) - Modified: trunk/cmake/modules/fortran.cmake =================================================================== --- trunk/cmake/modules/fortran.cmake 2009-06-29 20:23:11 UTC (rev 10095) +++ trunk/cmake/modules/fortran.cmake 2009-06-30 01:03:14 UTC (rev 10096) @@ -30,7 +30,18 @@ option(ENABLE_f95 "Enable f95 bindings" ON) endif(DEFAULT_NO_BINDINGS) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_f77 OR ENABLE_f95) + include(CMakeDetermineFortranCompiler) + if(NOT CMAKE_Fortran_COMPILER) + message(STATUS "WARNING: Fortran compiler not found so disabling Fortran bindings and examples.") + set(ENABLE_f77 OFF CACHE BOOL "Enable f77 bindings" FORCE) + set(ENABLE_f95 OFF CACHE BOOL "Enable f95 bindings" FORCE) + endif(NOT CMAKE_Fortran_COMPILER) +endif(ENABLE_f77 OR ENABLE_f95) + +if(ENABLE_f77 OR ENABLE_f95) # Find and check Fortran compiler. enable_language(Fortran OPTIONAL) if(NOT CMAKE_Fortran_COMPILER_WORKS) @@ -41,14 +52,6 @@ endif(ENABLE_f77 OR ENABLE_f95) if(ENABLE_f77 OR ENABLE_f95) - if(NOT CMAKE_Fortran_COMPILER) - message(STATUS "WARNING: Fortran compiler not found so disabling Fortran bindings and examples.") - set(ENABLE_f77 OFF CACHE BOOL "Enable f77 bindings" FORCE) - set(ENABLE_f95 OFF CACHE BOOL "Enable f95 bindings" FORCE) - endif(NOT CMAKE_Fortran_COMPILER) -endif(ENABLE_f77 OR ENABLE_f95) - -if(ENABLE_f77 OR ENABLE_f95) # Don't compile Fortran 95 binding if compiler doesn't support it if(ENABLE_f95 AND NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90) message(STATUS "WARNING: " Modified: trunk/cmake/modules/java.cmake =================================================================== --- trunk/cmake/modules/java.cmake 2009-06-29 20:23:11 UTC (rev 10095) +++ trunk/cmake/modules/java.cmake 2009-06-30 01:03:14 UTC (rev 10096) @@ -40,7 +40,17 @@ set(ENABLE_java OFF CACHE BOOL "Enable Java bindings" FORCE) endif(ENABLE_java AND NOT SWIG_FOUND) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_java) + include(CMakeDetermineJavaCompiler) + if(NOT CMAKE_Java_COMPILER) + message(STATUS "WARNING: Java compiler not found so disabling Java bindings and examples.") + set(ENABLE_java OFF CACHE BOOL "Enable Java bindings" FORCE) + endif(NOT CMAKE_Java_COMPILER) +endif(ENABLE_java) + +if(ENABLE_java) # Find and check Java compiler. enable_language(Java OPTIONAL) if(NOT CMAKE_Java_COMPILER_WORKS) @@ -50,13 +60,6 @@ endif(ENABLE_java) if(ENABLE_java) - if(NOT CMAKE_Java_COMPILER) - message(STATUS "WARNING: Java compiler not found so disabling Java bindings and examples.") - set(ENABLE_java OFF CACHE BOOL "Enable Java bindings" FORCE) - endif(NOT CMAKE_Java_COMPILER) -endif(ENABLE_java) - -if(ENABLE_java) if(NOT CMAKE_Java_ARCHIVE) message(STATUS "WARNING: java archiver (jar) not found. Disabling java bindings") set(ENABLE_java OFF CACHE BOOL "Enable Java bindings" FORCE) Modified: trunk/examples/plplot_configure.cmake_installed_examples.in =================================================================== --- trunk/examples/plplot_configure.cmake_installed_examples.in 2009-06-29 20:23:11 UTC (rev 10095) +++ trunk/examples/plplot_configure.cmake_installed_examples.in 2009-06-30 01:03:14 UTC (rev 10096) @@ -78,28 +78,63 @@ foreach(language_info tk:? gnome2:? wxwidgets:? qt:? ${language_info_LIST}) string(REGEX REPLACE "^(.*):.*$" "\\1" language ${language_info}) #message("DEBUG: language = ${language}") - if(CORE_ENABLE_${language}) - if(NOT PRESET_DEFAULT) - set(DEFAULT ${CORE_ENABLE_${language}}) - endif(NOT PRESET_DEFAULT) - option(ENABLE_${language} "Enable ${language} bindings" ${DEFAULT}) - else(CORE_ENABLE_${language}) - set(ENABLE_${language} OFF CACHE BOOL "Enable ${language} bindings" FORCE) - endif(CORE_ENABLE_${language}) + if(language STREQUAL "c") + #special case where the build system requires C. + set(ENABLE_${language} ON CACHE BOOL "Enable ${language} bindings" FORCE) + else(language STREQUAL "c") + if(CORE_ENABLE_${language}) + if(NOT PRESET_DEFAULT) + set(DEFAULT ${CORE_ENABLE_${language}}) + endif(NOT PRESET_DEFAULT) + option(ENABLE_${language} "Enable ${language} bindings" ${DEFAULT}) + else(CORE_ENABLE_${language}) + set(ENABLE_${language} OFF CACHE BOOL "Enable ${language} bindings" FORCE) + endif(CORE_ENABLE_${language}) + endif(language STREQUAL "c") endforeach(language_info ${language_info_LIST}) -if(ENABLE_c) +# Always carry out C checks because build system requires a C compiler +# for some of the automatic checking that is done. +set(alwaysc ON) + +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. +if(alwaysc OR ENABLE_c) + include(CMakeDetermineCCompiler) + if(NOT CMAKE_C_COMPILER) + # This is a FATAL_ERROR rather than STATUS message because C compiler + # absolutely required for some of the automatic checking that is done. + message(FATAL_ERROR "C compiler absolutely required to build this project.") + message(STATUS "WARNING: C compiler not found so disabling C examples.") + set(ENABLE_c OFF CACHE BOOL "Enable c bindings" FORCE) + endif(NOT CMAKE_C_COMPILER) +endif(alwaysc OR ENABLE_c) + +if(alwaysc OR ENABLE_c) enable_language(C OPTIONAL) if(NOT CMAKE_C_COMPILER_WORKS) - message(STATUS: "WARNING: C compiler does not work so disabling C examples.") + # This is a FATAL_ERROR rather than STATUS message because C compiler + # absolutely required for some of the automatic checking that is done. + message(FATAL_ERROR "C compiler absolutely required to build this project.") + message(STATUS "WARNING: C compiler does not work so disabling C examples.") set(ENABLE_c OFF CACHE BOOL "Enable c bindings" FORCE) endif(NOT CMAKE_C_COMPILER_WORKS) -endif(ENABLE_c) +endif(alwaysc OR ENABLE_c) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_ada) + include(CMakeDetermineAdaCompiler) + if(NOT CMAKE_Ada_COMPILER) + message(STATUS "WARNING: Ada compiler not found so disabling Ada examples.") + set(ENABLE_ada OFF CACHE BOOL "Enable ada bindings" FORCE) + endif(NOT CMAKE_Ada_COMPILER) +endif(ENABLE_ada) + +if(ENABLE_ada) enable_language(Ada OPTIONAL) if(NOT CMAKE_Ada_COMPILER_WORKS) - message(STATUS: "WARNING: Ada compiler does not work so disabling Ada examples.") + message(STATUS "WARNING: Ada compiler does not work so disabling Ada examples.") set(ENABLE_ada OFF CACHE BOOL "Enable ada bindings" FORCE) endif(NOT CMAKE_Ada_COMPILER_WORKS) endif(ENABLE_ada) @@ -109,43 +144,84 @@ set(ADA_LIB_DIR @ADA_LIB_DIR@) endif(ENABLE_ada) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_cxx) + include(CMakeDetermineCXXCompiler) + if(NOT CMAKE_CXX_COMPILER) + message(STATUS "WARNING: C++ compiler not found so disabling C++ examples.") + set(ENABLE_cxx OFF CACHE BOOL "Enable cxx bindings" FORCE) + endif(NOT CMAKE_CXX_COMPILER) +endif(ENABLE_cxx) + +if(ENABLE_cxx) enable_language(CXX OPTIONAL) if(NOT CMAKE_CXX_COMPILER_WORKS) - message(STATUS: "WARNING: C++ compiler does not work so disabling C++ examples.") + message(STATUS "WARNING: C++ compiler does not work so disabling C++ examples.") set(ENABLE_cxx OFF CACHE BOOL "Enable cxx bindings" FORCE) endif(NOT CMAKE_CXX_COMPILER_WORKS) endif(ENABLE_cxx) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_d) + include(CMakeDetermineDCompiler) + if(NOT CMAKE_D_COMPILER) + message(STATUS "WARNING: D compiler not found so disabling D examples.") + set(ENABLE_d OFF CACHE BOOL "Enable d bindings" FORCE) + endif(NOT CMAKE_D_COMPILER) +endif(ENABLE_d) + +if(ENABLE_d) enable_language(D OPTIONAL) if(NOT CMAKE_D_COMPILER_WORKS) - message(STATUS: "WARNING: D compiler does not work so disabling D examples.") + message(STATUS "WARNING: D compiler does not work so disabling D examples.") set(ENABLE_d OFF CACHE BOOL "Enable d bindings" FORCE) endif(NOT CMAKE_D_COMPILER_WORKS) endif(ENABLE_d) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_f77 OR ENABLE_f95) - set(STATIC_OPTS @STATIC_OPTS@) + include(CMakeDetermineFortranCompiler) + if(NOT CMAKE_Fortran_COMPILER) + message(STATUS "WARNING: Fortran compiler not found so disabling Fortran examples.") + set(ENABLE_f77 OFF CACHE BOOL "Enable f77 bindings" FORCE) + set(ENABLE_f95 OFF CACHE BOOL "Enable f95 bindings" FORCE) + endif(NOT CMAKE_Fortran_COMPILER) endif(ENABLE_f77 OR ENABLE_f95) if(ENABLE_f77 OR ENABLE_f95) enable_language(Fortran OPTIONAL) if(NOT CMAKE_Fortran_COMPILER_WORKS) - message(STATUS: "WARNING: Fortran compiler does not work so disabling Fortran examples.") + message(STATUS "WARNING: Fortran compiler does not work so disabling Fortran examples.") set(ENABLE_f77 OFF CACHE BOOL "Enable f77 bindings" FORCE) set(ENABLE_f95 OFF CACHE BOOL "Enable f95 bindings" FORCE) endif(NOT CMAKE_Fortran_COMPILER_WORKS) endif(ENABLE_f77 OR ENABLE_f95) +if(ENABLE_f77 OR ENABLE_f95) + set(STATIC_OPTS @STATIC_OPTS@) +endif(ENABLE_f77 OR ENABLE_f95) + if(ENABLE_f95) set(F95_MOD_DIR @F95_MOD_DIR@) endif(ENABLE_f95) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_java) + include(CMakeDetermineJavaCompiler) + if(NOT CMAKE_Java_COMPILER) + message(STATUS "WARNING: Java compiler not found so disabling Java examples.") + set(ENABLE_java OFF CACHE BOOL "Enable java bindings" FORCE) + endif(NOT CMAKE_Java_COMPILER) +endif(ENABLE_java) + +if(ENABLE_java) enable_language(Java OPTIONAL) if(NOT CMAKE_Java_COMPILER_WORKS) - message(STATUS: "WARNING: Java compiler does not work so disabling Java examples.") + message(STATUS "WARNING: Java compiler does not work so disabling Java examples.") set(ENABLE_java OFF CACHE BOOL "Enable java bindings" FORCE) endif(NOT CMAKE_Java_COMPILER_WORKS) endif(ENABLE_java) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |