LP-311 Remove basic/advanced stabilization tab auto-switch (autotune/txpid lock issues)
[librepilot.git] / ground / gcs / src / libs / eigen / cmake / language_support.cmake
blob231f7ff70351da6342309b1a42b8fc012640a431
1 # cmake/modules/language_support.cmake
3 # Temporary additional general language support is contained within this
4 # file.  
6 # This additional function definition is needed to provide a workaround for
7 # CMake bug 9220.
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
11 # as follows:
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}")
24   set(text
25     "project(test NONE)
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)
30   ")
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
34     ${text})
35   execute_process(
36     COMMAND ${CMAKE_COMMAND} . -G "${CMAKE_GENERATOR}"
37     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/language_tests/${language}
38     RESULT_VARIABLE return_code
39     OUTPUT_QUIET
40     ERROR_QUIET
41     )
43   if(return_code EQUAL 0)
44     # Second run
45     execute_process (
46       COMMAND ${CMAKE_COMMAND} .
47       WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/language_tests/${language}
48       RESULT_VARIABLE return_code
49       OUTPUT_QUIET
50       ERROR_QUIET
51       )
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}")