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

LAPACK requires CMake 3.11 or newer #975

Closed
2 tasks done
christoph-conrads opened this issue Jan 13, 2024 · 1 comment · Fixed by #976
Closed
2 tasks done

LAPACK requires CMake 3.11 or newer #975

christoph-conrads opened this issue Jan 13, 2024 · 1 comment · Fixed by #976

Comments

@christoph-conrads
Copy link
Contributor

Description

When building a BLAS shared library with cmake -DBUILD_SHARED_LIBS=ON with CMake releases before version 3.11, linking of the BLAS library will fail:

[ 27%] Linking Fortran shared library ../../lib/libblas.so
CMakeFiles/blas_64_obj.dir/blas_64_obj/isamax.f.o: In function `isamax_':
/tmp/build/BLAS/SRC/blas_64_obj/isamax.f:70: multiple definition of `isamax_'
CMakeFiles/blas_obj.dir/isamax.f.o:/home/docker/lapack/BLAS/SRC/isamax.f:70: first defined here
CMakeFiles/blas_64_obj.dir/blas_64_obj/lsame.f.o: In function `lsame_':
/tmp/build/BLAS/SRC/blas_64_obj/lsame.f:52: multiple definition of `lsame_'
CMakeFiles/blas_obj.dir/lsame.f.o:/home/docker/lapack/BLAS/SRC/lsame.f:52: first defined here
CMakeFiles/blas_64_obj.dir/blas_64_obj/sasum.f.o: In function `sasum_':
/tmp/build/BLAS/SRC/blas_64_obj/sasum.f:71: multiple definition of `sasum_'
CMakeFiles/blas_obj.dir/sasum.f.o:/home/docker/lapack/BLAS/SRC/sasum.f:71: first defined here
[snip]

The cause is an attempt to set the source file property COMPILE_OPTIONS:

list(APPEND COPT_64_F "-D${FUNC}=${FUNC}_64")
endforeach()
list(REMOVE_DUPLICATES COPT_64_F)
set_source_files_properties(${F} PROPERTIES COMPILE_OPTIONS "${COPT_64_F}")

This property exists only from CMake 3.11 onwards and these compiler options would avoid the name clash.

There are two possible fixes:

Checklist

  • I've included a minimal example to reproduce the issue
  • I'd be willing to make a PR to solve this issue
@christoph-conrads
Copy link
Contributor Author

christoph-conrads commented Jan 13, 2024

Suggested fix (will be PR'ed later) tested on Ubuntu 18.04 with CMake 3.10.2:

diff --git a/BLAS/SRC/CMakeLists.txt b/BLAS/SRC/CMakeLists.txt
index 9df128eb5..d90198f37 100644
--- a/BLAS/SRC/CMakeLists.txt
+++ b/BLAS/SRC/CMakeLists.txt
@@ -124,9 +124,9 @@ if(BUILD_INDEX64_EXT_API)
   #Add _64 suffix to all Fortran functions via macros
   foreach(F IN LISTS SOURCES_64_F)
     if(CMAKE_Fortran_COMPILER_ID STREQUAL "NAG")
-      set(COPT_64_F -fpp)
+               set_source_files_properties(${F} PROPERTIES COMPILE_FLAGS "-fpp")
     else()
-      set(COPT_64_F -cpp)
+               set_source_files_properties(${F} PROPERTIES COMPILE_FLAGS "-cpp")
     endif()
     file(STRINGS ${F} ${F}.lst)
     list(FILTER ${F}.lst INCLUDE REGEX "subroutine|SUBROUTINE|external|EXTERNAL|function|FUNCTION")
@@ -137,10 +137,10 @@ if(BUILD_INDEX64_EXT_API)
       string(REGEX REPLACE "^[a-zA-Z0-9_ *]*(subroutine|SUBROUTINE|external|EXTERNAL|function|FUNCTION)[ ]*[*]?" "" FUNC ${FUNC})
       string(REGEX REPLACE "[(][a-zA-Z0-9_, )]*$" "" FUNC ${FUNC})
       string(STRIP ${FUNC} FUNC)
-      list(APPEND COPT_64_F "-D${FUNC}=${FUNC}_64")
+      list(APPEND COPT_64_F "${FUNC}=${FUNC}_64")
     endforeach()
     list(REMOVE_DUPLICATES COPT_64_F)
-    set_source_files_properties(${F} PROPERTIES COMPILE_OPTIONS "${COPT_64_F}")
+        set_source_files_properties(${F} PROPERTIES COMPILE_DEFINITIONS "${COPT_64_F}")
   endforeach()
 endif()

christoph-conrads added a commit to christoph-conrads/lapack that referenced this issue Jan 13, 2024
The COMPILE_OPTIONS property exists only from CMake 3.11 onwards.

fixes Reference-LAPACK#975
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant