[CMake] FORTRAN and BLAS Issue
Matthew Clay
mpclay at gmail.com
Thu May 3 23:25:23 EDT 2012
Fellow cmake users:
I am experiencing a minor issue with cmake, and can't seem to find an
answer browsing the web. I have a minimal working example that
highlights the issue with my main code. The problem is this: compiling
by myself with gfortran and the appropriate flags produces no errors,
while attempting to build the code with cmake throws an error.
The FORTRAN code--note that DDOT is the call to BLAS that I want to make:
PROGRAM TEST
IMPLICIT NONE
DOUBLE PRECISION,DIMENSION(2) :: x,y ! The two vectors.
REAL(KIND=8),EXTERNAL :: DDOT ! Their dot product.
x(:) = (/ 1.,100. /)
y(:) = (/ 1.,1. /)
WRITE (*,*) DDOT(2,x,1,y,1)
END PROGRAM TEST
What works:
gfortran test.f90 -O3 -lblas
./a.out
What doesn't work:
cmake_minimum_required(VERSION 2.8)
project(collision)
enable_language(Fortran)
FIND_PACKAGE(BLAS REQUIRED)
add_definitions(-O3 -lblas)
add_executable(collision test.f90)
Upon attempting [ mkdir build && cd build && cmake .. && make ] as with
any other code I get the following result:
Scanning dependencies of target collision
[100%] Building Fortran object CMakeFiles/collision.dir/test.f90.o
Linking Fortran executable collision
CMakeFiles/collision.dir/test.f90.o: In function `MAIN__':
test.f90:(.text+0x7d): undefined reference to `ddot_'
collect2: error: ld returned 1 exit status
make[2]: *** [collision] Error 1
make[1]: *** [CMakeFiles/collision.dir/all] Error 2
It appears that BLAS is not being linked with the code...maybe? I am not
a cmake expert, and would greatly appreciate any words of wisdom for
troubleshooting this problem!
Thanks,
Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120503/0043c280/attachment-0001.htm>
More information about the CMake
mailing list