mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-30 17:40:05 +08:00
hopefully this workaround of cmake bug #9220 works for MSVC too
This commit is contained in:
parent
1ddf88060b
commit
e44c19d1cc
@ -1,25 +1,19 @@
|
||||
|
||||
project(EigenBlas CXX)
|
||||
|
||||
if( NOT DEFINED EIGEN_Fortran_COMPILER_WORKS OR EIGEN_Fortran_COMPILER_WORKS)
|
||||
include("../cmake/language_support.cmake")
|
||||
|
||||
workaround_9220(Fortran EIGEN_Fortran_COMPILER_WORKS)
|
||||
|
||||
if(EIGEN_Fortran_COMPILER_WORKS)
|
||||
enable_language(Fortran OPTIONAL)
|
||||
|
||||
if(CMAKE_Fortran_COMPILER_WORKS)
|
||||
set(EIGEN_Fortran_COMPILER_WORKS TRUE CACHE INTERNAL "workaround cmake's enable_language issue")
|
||||
else()
|
||||
set(EIGEN_Fortran_COMPILER_WORKS FALSE CACHE INTERNAL "workaround cmake's enable_language issue")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
add_custom_target(blas)
|
||||
|
||||
set(EigenBlas_SRCS single.cpp double.cpp complex_single.cpp complex_double.cpp xerbla.cpp)
|
||||
|
||||
if(CMAKE_Fortran_COMPILER_WORKS)
|
||||
|
||||
message(WARNING " No fortran compiler has been detected, the blas build will be incomplete.")
|
||||
if(EIGEN_Fortran_COMPILER_WORKS)
|
||||
|
||||
set(EigenBlas_SRCS ${EigenBlas_SRCS}
|
||||
complexdots.f
|
||||
@ -29,8 +23,11 @@ set(EigenBlas_SRCS ${EigenBlas_SRCS}
|
||||
zhbmv.f zhpr.f ztpmv.f chpmv.f ctbmv.f ctpsv.f dsbmv.f dspr.f dtpmv.f sspr2.f
|
||||
stbsv.f zhpmv.f ztbmv.f ztpsv.f
|
||||
)
|
||||
else()
|
||||
|
||||
endif(CMAKE_Fortran_COMPILER_WORKS)
|
||||
message(WARNING " No fortran compiler has been detected, the blas build will be incomplete.")
|
||||
|
||||
endif()
|
||||
|
||||
add_library(eigen_blas_static ${EigenBlas_SRCS})
|
||||
add_library(eigen_blas SHARED ${EigenBlas_SRCS})
|
||||
@ -47,7 +44,7 @@ install(TARGETS eigen_blas eigen_blas_static
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib)
|
||||
|
||||
if(CMAKE_Fortran_COMPILER_WORKS)
|
||||
if(EIGEN_Fortran_COMPILER_WORKS)
|
||||
|
||||
if(EIGEN_LEAVE_TEST_IN_ALL_TARGET)
|
||||
add_subdirectory(testing) # can't do EXCLUDE_FROM_ALL here, breaks CTest
|
||||
|
65
cmake/language_support.cmake
Normal file
65
cmake/language_support.cmake
Normal file
@ -0,0 +1,65 @@
|
||||
# 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}")
|
@ -1,19 +1,14 @@
|
||||
|
||||
project(EigenLapack CXX)
|
||||
|
||||
if( NOT DEFINED EIGEN_Fortran_COMPILER_WORKS OR EIGEN_Fortran_COMPILER_WORKS)
|
||||
include("../cmake/language_support.cmake")
|
||||
|
||||
workaround_9220(Fortran EIGEN_Fortran_COMPILER_WORKS)
|
||||
|
||||
if(EIGEN_Fortran_COMPILER_WORKS)
|
||||
enable_language(Fortran OPTIONAL)
|
||||
|
||||
if(CMAKE_Fortran_COMPILER_WORKS)
|
||||
set(EIGEN_Fortran_COMPILER_WORKS TRUE CACHE INTERNAL "workaround cmake's enable_language issue")
|
||||
else()
|
||||
set(EIGEN_Fortran_COMPILER_WORKS FALSE CACHE INTERNAL "workaround cmake's enable_language issue")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
add_custom_target(lapack)
|
||||
include_directories(../blas)
|
||||
|
||||
@ -21,7 +16,7 @@ set(EigenLapack_SRCS
|
||||
single.cpp double.cpp complex_single.cpp complex_double.cpp ../blas/xerbla.cpp
|
||||
)
|
||||
|
||||
if(CMAKE_Fortran_COMPILER_WORKS)
|
||||
if(EIGEN_Fortran_COMPILER_WORKS)
|
||||
|
||||
get_filename_component(eigen_full_path_to_reference_to_reference_lapack "./reference/" ABSOLUTE)
|
||||
if(EXISTS ${eigen_full_path_to_reference_to_reference_lapack})
|
||||
@ -358,7 +353,7 @@ reference/ctbcon.f reference/dormhr.f reference/sla_
|
||||
)
|
||||
endif()
|
||||
|
||||
endif(CMAKE_Fortran_COMPILER_WORKS)
|
||||
endif(EIGEN_Fortran_COMPILER_WORKS)
|
||||
|
||||
add_library(eigen_lapack_static ${EigenLapack_SRCS})
|
||||
add_library(eigen_lapack SHARED ${EigenLapack_SRCS})
|
||||
|
Loading…
Reference in New Issue
Block a user