Skip to content
Snippets Groups Projects
Commit 0ca96f2d authored by Markus Blatt's avatar Markus Blatt
Browse files

enable_language(<language> OPTIONAL) does not work due to bug

http://public.kitware.com/Bug/view.php?id=9220 .
Used the provided workaround to make fortran optional.

Please note:
No Fortran == No Lapack or Blas

[[Imported from SVN: r6639]]
parent b204a2f7
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ dune_module_information(${CMAKE_SOURCE_DIR})
set(ProjectName "${DUNE_MOD_NAME}")
set(ProjectVersion "${DUNE_MOD_VERSION}")
set(ProjectMaintainerEmail "${DUNE_MAINTAINER}")
project(${ProjectName} C CXX Fortran)
project(${ProjectName} C CXX)# Fortran)
set(DUNE_COMMON_VERSION "${DUNE_MOD_VERSION}")
set(DUNE_COMMON_VERSION_MAJOR "${DUNE_VERSION_MAJOR}")
set(DUNE_COMMON_VERSION_MINOR "${DUNE_VERSION_MINOR}")
......@@ -66,16 +66,24 @@ include(DUNEMPI)
find_package(Boost)
set(HAVE_BOOST BOOST_FOUND)
find_package(SharedPtr)
include(LanguageSupport)
workaround_9220(Fortran Fortran_Works)
if(Fortran_Works)
enable_language(Fortran OPTIONAL)
# search for lapack
find_package(LAPACK)
set(HAVE_LAPACK LAPACK_FOUND)
set(HAVE_BLAS BLAS_FOUND)
# make calling fortran routines from C/C++ possible
include(FortranCInterface)
FortranCInterface_VERIFY(CXX)
FortranCInterface_HEADER(FC.h MACRO_NAMESPACE "FC_")
else(Fortran_Works)
set(HAVE_LAPACK Off)
set(HAVE_BLAS Off)
file(WRITE ${CMAKE_BINARY_DIR}/FC.h "")
endif(Fortran_Works)
# search for lapack
find_package(LAPACK)
set(HAVE_LAPACK LAPACK_FOUND)
set(HAVE_BLAS BLAS_FOUND)
# make calling fortran routines from C/C++ possible
include(FortranCInterface)
FortranCInterface_VERIFY(CXX)
FortranCInterface_HEADER(FC.h MACRO_NAMESPACE "FC_")
# actually write the config.h file to disk
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
......
# 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.
# On debian testing (cmake 2.6.2), I get return code zero when calling
# cmake the first time, but cmake crashes when running a second time
# as follows:
#
# -- The Fortran compiler identification is unknown
# CMake Error at /usr/share/cmake-2.6/Modules/CMakeFortranInformation.cmake:7 (GET_FILENAME_COMPONENT):
# get_filename_component called with incorrect number of arguments
# Call Stack (most recent call first):
# CMakeLists.txt:3 (enable_language)
#
# My workaround is to invoke cmake twice. If both return codes are zero,
# it is safe to invoke ENABLE_LANGUAGE(Fortran OPTIONAL)
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)
# Second run
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)
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}")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment