1 # cmake/modules/language_support.cmake
3 # Temporary additional general language support is contained within this
6 # This additional function definition is needed to provide a workaround for
9 # On debian testing (cmake 2.6.2), I get return code zero when calling
10 # cmake the first time, but cmake crashes when running a second time
13 # -- The Fortran compiler identification is unknown
14 # CMake Error at /usr/share/cmake-2.6/Modules/CMakeFortranInformation.cmake:7 (GET_FILENAME_COMPONENT):
15 # get_filename_component called with incorrect number of arguments
16 # Call Stack (most recent call first):
17 # CMakeLists.txt:3 (enable_language)
19 # My workaround is to invoke cmake twice. If both return codes are zero,
20 # it is safe to invoke ENABLE_LANGUAGE(Fortran OPTIONAL)
22 function(workaround_9220 language language_works)
23 #message("DEBUG: language = ${language}")
26 cmake_minimum_required(VERSION 2.8.0)
27 set (CMAKE_Fortran_FLAGS \"${CMAKE_Fortran_FLAGS}\")
28 set (CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}\")
29 enable_language(${language} OPTIONAL)
31 file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/language_tests/${language})
32 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/language_tests/${language})
33 file(WRITE ${CMAKE_BINARY_DIR}/language_tests/${language}/CMakeLists.txt
36 COMMAND ${CMAKE_COMMAND} . -G "${CMAKE_GENERATOR}"
37 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/language_tests/${language}
38 RESULT_VARIABLE return_code
43 if(return_code EQUAL 0)
46 COMMAND ${CMAKE_COMMAND} . -G "${CMAKE_GENERATOR}"
47 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/language_tests/${language}
48 RESULT_VARIABLE return_code
52 if(return_code EQUAL 0)
53 set(${language_works} ON PARENT_SCOPE)
54 else(return_code EQUAL 0)
55 set(${language_works} OFF PARENT_SCOPE)
56 endif(return_code EQUAL 0)
57 else(return_code EQUAL 0)
58 set(${language_works} OFF PARENT_SCOPE)
59 endif(return_code EQUAL 0)
60 endfunction(workaround_9220)
62 # Temporary tests of the above function.
63 #workaround_9220(CXX CXX_language_works)
64 #message("CXX_language_works = ${CXX_language_works}")
65 #workaround_9220(CXXp CXXp_language_works)
66 #message("CXXp_language_works = ${CXXp_language_works}")