diff options
Diffstat (limited to 'blas/CMakeLists.txt')
-rw-r--r-- | blas/CMakeLists.txt | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/blas/CMakeLists.txt b/blas/CMakeLists.txt index d0efb4188..f3a94ec4a 100644 --- a/blas/CMakeLists.txt +++ b/blas/CMakeLists.txt @@ -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) @@ -28,27 +26,36 @@ else() set(EigenBlas_SRCS ${EigenBlas_SRCS} f2c/complexdots.c) endif() +set(EIGEN_BLAS_TARGETS "") + add_library(eigen_blas_static ${EigenBlas_SRCS}) -add_library(eigen_blas SHARED ${EigenBlas_SRCS}) +list(APPEND EIGEN_BLAS_TARGETS eigen_blas_static) -if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO) - target_link_libraries(eigen_blas_static ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}) - target_link_libraries(eigen_blas ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}) +if (EIGEN_BUILD_SHARED_LIBS) + add_library(eigen_blas SHARED ${EigenBlas_SRCS}) + list(APPEND EIGEN_BLAS_TARGETS eigen_blas) endif() -add_dependencies(blas eigen_blas eigen_blas_static) +foreach(target IN LISTS EIGEN_BLAS_TARGETS) + if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO) + target_link_libraries(${target} ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}) + endif() -install(TARGETS eigen_blas eigen_blas_static - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) + add_dependencies(blas ${target}) + install(TARGETS ${target} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) +endforeach() if(EIGEN_Fortran_COMPILER_WORKS) -if(EIGEN_LEAVE_TEST_IN_ALL_TARGET) - add_subdirectory(testing) # can't do EXCLUDE_FROM_ALL here, breaks CTest -else() - add_subdirectory(testing EXCLUDE_FROM_ALL) +if(BUILD_TESTING) + if(EIGEN_LEAVE_TEST_IN_ALL_TARGET) + add_subdirectory(testing) # can't do EXCLUDE_FROM_ALL here, breaks CTest + else() + add_subdirectory(testing EXCLUDE_FROM_ALL) + endif() endif() endif() |