mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-18 14:34:17 +08:00
Replace language_support module with builtin CheckLanguage
The workaround_9220 function was introduced a long time ago to workaround a CMake issue with enable_language(OPTIONAL). Since then CMake has clarified that the OPTIONAL keywords has not been implemented[0]. A CheckLanguage module is now provided with CMake to check if a language can be enabled. Use that instead. [0] https://cmake.org/cmake/help/v3.18/command/enable_language.html
This commit is contained in:
parent
3f4684f87d
commit
288d456c29
@ -1,15 +1,13 @@
|
||||
|
||||
project(EigenBlas CXX)
|
||||
|
||||
include("../cmake/language_support.cmake")
|
||||
|
||||
workaround_9220(Fortran EIGEN_Fortran_COMPILER_WORKS)
|
||||
|
||||
if(EIGEN_Fortran_COMPILER_WORKS)
|
||||
enable_language(Fortran OPTIONAL)
|
||||
if(NOT CMAKE_Fortran_COMPILER)
|
||||
set(EIGEN_Fortran_COMPILER_WORKS OFF)
|
||||
endif()
|
||||
include(CheckLanguage)
|
||||
check_language(Fortran)
|
||||
if(CMAKE_Fortran_COMPILER)
|
||||
enable_language(Fortran)
|
||||
set(EIGEN_Fortran_COMPILER_WORKS ON)
|
||||
else()
|
||||
set(EIGEN_Fortran_COMPILER_WORKS OFF)
|
||||
endif()
|
||||
|
||||
add_custom_target(blas)
|
||||
|
@ -1,67 +0,0 @@
|
||||
# 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.8.11)
|
||||
set (CMAKE_Fortran_FLAGS \"${CMAKE_Fortran_FLAGS}\")
|
||||
set (CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}\")
|
||||
enable_language(${language})
|
||||
")
|
||||
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} . -G "${CMAKE_GENERATOR}" -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
|
||||
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} . -G "${CMAKE_GENERATOR}" -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
|
||||
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()
|
||||
set(${language_works} OFF PARENT_SCOPE)
|
||||
endif()
|
||||
else()
|
||||
set(${language_works} OFF PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# 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}")
|
||||
|
@ -1,15 +1,13 @@
|
||||
|
||||
project(EigenLapack CXX)
|
||||
|
||||
include("../cmake/language_support.cmake")
|
||||
|
||||
workaround_9220(Fortran EIGEN_Fortran_COMPILER_WORKS)
|
||||
|
||||
if(EIGEN_Fortran_COMPILER_WORKS)
|
||||
enable_language(Fortran OPTIONAL)
|
||||
if(NOT CMAKE_Fortran_COMPILER)
|
||||
set(EIGEN_Fortran_COMPILER_WORKS OFF)
|
||||
endif()
|
||||
include(CheckLanguage)
|
||||
check_language(Fortran)
|
||||
if(CMAKE_Fortran_COMPILER)
|
||||
enable_language(Fortran)
|
||||
set(EIGEN_Fortran_COMPILER_WORKS ON)
|
||||
else()
|
||||
set(EIGEN_Fortran_COMPILER_WORKS OFF)
|
||||
endif()
|
||||
|
||||
add_custom_target(lapack)
|
||||
|
@ -5,18 +5,13 @@ if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/split_test_helper.h)
|
||||
endif()
|
||||
|
||||
# check if we have a Fortran compiler
|
||||
include("../cmake/language_support.cmake")
|
||||
|
||||
workaround_9220(Fortran EIGEN_Fortran_COMPILER_WORKS)
|
||||
|
||||
if(EIGEN_Fortran_COMPILER_WORKS)
|
||||
enable_language(Fortran OPTIONAL)
|
||||
if(NOT CMAKE_Fortran_COMPILER)
|
||||
set(EIGEN_Fortran_COMPILER_WORKS OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT EIGEN_Fortran_COMPILER_WORKS)
|
||||
include(CheckLanguage)
|
||||
check_language(Fortran)
|
||||
if(CMAKE_Fortran_COMPILER)
|
||||
enable_language(Fortran)
|
||||
set(EIGEN_Fortran_COMPILER_WORKS ON)
|
||||
else()
|
||||
set(EIGEN_Fortran_COMPILER_WORKS OFF)
|
||||
# search for a default Lapack library to complete Eigen's one
|
||||
find_package(LAPACK QUIET)
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user