Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip BLAS when not needed #474

Open
Fabian188 opened this issue Nov 20, 2024 · 0 comments
Open

skip BLAS when not needed #474

Fabian188 opened this issue Nov 20, 2024 · 0 comments

Comments

@Fabian188
Copy link

Fabian188 commented Nov 20, 2024

I need only the lib and no tests and no examples. In that case it is not necessary to search for blas.

We already have variables TESTS and EXAMPLES in CMakeLists.txt.
My patch simple does not touch anything with BLAS if both are disabled.

I'm not used to github and neither know the process nor the test stuff here.

Probably one of the experience would apply my patch if the content is of interest?

I wrote the patch based on 3.9.1

-if (NOT TARGET BLAS::BLAS) # Search only if not already found by upper CMakeLists.txt
+if ((TESTS OR EXAMPLES) AND NOT TARGET BLAS::BLAS) # Search only if required and not already found by upper CMakeLists.txt
     find_package(BLAS REQUIRED)
-
     # BLAS::BLAS target was already created at this point by FindBLAS.cmake if cmake version >= 3.18
     if (NOT TARGET BLAS::BLAS) # Create target "at hand" to ensure compatibility if cmake version < 3.18
         add_library(BLAS::BLAS INTERFACE IMPORTED)
@@ -292,7 +291,7 @@
 
 # Find LAPACK
 
-if (NOT TARGET LAPACK::LAPACK) # Search only if not already found by upper CMakeLists.txt
+if ((TESTS OR EXAMPLES) AND NOT TARGET LAPACK::LAPACK) # Search only if required and not already found by upper CMakeLists.txt
     find_package(LAPACK REQUIRED)
 
     # LAPACK::LAPACK target was already created at this point by FindLAPACK.cmake if cmake version >= 3.18
@@ -304,7 +303,7 @@
 
 # As BLAS/LAPACK does not provide ICB, we may have to deal with symbols the old-fashion-boring-cumbersome-fortran/C way...
 
-if (SYMBOLSUFFIX)
+if ((TESTS OR EXAMPLES) AND SYMBOLSUFFIX)
     if ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
       set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp -ffixed-line-length-none")
     elseif ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel")
@@ -388,13 +387,15 @@
 # use -DBUILD_SHARED_LIBS=ON|OFF to control static/shared
 add_library(arpack ${arpackutil_STAT_SRCS} ${arpacksrc_STAT_SRCS} ${arpacksrc_ICB})
 
-target_link_libraries(arpack
-  PUBLIC
-  $<INSTALL_INTERFACE:$<IF:$<BOOL:${BUILD_SHARED_LIBS}>,,LAPACK::LAPACK>>
-  $<INSTALL_INTERFACE:$<IF:$<BOOL:${BUILD_SHARED_LIBS}>,,BLAS::BLAS>>
-  $<BUILD_INTERFACE:LAPACK::LAPACK>
-  $<BUILD_INTERFACE:BLAS::BLAS>
-)
+if(TESTS OR EXAMPLES)
+  target_link_libraries(arpack
+    PUBLIC
+    $<INSTALL_INTERFACE:$<IF:$<BOOL:${BUILD_SHARED_LIBS}>,,LAPACK::LAPACK>>
+    $<INSTALL_INTERFACE:$<IF:$<BOOL:${BUILD_SHARED_LIBS}>,,BLAS::BLAS>>
+    $<BUILD_INTERFACE:LAPACK::LAPACK>
+    $<BUILD_INTERFACE:BLAS::BLAS>  
+  )
+endif()  

arpack_no_blas.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant