From 09d7122468fb9b9adf813cf32167ab212511c4d8 Mon Sep 17 00:00:00 2001 From: "Daniel N. Miller (APD)" Date: Wed, 23 Jun 2021 21:09:53 -0700 Subject: [PATCH] Do not build shared libs if not supported --- CMakeLists.txt | 3 +++ blas/CMakeLists.txt | 27 +++++++++++++++++---------- lapack/CMakeLists.txt | 30 +++++++++++++++++------------- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd1af32b2..f3e69b845 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,9 @@ else() ei_add_cxx_compiler_flag("-std=c++03") endif() +# Determine if we should build shared libraries on this platform. +get_cmake_property(EIGEN_BUILD_SHARED_LIBS TARGET_SUPPORTS_SHARED_LIBS) + ############################################################################# # find how to link to the standard libraries # ############################################################################# diff --git a/blas/CMakeLists.txt b/blas/CMakeLists.txt index 545bc989c..f3a94ec4a 100644 --- a/blas/CMakeLists.txt +++ b/blas/CMakeLists.txt @@ -26,20 +26,27 @@ else() set(EigenBlas_SRCS ${EigenBlas_SRCS} f2c/complexdots.c) endif() -add_library(eigen_blas_static ${EigenBlas_SRCS}) -add_library(eigen_blas SHARED ${EigenBlas_SRCS}) +set(EIGEN_BLAS_TARGETS "") -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}) +add_library(eigen_blas_static ${EigenBlas_SRCS}) +list(APPEND EIGEN_BLAS_TARGETS eigen_blas_static) + +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) diff --git a/lapack/CMakeLists.txt b/lapack/CMakeLists.txt index 9eec81076..e48497fda 100644 --- a/lapack/CMakeLists.txt +++ b/lapack/CMakeLists.txt @@ -88,25 +88,29 @@ endif() endif() +set(EIGEN_LAPACK_TARGETS "") + add_library(eigen_lapack_static ${EigenLapack_SRCS} ${ReferenceLapack_SRCS}) -add_library(eigen_lapack SHARED ${EigenLapack_SRCS}) +list(APPEND EIGEN_LAPACK_TARGETS eigen_lapack_static) -target_link_libraries(eigen_lapack eigen_blas) - -if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO) - target_link_libraries(eigen_lapack_static ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}) - target_link_libraries(eigen_lapack ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}) +if (EIGEN_BUILD_SHARED_LIBS) + add_library(eigen_lapack SHARED ${EigenLapack_SRCS}) + list(APPEND EIGEN_LAPACK_TARGETS eigen_lapack) + target_link_libraries(eigen_lapack eigen_blas) endif() -add_dependencies(lapack eigen_lapack eigen_lapack_static) +foreach(target IN LISTS EIGEN_LAPACK_TARGETS) + if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO) + target_link_libraries(${target} ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}) + endif() + add_dependencies(lapack ${target}) + install(TARGETS ${target} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) +endforeach() -install(TARGETS eigen_lapack eigen_lapack_static - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) - - get_filename_component(eigen_full_path_to_testing_lapack "./testing/" ABSOLUTE) if(EXISTS ${eigen_full_path_to_testing_lapack})