<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Fellow cmake users:<br>
<br>
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. <br>
<br>
The FORTRAN code--note that DDOT is the call to BLAS that I want to
make:<br>
<br>
<font face="Courier New, Courier, monospace">PROGRAM TEST<br>
IMPLICIT NONE<br>
DOUBLE PRECISION,DIMENSION(2) :: x,y ! The two vectors.<br>
REAL(KIND=8),EXTERNAL :: DDOT ! Their dot product.<br>
x(:) = (/ 1.,100. /)<br>
y(:) = (/ 1.,1. /)<br>
WRITE (*,*) DDOT(2,x,1,y,1)<br>
END PROGRAM TEST</font><br>
<br>
What works:<br>
<br>
<font face="Courier New, Courier, monospace">gfortran test.f90 -O3
-lblas</font><br>
<font face="Courier New, Courier, monospace">./a.out</font><br>
<br>
What doesn't work:<br>
<br>
<font face="Courier New, Courier, monospace">cmake_minimum_required(VERSION
2.8)<br>
project(collision)<br>
enable_language(Fortran)<br>
FIND_PACKAGE(BLAS REQUIRED)<br>
add_definitions(-O3 -lblas)<br>
add_executable(collision test.f90)</font><br>
<br>
Upon attempting [ <font face="Courier New, Courier, monospace">mkdir
build && cd build && cmake .. && make ]</font>
as with any other code I get the following result:<br>
<br>
<font face="Courier New, Courier, monospace">Scanning dependencies
of target collision<br>
[100%] Building Fortran object CMakeFiles/collision.dir/test.f90.o<br>
Linking Fortran executable collision<br>
CMakeFiles/collision.dir/test.f90.o: In function `MAIN__':<br>
test.f90:(.text+0x7d): undefined reference to `ddot_'<br>
collect2: error: ld returned 1 exit status<br>
make[2]: *** [collision] Error 1<br>
make[1]: *** [CMakeFiles/collision.dir/all] Error 2</font><br>
<br>
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!<br>
<br>
Thanks,<br>
Matt<br>
</body>
</html>